From 523cc8e44e060949103368e6f0bee6cc6a78a625 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 28 Nov 2012 22:33:42 -0500 Subject: [PATCH] Introduced another intermediate function for retrieving integer indexes --- src/fourier/details/euclidian_maps.hpp | 17 ++++++++++++----- src/fourier/details/euclidian_spectrum_1d.hpp | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/fourier/details/euclidian_maps.hpp b/src/fourier/details/euclidian_maps.hpp index 67b141b..cfadc72 100644 --- a/src/fourier/details/euclidian_maps.hpp +++ b/src/fourier/details/euclidian_maps.hpp @@ -136,14 +136,21 @@ namespace CosmoTool { const DimArray& dims = this->getDims(); DimArray d(delta_k.size()); - for (int q = 0; q < d.size(); q++) - { - d[q] = p%dims[q]; - p = (p-d[q])/dims[q]; - } + get_IKvec(p, d); get_Kvec(d, kvec); } + void get_IKvec(long p, DimArray& ikvec) + { + const DimArray& dims = this->getDims(); + assert(dims.size()==ikvec.size()); + for (int q = 0; q < ikvec.size(); q++) + { + ikvec[q] = p%dims[q]; + p = (p-ikvec[q])/dims[q]; + } + } + template double get_K(const Array& ik) diff --git a/src/fourier/details/euclidian_spectrum_1d.hpp b/src/fourier/details/euclidian_spectrum_1d.hpp index b12864b..291470d 100644 --- a/src/fourier/details/euclidian_spectrum_1d.hpp +++ b/src/fourier/details/euclidian_spectrum_1d.hpp @@ -1,6 +1,8 @@ #ifndef __DETAILS_EUCLIDIAN_SPECTRUM_1D #define __DETAILS_EUCLIDIAN_SPECTRUM_1D +#include + namespace CosmoTool {