/* * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this code; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Copyright (C) 2022-2023 Max-Planck-Society, Philipp Arras Authors: Philipp Arras */ #include #include #include using namespace std; using shape_t = vector; #include "ducc0/bindings/array_descriptor.h" #include "ducc0/bindings/typecode.h" #include "ducc0/fft/fft.h" #include "ducc0/infra/mav.cc" #include "ducc0/infra/threading.cc" static constexpr size_t F32 = ducc0::Typecode::value; static constexpr size_t F64 = ducc0::Typecode::value; static constexpr size_t C64 = ducc0::Typecode>::value; static constexpr size_t C128 = ducc0::Typecode>::value; shape_t arraydesc2vec(const ducc0::ArrayDescriptor &arrdesc) { auto mav = ducc0::to_cmav(arrdesc); shape_t res; for (size_t i = 0; i < mav.shape(0); i++) res.push_back(mav(i)); return res; } template void fft_c2c(const ducc0::ArrayDescriptor &in, ducc0::ArrayDescriptor &out, const ducc0::ArrayDescriptor &axes, const bool forward, const double fct, const size_t nthreads) { auto in_mav = ducc0::to_cfmav>(in); auto out_mav = ducc0::to_vfmav>(out); auto axes1 = arraydesc2vec(axes); ducc0::c2c(in_mav, out_mav, axes1, forward, T(fct), nthreads); } extern "C" { void fft_c2c_(const ducc0::ArrayDescriptor &in, ducc0::ArrayDescriptor &out, const ducc0::ArrayDescriptor &axes, const bool forward, const double fct, const size_t nthreads) { if (in.dtype == C128) fft_c2c(in, out, axes, forward, fct, nthreads); else if (in.dtype == C64) fft_c2c(in, out, axes, forward, fct, nthreads); else MR_fail("Type not supported"); } }