KokkosFFT::ihfft

template<typename ExecutionSpace, typename InViewType, typename OutViewType>
void KokkosFFT::ihfft(const ExecutionSpace &exec_space, const InViewType &in, const OutViewType &out, KokkosFFT::Normalization norm = KokkosFFT::Normalization::backward, int axis = -1, std::optional<std::size_t> n = std::nullopt)

Inverse of hfft.

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 (real)

  • out – [out] Output data (complex)

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

  • axis – [in] Axis over which FFT is performed (default, -1)

  • n – [in] Length of the transformed axis of the output (default, nullopt)

Note

The input must be a real-valued view, and the output must be a complex-valued view. The output length along the transform axis is n/2 + 1, where n is the input length along that axis. If this condition is not met, the std::runtime_error exception will be thrown.

Examples

 1#include <iostream>
 2#include <Kokkos_Core.hpp>
 3#include <Kokkos_Complex.hpp>
 4#include <KokkosFFT.hpp>
 5
 6/// \brief Example of ihfft usage in documentation
 7/// x_hat = [15.0, -4.0, 0.0, -1.0, 0.0, -4.0]
 8/// x = [1.-0.j, 2.-0.j, 3.-0.j, 4.-0.j]
 9int main(int argc, char* argv[]) {
10  Kokkos::ScopeGuard guard(argc, argv);
11  using ExecutionSpace = Kokkos::DefaultExecutionSpace;
12  using View1D         = Kokkos::View<double*, ExecutionSpace>;
13  using ComplexView1D  = Kokkos::View<Kokkos::complex<double>*, ExecutionSpace>;
14
15  const int n0 = 6;
16
17  View1D x_hat("x_hat", n0);
18  ComplexView1D x("x", n0 / 2 + 1);
19  auto h_x_hat = Kokkos::create_mirror_view(x_hat);
20  h_x_hat(0)   = 15.0;
21  h_x_hat(1)   = -4.0;
22  h_x_hat(2)   = 0.0;
23  h_x_hat(3)   = -1.0;
24  h_x_hat(4)   = 0.0;
25  h_x_hat(5)   = -4.0;
26  Kokkos::deep_copy(x_hat, h_x_hat);
27
28  ExecutionSpace exec;
29  KokkosFFT::ihfft(exec, x_hat, x);
30
31  auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x);
32  for (int i = 0; i < x.extent_int(0); ++i) {
33    std::cout << " " << h_x(i);
34  }
35  std::cout << std::endl;
36
37  return 0;
38}

Expected output:

(1,0) (2,0) (3,0) (4,0)