46#include <gtest/gtest.h>
61 std::vector<std::complex<double>> data(8, std::complex<double>(1.0, 0.0));
64 std::vector<std::complex<double>> fft_data = data;
72 EXPECT_EQ(data.size(), 8);
78 std::vector<double> data(n);
82 for (
size_t i = 1; i < n; ++i) {
92 EXPECT_NEAR(data[0], 1.0, 1e-10);
100 std::vector<double> data(2 * n);
105 for (
size_t i = 1; i < n; ++i) {
107 data[2 * i + 1] = 0.0;
116 for (
size_t i = 0; i < n; ++i) {
117 EXPECT_NEAR(data[2 * i], 1.0, 1e-10);
118 EXPECT_NEAR(data[2 * i + 1], 0.0, 1e-10);
127 std::vector<double> data(2 * n);
130 for (
size_t i = 0; i < n; ++i) {
132 data[2 * i + 1] = 0.0;
141 EXPECT_NEAR(data[0],
static_cast<double>(n), 1e-10);
142 EXPECT_NEAR(data[1], 0.0, 1e-10);
150 std::vector<double> original(2 * n);
151 std::vector<double> transformed(2 * n);
154 for (
size_t i = 0; i < n; ++i) {
155 original[2 * i] =
static_cast<double>(i);
156 original[2 * i + 1] = 0.0;
159 transformed = original;
171 for (
size_t i = 0; i < n; ++i) {
172 EXPECT_NEAR(transformed[2 * i], original[2 * i] *
static_cast<double>(n), 1e-6);
173 EXPECT_NEAR(transformed[2 * i + 1], 0.0, 1e-6);
182 std::vector<double> data(2 * n);
187 for (
size_t i = 1; i < n; ++i) {
189 data[2 * i + 1] = 0.0;
195 for (
size_t i = 0; i < n; ++i) {
196 EXPECT_NEAR(data[2 * i], 1.0, 1e-10);
197 EXPECT_NEAR(data[2 * i + 1], 0.0, 1e-10);
203 std::vector<double> data(2 * n);
206 for (
size_t i = 0; i < n; ++i) {
208 data[2 * i + 1] = 0.0;
214 EXPECT_NEAR(data[0],
static_cast<double>(n), 1e-10);
215 EXPECT_NEAR(data[1], 0.0, 1e-10);
void gsl_fft_complex_wavetable_free(gsl_fft_complex_wavetable *w)
Free a complex FFT wavetable.
gsl_fft_complex_workspace * gsl_fft_complex_workspace_alloc(size_t n)
Allocate a complex FFT workspace of size .
void gsl_fft_real_wavetable_free(gsl_fft_real_wavetable *w)
Free a real FFT wavetable.
gsl_fft_real_workspace * gsl_fft_real_workspace_alloc(size_t n)
Allocate a real FFT workspace of size .
void gsl_fft_complex_inverse(double *data, size_t stride, size_t n, gsl_fft_complex_wavetable *, gsl_fft_complex_workspace *)
Inverse complex FFT (GSL scaling: multiplies by ).
void gsl_fft_complex_forward(double *data, size_t stride, size_t n, gsl_fft_complex_wavetable *, gsl_fft_complex_workspace *)
Forward complex FFT.
void gsl_fft_complex_workspace_free(gsl_fft_complex_workspace *w)
Free a complex FFT workspace.
void gsl_fft_real_workspace_free(gsl_fft_real_workspace *w)
Free a real FFT workspace.
void gsl_fft_complex_radix2_inverse(double *data, size_t stride, size_t n)
Radix-2 inverse complex FFT (GSL scaling, allocates temporaries).
gsl_fft_complex_wavetable * gsl_fft_complex_wavetable_alloc(size_t n)
Allocate a complex FFT wavetable of size .
void gsl_fft_real_transform(double *data, size_t stride, size_t n, gsl_fft_real_wavetable *, gsl_fft_real_workspace *)
Forward real FFT with GSL-compatible packed output.
gsl_fft_real_wavetable * gsl_fft_real_wavetable_alloc(size_t n)
Allocate a real FFT wavetable of size .
void gsl_fft_complex_radix2_forward(double *data, size_t stride, size_t n)
Radix-2 forward complex FFT (allocates temporary wavetable/workspace).
Workspace for complex FFT routines.
GSL-compatible interface for FFT routines.
Workspace for real FFT routines.
TEST_F(FFTTest, ComplexFFT_Identity)