From d890337e6cb24dd003b8887ffdca140b85ffe776 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 11 Jun 2021 17:25:13 +0200 Subject: Implemented planting. --- tensor.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tensor.hpp b/tensor.hpp index 6a5b2c2..1d90c78 100644 --- a/tensor.hpp +++ b/tensor.hpp @@ -89,6 +89,27 @@ Tensor generateCouplings(unsigned N, Distribution d, Generator& r) { return J; } +template +Tensor plantState(const Tensor& J, const Vector& z, double β) { + Tensor JPlanted = J; + + std::function&, std::array)> plant = + [&z, β] (Tensor& JJ, std::array ind) { + Scalar Ji = getJ(JJ, ind); + Scalar zzz = 1; + + for (unsigned i : ind) { + zzz *= z(i); + } + + setJ(JJ, ind, Ji - β * zzz / pow(zzz.size(), p)); + }; + + iterateOver(JPlanted, plant); + + return JPlanted; +} + template Matrix contractDown(const Tensor& J, const Vector& z) { return Eigen::Map>(J.data(), z.size(), z.size()); -- cgit v1.2.3-70-g09d2