From 21a40622a0f542a7cf6ae695f2230205ecc3f445 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 5 Jan 2021 12:02:45 +0100 Subject: Eliminated one pesky helper function. --- tensor.hpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'tensor.hpp') diff --git a/tensor.hpp b/tensor.hpp index 9e860d9..a2170a8 100644 --- a/tensor.hpp +++ b/tensor.hpp @@ -7,12 +7,6 @@ #include "factorial.hpp" -template -void setJ(Scalar z, Eigen::Tensor& J, const std::array& is, - std::index_sequence) { - J(std::get(is)...) = z; -} - template Eigen::Tensor initializeJ(unsigned N, std::index_sequence) { std::array Ns; @@ -20,13 +14,14 @@ Eigen::Tensor initializeJ(unsigned N, std::index_sequence return Eigen::Tensor(std::get(Ns)...); } -template +template void populateCouplings(Eigen::Tensor& J, unsigned N, unsigned l, - std::array is, Distribution d, Generator& r) { + std::array is, Distribution d, Generator& r, + std::index_sequence ii) { if (l == 0) { Scalar z = d(r); do { - setJ(z, J, is, std::make_index_sequence

()); + J(std::get(is)...) = z; } while (std::next_permutation(is.begin(), is.end())); } else { unsigned iMin; @@ -38,7 +33,7 @@ void populateCouplings(Eigen::Tensor& J, unsigned N, unsigned l, for (unsigned i = iMin; i < N; i++) { std::array js = is; js[p - l] = i; - populateCouplings(J, N, l - 1, js, d, r); + populateCouplings(J, N, l - 1, js, d, r, ii); } } } @@ -48,7 +43,7 @@ Eigen::Tensor generateCouplings(unsigned N, Distribution d, Generator Eigen::Tensor J = initializeJ(N, std::make_index_sequence

()); std::array is; - populateCouplings(J, N, p, is, d, r); + populateCouplings(J, N, p, is, d, r, std::make_index_sequence

()); return J; } -- cgit v1.2.3-54-g00ecf