KokkosFFT::rfftfreq
-
template<typename ExecutionSpace, typename RealType>
auto KokkosFFT::rfftfreq(const ExecutionSpace&, const std::size_t n, const RealType d = 1.0) Return the DFT sample frequencies for Real FFTs.
- Template Parameters:
ExecutionSpace – The type of Kokkos execution space
RealType – The floating point precision type to represent frequencies
- Parameters:
exec_space – [in] Kokkos execution space
n – [in] Window length
d – [in] Sample spacing (default, 1)
- Returns:
Sampling frequency starting from zero
Examples
1#include <iostream>
2#include <Kokkos_Core.hpp>
3#include <Kokkos_Complex.hpp>
4#include <KokkosFFT.hpp>
5
6/// \brief Example of rfftfreq usage in documentation
7/// For n = 9, the output is
8/// freq = [0 0.111111 0.222222 0.333333 0.444444]
9int main(int argc, char* argv[]) {
10 Kokkos::ScopeGuard guard(argc, argv);
11 using ExecutionSpace = Kokkos::DefaultExecutionSpace;
12
13 const int n0 = 9;
14 ExecutionSpace exec;
15 auto freq = KokkosFFT::rfftfreq<ExecutionSpace, double>(exec, n0);
16
17 auto h_freq = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, freq);
18 for (int i = 0; i < freq.extent_int(0); ++i) {
19 std::cout << " " << h_freq(i);
20 }
21 std::cout << std::endl;
22
23 return 0;
24}
Expected output:
0 0.111111 0.222222 0.333333 0.444444