KokkosFFT::ifft2

template<typename ExecutionSpace, typename InViewType, typename OutViewType>
void KokkosFFT::ifft2(const ExecutionSpace &exec_space, const InViewType &in, const OutViewType &out, KokkosFFT::Normalization norm = KokkosFFT::Normalization::backward, axis_type<2> axes = {-2, -1}, shape_type<2> s = {})

Two dimensional FFT in backward direction.

Template Parameters:
  • ExecutionSpace – The type of Kokkos execution space

  • InViewType – Input View type for the fft

  • OutViewType – Output View type for the fft

Parameters:
  • exec_space – [in] Kokkos execution space

  • in – [in] Input data (complex)

  • out – [out] Output data (complex)

  • norm – [in] How the normalization is applied (default, backward)

  • axes – [in] Axes over which FFT is performed (default, {-2, -1})

  • s – [in] Shape of the transformed axis of the output (default, {})

Examples

In this example, we use the 2D View with LayoutRight to avoid the internal transpose. This allows ifft2 to perform 2D 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 ifft2 usage in documentation
 7/// x = [[78, -6+3.46410162j, -6-3.46410162j],
 8///      [-18+18j, 0, 0],
 9///      [-18, 0, 0],
10///      [-18-18j, 0, 0]]
11/// x_hat = [[1, 2, 3],
12///          [4, 5, 6],
13///          [7, 8, 9],
14///          [10, 11, 12]]
15int main(int argc, char* argv[]) {
16  Kokkos::ScopeGuard guard(argc, argv);
17  using ExecutionSpace = Kokkos::DefaultExecutionSpace;
18  using View2D = Kokkos::View<Kokkos::complex<double>**, Kokkos::LayoutRight,
19                              ExecutionSpace>;
20
21  const int n0 = 4, n1 = 3;
22
23  View2D x("x", n0, n1), x_hat("x_hat", n0, n1);
24  auto h_x  = Kokkos::create_mirror_view(x);
25  h_x(0, 0) = Kokkos::complex<double>(78, 0);
26  h_x(0, 1) = Kokkos::complex<double>(-6, 3.46410162);
27  h_x(0, 2) = Kokkos::complex<double>(-6, -3.46410162);
28  h_x(1, 0) = Kokkos::complex<double>(-18, 18);
29  h_x(2, 0) = Kokkos::complex<double>(-18, 0);
30  h_x(3, 0) = Kokkos::complex<double>(-18, -18);
31  Kokkos::deep_copy(x, h_x);
32
33  ExecutionSpace exec;
34  KokkosFFT::ifft2(exec, x, x_hat);
35
36  auto h_x_hat =
37      Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x_hat);
38  for (int i = 0; i < n0; ++i) {
39    for (int j = 0; j < n1; ++j) {
40      std::cout << " " << h_x_hat(i, j);
41    }
42    if (i < n0 - 1) std::cout << "\n";
43  }
44  std::cout << std::endl;
45
46  return 0;
47}

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)