KokkosFFT::irfft
-
template<typename ExecutionSpace, typename InViewType, typename OutViewType>
void KokkosFFT::irfft(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 rfft.
- 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 (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 must be a 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.
Examples
1#include <iostream>
2#include <Kokkos_Core.hpp>
3#include <Kokkos_Complex.hpp>
4#include <KokkosFFT.hpp>
5
6/// \brief Example of irfft usage in documentation
7/// x_hat = [10, -2+2j, -2]
8/// x = [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<double*, ExecutionSpace>;
13 using ComplexView1D = Kokkos::View<Kokkos::complex<double>*, ExecutionSpace>;
14
15 const int n0 = 4;
16
17 ComplexView1D x_hat("x_hat", n0 / 2 + 1);
18 View1D x("x", n0);
19 auto h_x_hat = Kokkos::create_mirror_view(x_hat);
20 h_x_hat(0) = Kokkos::complex<double>(10, 0);
21 h_x_hat(1) = Kokkos::complex<double>(-2, 2);
22 h_x_hat(2) = Kokkos::complex<double>(-2, 0);
23 Kokkos::deep_copy(x_hat, h_x_hat);
24
25 ExecutionSpace exec;
26 KokkosFFT::irfft(exec, x_hat, x);
27
28 auto h_x = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, x);
29 for (int i = 0; i < n0; ++i) {
30 std::cout << " " << h_x(i);
31 }
32 std::cout << std::endl;
33
34 return 0;
35}
Expected output:
1 2 3 4