Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
duccfft_impl.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// This Source Code Form is subject to the terms of the Mozilla
5// Public License v. 2.0. If a copy of the MPL was not distributed
6// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7// SPDX-FileCopyrightText: The Eigen Authors
8// SPDX-License-Identifier: MPL-2.0
9
10#ifndef EIGEN_FFT_DUCCFFT_IMPL_H
11#define EIGEN_FFT_DUCCFFT_IMPL_H
12
13namespace Eigen {
14
15namespace internal {
16
17template <typename _Scalar>
18struct duccfft_impl {
19 using Scalar = _Scalar;
20 using Complex = std::complex<Scalar>;
21 using shape_t = ducc0::fmav_info::shape_t;
22 using stride_t = ducc0::fmav_info::stride_t;
23
24 inline void clear() {}
25
26 inline void fwd(Complex* dst, const Scalar* src, int nfft) {
27 const shape_t axes{0};
28 ducc0::cfmav<Scalar> m_in(src, shape_t{static_cast<size_t>(nfft)});
29 ducc0::vfmav<Complex> m_out(dst, shape_t{static_cast<size_t>(nfft) / 2 + 1});
30 ducc0::r2c(m_in, m_out, axes, /*forward=*/true, /*scale=*/static_cast<Scalar>(1));
31 }
32
33 inline void fwd(Complex* dst, const Complex* src, int nfft) {
34 const shape_t axes{0};
35 ducc0::cfmav<Complex> m_in(src, shape_t{static_cast<size_t>(nfft)});
36 ducc0::vfmav<Complex> m_out(dst, shape_t{static_cast<size_t>(nfft)});
37 ducc0::c2c(m_in, m_out, axes, /*forward=*/true, /*scale=*/static_cast<Scalar>(1));
38 }
39
40 inline void inv(Scalar* dst, const Complex* src, int nfft) {
41 const shape_t axes{0};
42 ducc0::cfmav<Complex> m_in(src, shape_t{static_cast<size_t>(nfft) / 2 + 1});
43 ducc0::vfmav<Scalar> m_out(dst, shape_t{static_cast<size_t>(nfft)});
44 ducc0::c2r(m_in, m_out, axes, /*forward=*/false, /*scale=*/static_cast<Scalar>(1));
45 }
46
47 inline void inv(Complex* dst, const Complex* src, int nfft) {
48 const shape_t axes{0};
49 ducc0::cfmav<Complex> m_in(src, shape_t{static_cast<size_t>(nfft)});
50 ducc0::vfmav<Complex> m_out(dst, shape_t{static_cast<size_t>(nfft)});
51 ducc0::c2c(m_in, m_out, axes, /*forward=*/false, /*scale=*/static_cast<Scalar>(1));
52 }
53
54 inline void fwd2(Complex* dst, const Complex* src, int nfft0, int nfft1) {
55 const shape_t axes{0, 1};
56 const shape_t in_shape{static_cast<size_t>(nfft0), static_cast<size_t>(nfft1)};
57 const shape_t out_shape{static_cast<size_t>(nfft0), static_cast<size_t>(nfft1)};
58 const stride_t stride{static_cast<ptrdiff_t>(nfft1), static_cast<ptrdiff_t>(1)};
59 ducc0::cfmav<Complex> m_in(src, in_shape, stride);
60 ducc0::vfmav<Complex> m_out(dst, out_shape, stride);
61 ducc0::c2c(m_in, m_out, axes, /*forward=*/true, /*scale=*/static_cast<Scalar>(1));
62 }
63
64 inline void inv2(Complex* dst, const Complex* src, int nfft0, int nfft1) {
65 const shape_t axes{0, 1};
66 const shape_t in_shape{static_cast<size_t>(nfft0), static_cast<size_t>(nfft1)};
67 const shape_t out_shape{static_cast<size_t>(nfft0), static_cast<size_t>(nfft1)};
68 const stride_t stride{static_cast<ptrdiff_t>(nfft1), static_cast<ptrdiff_t>(1)};
69 ducc0::cfmav<Complex> m_in(src, in_shape, stride);
70 ducc0::vfmav<Complex> m_out(dst, out_shape, stride);
71 ducc0::c2c(m_in, m_out, axes, /*forward=*/false, /*scale=*/static_cast<Scalar>(1));
72 }
73};
74
75} // namespace internal
76} // namespace Eigen
77
78#endif // EIGEN_FFT_DUCCFFT_IMPL_H
Namespace containing all symbols from the Eigen library.