From 136fcddcd38d0b8f3b40faf7c1cb7365d9b2a753 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 15 Jan 2021 14:45:19 +0100 Subject: Converted more of library to templates accepting generic Scalar types and p --- tensor.hpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'tensor.hpp') diff --git a/tensor.hpp b/tensor.hpp index 66f6d59..21f2a89 100644 --- a/tensor.hpp +++ b/tensor.hpp @@ -5,43 +5,41 @@ #include -#include "factorial.hpp" - -template +template Eigen::Tensor initializeJHelper(unsigned N, std::index_sequence) { std::array Ns; std::fill_n(Ns.begin(), p, N); return Eigen::Tensor(std::get(Ns)...); } -template +template Eigen::Tensor initializeJ(unsigned N) { return initializeJHelper(N, std::make_index_sequence

()); } -template +template void setJHelper(Eigen::Tensor& J, const std::array& ind, Scalar val, std::index_sequence) { J(std::get(ind)...) = val; } -template +template void setJ(Eigen::Tensor& J, std::array ind, Scalar val) { do { setJHelper(J, ind, val, std::make_index_sequence

()); } while (std::next_permutation(ind.begin(), ind.end())); } -template +template Scalar getJHelper(const Eigen::Tensor& J, const std::array& ind, std::index_sequence) { return J(std::get(ind)...); } -template +template Scalar getJ(const Eigen::Tensor& J, const std::array& ind) { return getJHelper(J, ind, std::make_index_sequence

()); } -template +template void iterateOverHelper(Eigen::Tensor& J, std::function&, std::array)>& f, unsigned l, std::array is) { @@ -62,13 +60,13 @@ void iterateOverHelper(Eigen::Tensor& J, } } -template +template void iterateOver(Eigen::Tensor& J, std::function&, std::array)>& f) { std::array is; iterateOverHelper(J, f, p, is); } -template +template Eigen::Tensor generateCouplings(unsigned N, Distribution d, Generator& r) { Eigen::Tensor J = initializeJ(N); -- cgit v1.2.3-54-g00ecf