KokkosFFT::hfft

template<typename ExecutionSpace, typename InViewType, typename OutViewType>
void KokkosFFT::hfft(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)

One dimensional FFT of a signal that has Hermitian symmetry.

The input data is modified in-place to save memory (if the input is non-const complex). If the input is real or const complex, we create a temporary complex view to perform the computation, and the input data is not modified.

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[inout] Input data (real or complex)

  • out[out] Output data (real)

  • 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 can be either a real-valued or complex-valued view, and the output must be a real-valued view. The input length along the transform axis is n/2 + 1, where n is the output length along that axis. If this condition is not met, the std::runtime_error exception will be thrown. For the real input, we internally convert it to complex and perform hfft on it.

Examples

 1#include <iostream>
 2#include <Kokkos_Core.hpp>
 3#include <Kokkos_Complex.hpp>
 4#include <KokkosFFT.hpp>
 5
 6/// \brief Example of hfft usage in documentation
 7/// x = [1, 2, 3, 4]
 8/// x_hat = [15.0, -4.0, 0.0, -1.0, 0.0, -4.0]
 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
14  const int n0 = 6;
15
16  View1D x("x", n0 / 2 + 1), x_hat("x_hat", n0);
17  auto h_x = Kokkos::create_mirror_view(x);
18  for (int i = 0; i < x.extent_int(0); ++i) {
19    h_x(i) = i + 1;
20  }
21  Kokkos::deep_copy(x, h_x);
22
23  ExecutionSpace exec;
24  KokkosFFT::hfft(exec, x, x_hat);
25
26  auto h_x_hat =
27      Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x_hat);
28  for (int i = 0; i < x_hat.extent_int(0); ++i) {
29    std::cout << " " << h_x_hat(i);
30  }
31  std::cout << std::endl;
32
33  return 0;
34}

Expected output:

15 -4 0 -1 0 -4