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

Function test_random_ffts

dlib/test/fft.cpp:116–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114// ----------------------------------------------------------------------------------------
115
116 void test_random_ffts()
117 {
118 int test = 0;
119 for (int nr = 1; nr <= 64; nr++)
120 {
121 for (int nc = 1; nc <= 64; nc++)
122 {
123 if (++test % 100 == 0)
124 print_spinner();
125
126 const matrix<complex<double> > m1 = rand_complex<double>(nr,nc);
127 const matrix<complex<float> > fm1 = rand_complex<float>(nr,nc);
128
129 DLIB_TEST(max(norm(ifft(fft(m1))-m1)) < 1e-16);
130 DLIB_TEST(max(norm(ifft(fft(fm1))-fm1)) < 1e-7);
131
132 matrix<complex<double> > temp = m1;
133 matrix<complex<float> > ftemp = fm1;
134 fft_inplace(temp);
135 fft_inplace(ftemp);
136 DLIB_TEST(max(norm(temp-fft(m1))) < 1e-16);
137 DLIB_TEST(max(norm(ftemp-fft(fm1))) < 1e-7);
138 ifft_inplace(temp);
139 ifft_inplace(ftemp);
140 DLIB_TEST(max(norm(temp/temp.size()-m1)) < 1e-16);
141 DLIB_TEST(max(norm(ftemp/ftemp.size()-fm1)) < 1e-7);
142 }
143 }
144
145 {
146 // test size 0 matrices.
147 matrix<complex<double>> temp;
148 matrix<complex<float>> ftemp;
149 fft_inplace(temp);
150 fft_inplace(ftemp);
151 DLIB_TEST(temp.size() == 0);
152 DLIB_TEST(ftemp.size() == 0);
153
154 DLIB_TEST(fft(temp).size() == 0);
155 DLIB_TEST(ifft(temp).size() == 0);
156
157 matrix<double> rtemp;
158 DLIB_TEST(fftr(rtemp).size() == 0);
159 DLIB_TEST(ifftr(temp).size() == 0);
160 }
161 }
162
163// ----------------------------------------------------------------------------------------
164

Callers 1

perform_testMethod · 0.85

Calls 10

print_spinnerFunction · 0.85
normFunction · 0.85
ifftFunction · 0.85
maxFunction · 0.50
fftFunction · 0.50
fft_inplaceFunction · 0.50
ifft_inplaceFunction · 0.50
fftrFunction · 0.50
ifftrFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected