KokkosFFT::ifftshift

template<typename ExecutionSpace, typename ViewType>
void KokkosFFT::ifftshift(const ExecutionSpace &exec_space, const ViewType &inout, std::optional<int> axes = std::nullopt)

The inverse of fftshift.

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

  • ViewType – Input/Output View type for the shift

Parameters:
  • exec_space – [in] Kokkos execution space

  • inout – [in,out] Spectrum

  • axes – [in] Axes over which to shift (default: nullopt, shifting over all axes)

template<typename ExecutionSpace, typename ViewType, std::size_t DIM = 1>
void KokkosFFT::ifftshift(const ExecutionSpace &exec_space, const ViewType &inout, axis_type<DIM> axes)

The inverse of fftshift.

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

  • ViewType – Input/Output View type for the shift

  • DIM – The dimensionality of the shift

Parameters:
  • exec_space – [in] Kokkos execution space

  • inout – [in,out] Spectrum

  • axes – [in] Axes over which to shift

Examples

 1#include <iostream>
 2#include <Kokkos_Core.hpp>
 3#include <Kokkos_Complex.hpp>
 4#include <KokkosFFT.hpp>
 5
 6/// \brief Example of ifftshift usage in documentation
 7/// freqs: [-4 -3 -2 -1 0 1 2 3 4]
 8/// KokkosFFT::ifftshift(freqs);
 9/// freqs_shifted: [0 1 2 3 4 -4 -3 -2 -1]
10int main(int argc, char* argv[]) {
11  Kokkos::ScopeGuard guard(argc, argv);
12  using ExecutionSpace = Kokkos::DefaultExecutionSpace;
13  using ViewType       = Kokkos::View<double*, ExecutionSpace>;
14
15  ExecutionSpace exec;
16  ViewType freq_shifted("freq_shifted", 9);
17  auto h_freq_shifted = Kokkos::create_mirror_view(freq_shifted);
18  for (int i = 0; i < freq_shifted.extent_int(0); ++i) {
19    h_freq_shifted(i) = static_cast<double>(i - 4);
20  }
21  Kokkos::deep_copy(freq_shifted, h_freq_shifted);
22
23  KokkosFFT::ifftshift(exec, freq_shifted);
24  Kokkos::deep_copy(h_freq_shifted, freq_shifted);
25  for (int i = 0; i < h_freq_shifted.extent_int(0); ++i) {
26    std::cout << " " << h_freq_shifted(i);
27  }
28  std::cout << std::endl;
29
30  return 0;
31}

Expected output:

0 1 2 3 4 -4 -3 -2 -1