KokkosFFT::fftfreq
-
template<typename ExecutionSpace, typename RealType>
auto KokkosFFT::fftfreq(const ExecutionSpace&, const std::size_t n, const RealType d = 1.0) Return the DFT sample frequencies.
- 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
Examples
1#include <iostream>
2#include <Kokkos_Core.hpp>
3#include <Kokkos_Complex.hpp>
4#include <KokkosFFT.hpp>
5
6/// \brief Example of fftfreq usage in documentation
7/// For n = 10, the output is
8/// freq = [0 0.1 0.2 0.3 0.4 -0.5 -0.4 -0.3 -0.2 -0.1]
9int main(int argc, char* argv[]) {
10 Kokkos::ScopeGuard guard(argc, argv);
11 using ExecutionSpace = Kokkos::DefaultExecutionSpace;
12
13 const int n0 = 10;
14 ExecutionSpace exec;
15 auto freq = KokkosFFT::fftfreq<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.1 0.2 0.3 0.4 -0.5 -0.4 -0.3 -0.2 -0.1