File tree Expand file tree Collapse file tree 10 files changed +65
-434
lines changed
Expand file tree Collapse file tree 10 files changed +65
-434
lines changed Original file line number Diff line number Diff line change 88 * ` fft::fftfreq ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.fftfreq.html >
99 * ` fft::fftshift ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.fftshfit.html >
1010 * ` fft::ifftshift ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.ifftshfit.html >
11- * ` fft::fftresample ` : Resample a series to m points via Fourier interpolation
1211 * ` fft::fft2 ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.fft2.html#numpy.fft.fft2 >
1312 * ` fft::ifft2 ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft2.html#numpy.fft.ifft2 >
14- * ` fft::fft2resample ` : Resample a series to m x n points via Fourier interpolation
1513 * ` fft::rfft ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft.html#numpy.fft.rfft >
1614 * ` fft::irfft ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft.html#numpy.fft.irfft >
1715 * ` fft::rfftfreq ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.rfftfreq.html >
18- * ` fft::rfftresample ` : Resample a series to m points via Fourier interpolation
1916 * ` fft::rfft2 ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft2.html#numpy.fft.rfft2 >
2017 * ` fft::irfft2 ` < https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft2.html#numpy.fft.irfft2 >
21- * ` fft::rfft2resample ` : Resample a series to m x n points via Fourier interpolation
2218* added ` divmod ` < https://numpy.org/doc/stable/reference/generated/numpy.divmod.html#numpy-divmod >
2319* added ` find_duplicates ` < https://numpy.org/doc/stable//reference/generated/numpy.rec.find_duplicate.html >
2420* added ` mode ` < https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.mode.html >
Original file line number Diff line number Diff line change 2929
3030#include " NumCpp/FFT/fft.hpp"
3131#include " NumCpp/FFT/fft2.hpp"
32- #include " NumCpp/FFT/fft2resample.hpp"
3332#include " NumCpp/FFT/fftfreq.hpp"
34- #include " NumCpp/FFT/fftresample.hpp"
3533#include " NumCpp/FFT/fftshift.hpp"
3634#include " NumCpp/FFT/ifft.hpp"
3735#include " NumCpp/FFT/ifft2.hpp"
3836#include " NumCpp/FFT/ifftshift.hpp"
3937#include " NumCpp/FFT/irfft.hpp"
38+ #include " NumCpp/FFT/irfft2.hpp"
4039#include " NumCpp/FFT/rfft.hpp"
4140#include " NumCpp/FFT/rfft2.hpp"
42- #include " NumCpp/FFT/rfft2resample.hpp"
4341#include " NumCpp/FFT/rfftfreq.hpp"
44- #include " NumCpp/FFT/rfftresample.hpp"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -41,12 +41,42 @@ namespace nc::fft
4141 // / NumPy Reference: <https://numpy.org/doc/stable/reference/generated/numpy.fft.fftfreq.html#>
4242 // /
4343 // / @param inN Window Length
44- // / @param inD (Optional) Sample spacing (inverse of the sampling rate). Defaults to 1.
44+ // / @param inD (Optional) Sample spacing (inverse of the sampling rate). Must be positive non-zero. Defaults to 1.
4545 // /
4646 // / @return NdArray
4747 // /
4848 inline NdArray<double > fftfreq (uint32 inN, double inD = 1 .)
4949 {
50- return {};
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 nTimesD = static_cast <double >(inN) * inD;
65+
66+ auto result = NdArray<double >(1 , inN);
67+ result[0 ] = 0 .;
68+
69+ for (auto i = 1u ; i < (inN + 1 ) / 2 ; ++i)
70+ {
71+ result[i] = static_cast <double >(i) / nTimesD;
72+ result[inN - i] = -static_cast <double >(i) / nTimesD;
73+ }
74+
75+ if (inN % 2 == 0 )
76+ {
77+ result[inN / 2 ] = -static_cast <double >(inN / 2 ) / nTimesD;
78+ }
79+
80+ return result;
5181 }
5282} // namespace nc::fft
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -47,6 +47,29 @@ namespace nc::fft
4747 // /
4848 inline NdArray<double > rfftfreq (uint32 inN, double inD = 1 .)
4949 {
50- return {};
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;
5174 }
5275} // namespace nc::fft
You can’t perform that action at this time.
0 commit comments