From bcc5c327016a3d188a9bdcb0069cc63b0bb8163f Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 9 Nov 2021 15:41:56 +0100 Subject: Moved some repeated code into the pSpinModel class. --- tensor.hpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'tensor.hpp') diff --git a/tensor.hpp b/tensor.hpp index fc99042..1212bda 100644 --- a/tensor.hpp +++ b/tensor.hpp @@ -5,6 +5,8 @@ #include +#include "factorial.hpp" + template using Vector = Eigen::Matrix; @@ -89,25 +91,11 @@ 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); +template +Tensor generateRealPSpinCouplings(unsigned N, Generator& r) { + Real σp = sqrt(factorial(p) / ((Real)2 * pow(N, p - 1))); - return JPlanted; + return generateCouplings(N, std::normal_distribution(0, σp), r); } template -- cgit v1.2.3-54-g00ecf