diff --git a/src/include/tfrfme.h b/src/include/tfrfme.h index be6ac56252d6f7b63241af2b8a60119fe0b00cbf..ded5377a19f0a4879e57e3733601648b4db12913 100644 --- a/src/include/tfrfme.h +++ b/src/include/tfrfme.h @@ -63,6 +63,9 @@ protected: void write_legacy(const std::string& file_name); public: + //! \brief Read only view on WK. + const dcomplex *vec_wk; + /*! \brief Swap1 instance constructor. * * \param lm: `int` Maximum field expansion order. @@ -97,12 +100,6 @@ public: */ static long get_memory_requirement(int lm, int _nkv); - /*! \brief Get the pointer to the WK vector. - * - * \return value: `complex double *` Memory address of the WK vector. - */ - dcomplex *get_vector() { return wk; } - /*! \brief Bring the pointer to the next element at the start of vector. */ void reset() { last_index = 0; } diff --git a/src/libnptm/tfrfme.cpp b/src/libnptm/tfrfme.cpp index df999983f83f4b1e855fa23b9990c2500998cf33..37b872e209365c6cf71efbab931f6a26ca1ac8db 100644 --- a/src/libnptm/tfrfme.cpp +++ b/src/libnptm/tfrfme.cpp @@ -52,6 +52,7 @@ Swap1::Swap1(int lm, int _nkv) { nlmmt = 2 * lm * (lm + 2); const int size = nkv * nkv * nlmmt; wk = new dcomplex[size](); + vec_wk = wk; last_index = 0; } @@ -77,21 +78,19 @@ Swap1* Swap1::from_hdf5(const std::string& file_name) { string str_type; int _nlmmt, _nkv, lm, num_elements, index; dcomplex value; - dcomplex *_wk = NULL; if (status == 0) { status = hdf_file->read("NLMMT", "INT32", &_nlmmt); status = hdf_file->read("NKV", "INT32", &_nkv); lm = (int)((-2.0 + sqrt(4.0 + 2.0 * _nlmmt)) / 2.0); num_elements = 2 * _nlmmt * _nkv * _nkv; instance = new Swap1(lm, _nkv); - _wk = instance->get_vector(); elements = new double[num_elements](); str_type = "FLOAT64_(" + to_string(num_elements) + ")"; status = hdf_file->read("WK", str_type, elements); for (int wi = 0; wi < num_elements / 2; wi++) { index = 2 * wi; value = elements[index] + elements[index + 1] * I; - _wk[wi] = value; + instance->wk[wi] = value; } // wi loop delete[] elements; status = hdf_file->close(); @@ -103,7 +102,6 @@ Swap1* Swap1::from_hdf5(const std::string& file_name) { Swap1* Swap1::from_legacy(const std::string& file_name) { fstream input; Swap1 *instance = NULL; - dcomplex *_wk = NULL; int _nlmmt, _nkv, lm; double rval, ival; input.open(file_name.c_str(), ios::in | ios::binary); @@ -112,12 +110,11 @@ Swap1* Swap1::from_legacy(const std::string& file_name) { lm = (int)((-2.0 + sqrt(4.0 + 2.0 * _nlmmt)) / 2.0); input.read(reinterpret_cast<char *>(&_nkv), sizeof(int)); instance = new Swap1(lm, _nkv); - _wk = instance->get_vector(); int num_elements = _nlmmt * _nkv * _nkv; for (int j = 0; j < num_elements; j++) { input.read(reinterpret_cast<char *>(&rval), sizeof(double)); input.read(reinterpret_cast<char *>(&ival), sizeof(double)); - _wk[j] = rval + ival * I; + instance->wk[j] = rval + ival * I; } input.close(); } else { diff --git a/src/libnptm/tra_subs.cpp b/src/libnptm/tra_subs.cpp index 8d04f4479c86d72407a7f3b836864425e3d0abdd..59496de9b3d642b013c36d394db50e5989ce9017 100644 --- a/src/libnptm/tra_subs.cpp +++ b/src/libnptm/tra_subs.cpp @@ -269,9 +269,9 @@ void ffrt(dcomplex *ac, dcomplex *ws, double *ffte, double *ffts, CIL *cil) { } dcomplex *frfmer( - int nkv, double vkm, double vknmx, double apfafa, double tra, - double spd, double rir, double ftcn, int le, int lmode, double pmf, - Swap1 *tt1, Swap2 *tt2 + int nkv, double vkm, double vknmx, double apfafa, double tra, + double spd, double rir, double ftcn, int le, int lmode, double pmf, + Swap1 *tt1, Swap2 *tt2 ) { const int nlemt = le * (le + 2) * 2; const dcomplex cc0 = 0.0 + 0.0 * I;