MCPcopy Create free account
hub / github.com/davisking/dlib / test_random_real_ffts

Function test_random_real_ffts

dlib/test/fft.cpp:187–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185 }
186
187 void test_random_real_ffts()
188 {
189 int test = 0;
190 for (int nr = 1; nr <= 64; nr++)
191 {
192 for (int nc = 1; nc <= 64; nc++)
193 {
194 if (++test % 100 == 0)
195 print_spinner();
196
197 const matrix<complex<double> > m1 = complex_matrix(rand_real<double>(nr,nc));
198 const matrix<complex<float> > fm1 = complex_matrix(rand_real<float>(nr,nc));
199
200 DLIB_TEST(max(norm(ifft(fft(complex_matrix(real(m1))))-m1)) < 1e-16);
201 DLIB_TEST(max(norm(ifft(fft(complex_matrix(real(fm1))))-fm1)) < 1e-7);
202
203 matrix<complex<double> > temp = m1;
204 matrix<complex<float> > ftemp = fm1;
205 fft_inplace(temp);
206 fft_inplace(ftemp);
207 DLIB_TEST(max(norm(temp-fft(m1))) < 1e-16);
208 DLIB_TEST(max(norm(ftemp-fft(fm1))) < 1e-7);
209 ifft_inplace(temp);
210 ifft_inplace(ftemp);
211 DLIB_TEST(max(norm(temp/temp.size()-m1)) < 1e-16);
212 DLIB_TEST(max(norm(ftemp/ftemp.size()-fm1)) < 1e-7);
213 }
214 }
215
216 test_real_compile_time_sized_ffts<16,16>();
217 test_real_compile_time_sized_ffts<16,1>();
218 test_real_compile_time_sized_ffts<1,16>();
219 test_real_compile_time_sized_ffts<480,480>(); //2^5 * 3 * 5
220 test_real_compile_time_sized_ffts<480,1>(); //2^5 * 3 * 5
221 test_real_compile_time_sized_ffts<1,480>(); //2^5 * 3 * 5
222 test_real_compile_time_sized_ffts<131,131>(); //some large prime
223 test_real_compile_time_sized_ffts<131,1>(); //some large prime
224 test_real_compile_time_sized_ffts<1,131>(); //some large prime
225 }
226
227// ----------------------------------------------------------------------------------------
228

Callers 1

perform_testMethod · 0.85

Calls 10

print_spinnerFunction · 0.85
complex_matrixFunction · 0.85
normFunction · 0.85
ifftFunction · 0.85
realFunction · 0.85
maxFunction · 0.50
fftFunction · 0.50
fft_inplaceFunction · 0.50
ifft_inplaceFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected