Skip to content

Commit 159101d

Browse files
committed
skeletoning out remaining fft work
1 parent 5f82084 commit 159101d

File tree

8 files changed

+500
-12
lines changed

8 files changed

+500
-12
lines changed

docs/markdown/ReleaseNotes.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
## Version 2.15.0
44

5-
* added `fft::fft` for **Issue #137** <https://numpy.org/doc/stable/reference/generated/numpy.fft.fft.html#numpy.fft.fft>
6-
* added `fft::fft2` for **Issue #137** <https://numpy.org/doc/stable/reference/generated/numpy.fft.fft2.html#numpy.fft.fft2>
7-
* added `fft::ifft` for **Issue #137** <https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft.html#numpy.fft.ifft>
8-
* added `fft::ifft2` for **Issue #137** <https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft2.html#numpy.fft.ifft2>
9-
* added `fft::rfft` for **Issue #137** <https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft.html#numpy.fft.rfft>
10-
* added `fft::rfft2` for **Issue #137** <https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft2.html#numpy.fft.rfft2>
11-
* added `fft::irfft` for **Issue #137** <https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft.html#numpy.fft.irfft>
12-
* added `fft::irfft2` for **Issue #137** <https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft2.html#numpy.fft.irfft2>
13-
* added `fft::fft_resample`: Resample a series to m points via Fourier interpolation
14-
* added `fft::fft2_resample`: Resample a series to m x n points via Fourier interpolation
15-
* added `fft::rfft_resample`: Resample a series to m points via Fourier interpolation
16-
* added `fft::rfft2_resample`: Resample a series to m x n points via Fourier interpolation
5+
* added `fft` module for **Issue #137**
6+
* `fft::fft` <https://numpy.org/doc/stable/reference/generated/numpy.fft.fft.html#numpy.fft.fft>
7+
* `fft::fft2` <https://numpy.org/doc/stable/reference/generated/numpy.fft.fft2.html#numpy.fft.fft2>
8+
* `fft::ifft` <https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft.html#numpy.fft.ifft>
9+
* `fft::ifft2` <https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft2.html#numpy.fft.ifft2>
10+
* `fft::rfft` <https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft.html#numpy.fft.rfft>
11+
* `fft::rfft2` <https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft2.html#numpy.fft.rfft2>
12+
* `fft::irfft` <https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft.html#numpy.fft.irfft>
13+
* `fft::irfft2` <https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft2.html#numpy.fft.irfft2>
14+
* `fft::fft_resample`: Resample a series to m points via Fourier interpolation
15+
* `fft::fft2_resample`: Resample a series to m x n points via Fourier interpolation
16+
* `fft::rfft_resample`: Resample a series to m points via Fourier interpolation
17+
* `fft::rfft2_resample`: Resample a series to m x n points via Fourier interpolation
1718
* added `divmod` <https://numpy.org/doc/stable/reference/generated/numpy.divmod.html#numpy-divmod>
1819
* added `find_duplicates` <https://numpy.org/doc/stable//reference/generated/numpy.rec.find_duplicate.html>
1920
* added `mode` <https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.mode.html>

include/NumCpp/FFT.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929

3030
#include "NumCpp/FFT/fft.hpp"
3131
#include "NumCpp/FFT/fft2.hpp"
32+
#include "NumCpp/FFT/fft2_resample.hpp"
33+
#include "NumCpp/FFT/fft_resample.hpp"
3234
#include "NumCpp/FFT/ifft.hpp"
3335
#include "NumCpp/FFT/ifft2.hpp"
3436
#include "NumCpp/FFT/irfft.hpp"
3537
#include "NumCpp/FFT/rfft.hpp"
38+
#include "NumCpp/FFT/rfft2.hpp"
39+
#include "NumCpp/FFT/rfft2_resample.hpp"
40+
#include "NumCpp/FFT/rfft_resample.hpp"
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/// @file
2+
/// @author David Pilger <[email protected]>
3+
/// [GitHub Repository](https://github.com/dpilger26/NumCpp)
4+
///
5+
/// License
6+
/// Copyright 2018-2025 David Pilger
7+
///
8+
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this
9+
/// software and associated documentation files(the "Software"), to deal in the Software
10+
/// without restriction, including without limitation the rights to use, copy, modify,
11+
/// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12+
/// permit persons to whom the Software is furnished to do so, subject to the following
13+
/// conditions :
14+
///
15+
/// The above copyright notice and this permission notice shall be included in all copies
16+
/// or substantial portions of the Software.
17+
///
18+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19+
/// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20+
/// PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21+
/// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22+
/// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
/// DEALINGS IN THE SOFTWARE.
24+
///
25+
/// Description
26+
/// Functions for working with NdArrays
27+
///
28+
#pragma once
29+
30+
#include <complex>
31+
32+
#include "NumCpp/Core/Types.hpp"
33+
#include "NumCpp/FFT/fft2.hpp"
34+
#include "NumCpp/FFT/ifft2.hpp"
35+
#include "NumCpp/NdArray.hpp"
36+
37+
namespace nc::fft
38+
{
39+
//===========================================================================
40+
// Method Description:
41+
/// Resample a series to m,n points via Fourier interpolation
42+
///
43+
/// @param inArray
44+
/// @param n Length of the transformed axis of the output.
45+
/// @param inAxis (Optional, default NONE)
46+
///
47+
/// @return NdArray
48+
///
49+
template<typename dtype>
50+
NdArray<std::complex<double>> fft2_resample(const NdArray<dtype>& inArray, uint32 inN, Axis inAxis = Axis::NONE)
51+
{
52+
}
53+
54+
//===========================================================================
55+
// Method Description:
56+
/// Resample a series to m,n points via Fourier interpolation
57+
///
58+
/// @param inArray
59+
/// @param inAxis (Optional, default NONE)
60+
///
61+
/// @return NdArray
62+
///
63+
template<typename dtype>
64+
NdArray<std::complex<double>> fft2_resample(const NdArray<dtype>& inArray, Axis inAxis = Axis::NONE)
65+
{
66+
}
67+
68+
//============================================================================
69+
// Method Description:
70+
/// Resample a series to m,n points via Fourier interpolation
71+
///
72+
/// @param inArray
73+
/// @param n Length of the transformed axis of the output.
74+
/// @param inAxis (Optional, default NONE)
75+
///
76+
/// @return NdArray
77+
///
78+
template<typename dtype>
79+
NdArray<std::complex<double>>
80+
fft2_resample(const NdArray<std::complex<dtype>>& inArray, uint32 inN, Axis inAxis = Axis::NONE)
81+
{
82+
}
83+
84+
//============================================================================
85+
// Method Description:
86+
/// Resample a series to m,n points via Fourier interpolation
87+
///
88+
/// @param inArray
89+
/// @param inAxis (Optional, default NONE)
90+
///
91+
/// @return NdArray
92+
///
93+
template<typename dtype>
94+
NdArray<std::complex<double>> fft2_resample(const NdArray<std::complex<dtype>>& inArray, Axis inAxis = Axis::NONE)
95+
{
96+
}
97+
} // namespace nc::fft
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/// @file
2+
/// @author David Pilger <[email protected]>
3+
/// [GitHub Repository](https://github.com/dpilger26/NumCpp)
4+
///
5+
/// License
6+
/// Copyright 2018-2025 David Pilger
7+
///
8+
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this
9+
/// software and associated documentation files(the "Software"), to deal in the Software
10+
/// without restriction, including without limitation the rights to use, copy, modify,
11+
/// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12+
/// permit persons to whom the Software is furnished to do so, subject to the following
13+
/// conditions :
14+
///
15+
/// The above copyright notice and this permission notice shall be included in all copies
16+
/// or substantial portions of the Software.
17+
///
18+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19+
/// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20+
/// PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21+
/// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22+
/// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
/// DEALINGS IN THE SOFTWARE.
24+
///
25+
/// Description
26+
/// Functions for working with NdArrays
27+
///
28+
#pragma once
29+
30+
#include <complex>
31+
32+
#include "NumCpp/Core/Types.hpp"
33+
#include "NumCpp/FFT/fft.hpp"
34+
#include "NumCpp/FFT/ifft.hpp"
35+
#include "NumCpp/NdArray.hpp"
36+
37+
namespace nc::fft
38+
{
39+
//===========================================================================
40+
// Method Description:
41+
/// Resample a series to m points via Fourier interpolation
42+
///
43+
/// @param inArray
44+
/// @param n Length of the transformed axis of the output.
45+
/// @param inAxis (Optional, default NONE)
46+
///
47+
/// @return NdArray
48+
///
49+
template<typename dtype>
50+
NdArray<std::complex<double>> fft_resample(const NdArray<dtype>& inArray, uint32 inN, Axis inAxis = Axis::NONE)
51+
{
52+
}
53+
54+
//===========================================================================
55+
// Method Description:
56+
/// Resample a series to m points via Fourier interpolation
57+
///
58+
/// @param inArray
59+
/// @param inAxis (Optional, default NONE)
60+
///
61+
/// @return NdArray
62+
///
63+
template<typename dtype>
64+
NdArray<std::complex<double>> fft_resample(const NdArray<dtype>& inArray, Axis inAxis = Axis::NONE)
65+
{
66+
}
67+
68+
//============================================================================
69+
// Method Description:
70+
/// Resample a series to m points via Fourier interpolation
71+
///
72+
/// @param inArray
73+
/// @param n Length of the transformed axis of the output.
74+
/// @param inAxis (Optional, default NONE)
75+
///
76+
/// @return NdArray
77+
///
78+
template<typename dtype>
79+
NdArray<std::complex<double>>
80+
fft_resample(const NdArray<std::complex<dtype>>& inArray, uint32 inN, Axis inAxis = Axis::NONE)
81+
{
82+
}
83+
84+
//============================================================================
85+
// Method Description:
86+
/// Resample a series to m points via Fourier interpolation
87+
///
88+
/// @param inArray
89+
/// @param inAxis (Optional, default NONE)
90+
///
91+
/// @return NdArray
92+
///
93+
template<typename dtype>
94+
NdArray<std::complex<double>> fft_resample(const NdArray<std::complex<dtype>>& inArray, Axis inAxis = Axis::NONE)
95+
{
96+
}
97+
} // namespace nc::fft

include/NumCpp/FFT/irfft2.hpp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/// @file
2+
/// @author David Pilger <[email protected]>
3+
/// [GitHub Repository](https://github.com/dpilger26/NumCpp)
4+
///
5+
/// License
6+
/// Copyright 2018-2025 David Pilger
7+
///
8+
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this
9+
/// software and associated documentation files(the "Software"), to deal in the Software
10+
/// without restriction, including without limitation the rights to use, copy, modify,
11+
/// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12+
/// permit persons to whom the Software is furnished to do so, subject to the following
13+
/// conditions :
14+
///
15+
/// The above copyright notice and this permission notice shall be included in all copies
16+
/// or substantial portions of the Software.
17+
///
18+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19+
/// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20+
/// PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21+
/// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22+
/// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
/// DEALINGS IN THE SOFTWARE.
24+
///
25+
/// Description
26+
/// Functions for working with NdArrays
27+
///
28+
#pragma once
29+
30+
#include <complex>
31+
32+
#include "NumCpp/Core/Constants.hpp"
33+
#include "NumCpp/Core/Internal/StaticAsserts.hpp"
34+
#include "NumCpp/Core/Internal/StlAlgorithms.hpp"
35+
#include "NumCpp/Core/Types.hpp"
36+
#include "NumCpp/FFT/ifft.hpp"
37+
#include "NumCpp/Functions/complex.hpp"
38+
#include "NumCpp/Functions/real.hpp"
39+
#include "NumCpp/NdArray.hpp"
40+
41+
namespace nc::fft
42+
{
43+
//============================================================================
44+
// Method Description:
45+
/// Computes the inverse of rfft2.
46+
///
47+
/// NumPy Reference: <https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft2.html>
48+
///
49+
/// @param inArray
50+
/// @param inShape Shape (length of each transformed axis) of the output
51+
///
52+
/// @return NdArray
53+
///
54+
template<typename dtype>
55+
NdArray<double> irfft2(const NdArray<std::complex<dtype>>& inArray, const Shape& inShape)
56+
{
57+
STATIC_ASSERT_ARITHMETIC(dtype);
58+
59+
return {};
60+
}
61+
62+
//============================================================================
63+
// Method Description:
64+
/// Computes the inverse of rfft2.
65+
///
66+
/// NumPy Reference: <https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft2.html>
67+
///
68+
/// @param inArray
69+
///
70+
/// @return NdArray
71+
///
72+
template<typename dtype>
73+
NdArray<double> irfft2(const NdArray<std::complex<dtype>>& inArray)
74+
{
75+
STATIC_ASSERT_ARITHMETIC(dtype);
76+
77+
return irfft2(inArray, inArray.shape());
78+
}
79+
} // namespace nc::fft

include/NumCpp/FFT/rfft2.hpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/// @file
2+
/// @author David Pilger <[email protected]>
3+
/// [GitHub Repository](https://github.com/dpilger26/NumCpp)
4+
///
5+
/// License
6+
/// Copyright 2018-2025 David Pilger
7+
///
8+
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this
9+
/// software and associated documentation files(the "Software"), to deal in the Software
10+
/// without restriction, including without limitation the rights to use, copy, modify,
11+
/// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12+
/// permit persons to whom the Software is furnished to do so, subject to the following
13+
/// conditions :
14+
///
15+
/// The above copyright notice and this permission notice shall be included in all copies
16+
/// or substantial portions of the Software.
17+
///
18+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19+
/// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20+
/// PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21+
/// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22+
/// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
/// DEALINGS IN THE SOFTWARE.
24+
///
25+
/// Description
26+
/// Functions for working with NdArrays
27+
///
28+
#pragma once
29+
30+
#include <complex>
31+
32+
#include "NumCpp/Core/Internal/StaticAsserts.hpp"
33+
#include "NumCpp/Core/Types.hpp"
34+
#include "NumCpp/Functions/complex.hpp"
35+
#include "NumCpp/NdArray.hpp"
36+
37+
namespace nc::fft
38+
{
39+
//============================================================================
40+
// Method Description:
41+
/// Compute the 2-dimensional FFT of a real array.
42+
///
43+
/// NumPy Reference: <https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft2.html>
44+
///
45+
/// @param inArray
46+
/// @param inShape Shape (length of each transformed axis) of the output
47+
///
48+
/// @return NdArray
49+
///
50+
template<typename dtype>
51+
NdArray<double> rfft2(const NdArray<std::complex<dtype>>& inArray, const Shape& inShape)
52+
{
53+
STATIC_ASSERT_ARITHMETIC(dtype);
54+
55+
return {};
56+
}
57+
58+
//============================================================================
59+
// Method Description:
60+
/// Compute the 2-dimensional FFT of a real array.
61+
///
62+
/// NumPy Reference: <https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft2.html>
63+
///
64+
/// @param inArray
65+
///
66+
/// @return NdArray
67+
///
68+
template<typename dtype>
69+
NdArray<double> rfft2(const NdArray<std::complex<dtype>>& inArray)
70+
{
71+
STATIC_ASSERT_ARITHMETIC(dtype);
72+
73+
return fft2(inArray, inArray.shape());
74+
}
75+
} // namespace nc::fft

0 commit comments

Comments
 (0)