NumCpp  2.16.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
rfftfreq.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include "NumCpp/Core/Types.hpp"
31#include "NumCpp/NdArray.hpp"
32
33namespace nc::fft
34{
35 //===========================================================================
36 // Method Description:
48 inline NdArray<double> rfftfreq(uint32 inN, double inD = 1.)
49 {
50 if (inN == 0)
51 {
52 return {};
53 }
54 else if (inN == 1)
55 {
56 return { 0 };
57 }
58
59 if (inD <= 0.)
60 {
61 return {};
62 }
63
64 const auto halfN = (inN / 2) + 1;
65 const auto nTimesD = static_cast<double>(inN) * inD;
66
67 auto result = NdArray<double>(1, halfN);
68 for (auto i = 0u; i < halfN; ++i)
69 {
70 result[i] = static_cast<double>(i) / nTimesD;
71 }
72
73 return result;
74 }
75} // namespace nc::fft
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
Definition FFT/FFT.hpp:40
NdArray< double > rfftfreq(uint32 inN, double inD=1.)
Definition rfftfreq.hpp:48
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
std::uint32_t uint32
Definition Types.hpp:40