Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
pocketfft_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_POCKETFFT_IMPL_H
11#define EIGEN_FFT_POCKETFFT_IMPL_H
12
13namespace Eigen {
14
15namespace internal {
16
17template <typename _Scalar>
18struct pocketfft_impl {
19 using Scalar = _Scalar;
20 using Complex = std::complex<Scalar>;
21 using shape_t = pocketfft::shape_t;
22 using stride_t = pocketfft::stride_t;
23
24 inline void clear() {}
25
26 inline void fwd(Complex* dst, const Scalar* src, int nfft) {
27 const shape_t shape_{static_cast<size_t>(nfft)};
28 const shape_t axes_{0};
29 const stride_t stride_in{sizeof(Scalar)};
30 const stride_t stride_out{sizeof(Complex)};
31 pocketfft::r2c(shape_, stride_in, stride_out, axes_, pocketfft::FORWARD, src, dst, static_cast<Scalar>(1));
32 }
33
34 inline void fwd(Complex* dst, const Complex* src, int nfft) {
35 const shape_t shape_{static_cast<size_t>(nfft)};
36 const shape_t axes_{0};
37 const stride_t stride_{sizeof(Complex)};
38 pocketfft::c2c(shape_, stride_, stride_, axes_, pocketfft::FORWARD, src, dst, static_cast<Scalar>(1));
39 }
40
41 inline void inv(Scalar* dst, const Complex* src, int nfft) {
42 const shape_t shape_{static_cast<size_t>(nfft)};
43 const shape_t axes_{0};
44 const stride_t stride_in{sizeof(Complex)};
45 const stride_t stride_out{sizeof(Scalar)};
46 pocketfft::c2r(shape_, stride_in, stride_out, axes_, pocketfft::BACKWARD, src, dst, static_cast<Scalar>(1));
47 }
48
49 inline void inv(Complex* dst, const Complex* src, int nfft) {
50 const shape_t shape_{static_cast<size_t>(nfft)};
51 const shape_t axes_{0};
52 const stride_t stride_{sizeof(Complex)};
53 pocketfft::c2c(shape_, stride_, stride_, axes_, pocketfft::BACKWARD, src, dst, static_cast<Scalar>(1));
54 }
55
56 inline void fwd2(Complex* dst, const Complex* src, int nfft0, int nfft1) {
57 const shape_t shape_{static_cast<size_t>(nfft0), static_cast<size_t>(nfft1)};
58 const shape_t axes_{0, 1};
59 const stride_t stride_{static_cast<ptrdiff_t>(sizeof(Complex) * nfft1), static_cast<ptrdiff_t>(sizeof(Complex))};
60 pocketfft::c2c(shape_, stride_, stride_, axes_, pocketfft::FORWARD, src, dst, static_cast<Scalar>(1));
61 }
62
63 inline void inv2(Complex* dst, const Complex* src, int nfft0, int nfft1) {
64 const shape_t shape_{static_cast<size_t>(nfft0), static_cast<size_t>(nfft1)};
65 const shape_t axes_{0, 1};
66 const stride_t stride_{static_cast<ptrdiff_t>(sizeof(Complex) * nfft1), static_cast<ptrdiff_t>(sizeof(Complex))};
67 pocketfft::c2c(shape_, stride_, stride_, axes_, pocketfft::BACKWARD, src, dst, static_cast<Scalar>(1));
68 }
69};
70
71} // namespace internal
72} // namespace Eigen
73
74#endif // EIGEN_FFT_POCKETFFT_IMPL_H
Namespace containing all symbols from the Eigen library.