KokkosFFT::ifftn
-
template<typename ExecutionSpace, typename InViewType, typename OutViewType, std::size_t DIM>
void KokkosFFT::ifftn(const ExecutionSpace &exec_space, const InViewType &in, const OutViewType &out, axis_type<DIM> axes = KokkosFFT::Impl::index_sequence<int, DIM, -static_cast<int>(DIM)>(), KokkosFFT::Normalization norm = KokkosFFT::Normalization::backward, shape_type<DIM> s = {}) Inverse of fftn.
- Template Parameters:
ExecutionSpace – The type of Kokkos execution space
InViewType – Input View type for the fft
OutViewType – Output View type for the fft
DIM – The dimensionality of the fft
- Parameters:
exec_space – [in] Kokkos execution space
in – [in] Input data (complex)
out – [out] Output data (complex)
axes – [in] Axes over which FFT is performed (default, all axes)
norm – [in] How the normalization is applied (default, backward)
s – [in] Shape of the transformed axis of the output (default, {})
Examples
In this example, we use the 3D View with LayoutRight to avoid the internal transpose. This allows ifftn to perform 3D FFT on the outermost dimension without transpose.
1#include <iostream>
2#include <Kokkos_Core.hpp>
3#include <Kokkos_Complex.hpp>
4#include <KokkosFFT.hpp>
5
6/// \brief Example of ifftn usage in documentation
7/// x = [[[78, -6],
8/// [-12, 0]],
9/// [[-24+13.85640646j, 0],
10/// [0, 0]],
11/// [[-24-13.85640646j, 0],
12/// [0, 0]]]
13/// x_hat = [[[1, 2],
14/// [3, 4]],
15/// [[5, 6],
16/// [7, 8]],
17/// [[9, 10],
18/// [11, 12]]]
19int main(int argc, char* argv[]) {
20 Kokkos::ScopeGuard guard(argc, argv);
21 using ExecutionSpace = Kokkos::DefaultExecutionSpace;
22 using View3D = Kokkos::View<Kokkos::complex<double>***, Kokkos::LayoutRight,
23 ExecutionSpace>;
24
25 const int n0 = 3, n1 = 2, n2 = 2;
26
27 View3D x("x", n0, n1, n2), x_hat("x_hat", n0, n1, n2);
28 auto h_x = Kokkos::create_mirror_view(x);
29 h_x(0, 0, 0) = Kokkos::complex<double>(78, 0);
30 h_x(0, 0, 1) = Kokkos::complex<double>(-6, 0);
31 h_x(0, 1, 0) = Kokkos::complex<double>(-12, 0);
32 h_x(1, 0, 0) = Kokkos::complex<double>(-24, 13.85640646);
33 h_x(2, 0, 0) = Kokkos::complex<double>(-24, -13.85640646);
34 Kokkos::deep_copy(x, h_x);
35
36 ExecutionSpace exec;
37 KokkosFFT::ifftn(exec, x, x_hat);
38
39 auto h_x_hat =
40 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x_hat);
41 for (int i = 0; i < n0; ++i) {
42 for (int j = 0; j < n1; ++j) {
43 for (int k = 0; k < n2; ++k) {
44 std::cout << " " << h_x_hat(i, j, k);
45 }
46 std::cout << "\n";
47 }
48 if (i < n0 - 1) std::cout << "\n";
49 }
50 std::cout << std::endl;
51
52 return 0;
53}
Expected output:
(1,0) (2,0)
(3,0) (4,0)
(5,0) (6,0)
(7,0) (8,0)
(9,0) (10,0)
(11,0) (12,0)