KokkosFFT::ifft
-
template<typename ExecutionSpace, typename InViewType, typename OutViewType>
void KokkosFFT::ifft(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 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)
axis – [in] Axis over which FFT is performed (default, -1)
n – [in] Length of the transformed axis of the output (default, nullopt)
Examples
1#include <iostream>
2#include <Kokkos_Core.hpp>
3#include <Kokkos_Complex.hpp>
4#include <KokkosFFT.hpp>
5
6/// \brief Example of ifft usage in documentation
7/// x = [10, -2+2j, -2, -2-2j]
8/// x_hat = [1, 2, 3, 4]
9int main(int argc, char* argv[]) {
10 Kokkos::ScopeGuard guard(argc, argv);
11 using ExecutionSpace = Kokkos::DefaultExecutionSpace;
12 using View1D = Kokkos::View<Kokkos::complex<double>*, ExecutionSpace>;
13
14 const int n0 = 4;
15
16 View1D x("x", n0), x_hat("x_hat", n0);
17 auto h_x = Kokkos::create_mirror_view(x);
18 h_x(0) = Kokkos::complex<double>(10, 0);
19 h_x(1) = Kokkos::complex<double>(-2, 2);
20 h_x(2) = Kokkos::complex<double>(-2, 0);
21 h_x(3) = Kokkos::complex<double>(-2, -2);
22 Kokkos::deep_copy(x, h_x);
23
24 ExecutionSpace exec;
25 KokkosFFT::ifft(exec, x, x_hat);
26
27 auto h_x_hat =
28 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x_hat);
29 for (int i = 0; i < n0; ++i) {
30 std::cout << " " << h_x_hat(i);
31 }
32 std::cout << std::endl;
33
34 return 0;
35}
Expected output:
(1,0) (2,0) (3,0) (4,0)