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

Function test_random_stfts_impl

dlib/test/fft.cpp:632–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630
631 template<typename R, typename WINDOW>
632 void test_random_stfts_impl(const WINDOW& w, std::size_t fftsize, std::size_t wlen)
633 {
634 constexpr R tol = std::is_same<R,float>::value ? 1e-5 : 1e-12;
635
636 int test = 0;
637
638 for (long nsamples = 512 ; nsamples < 1024 ; ++nsamples)
639 {
640 matrix<R> samples1 = matrix_cast<R>(randm(1, nsamples));
641 matrix<complex<R>> samples2 = istft(stft(samples1, w, fftsize, wlen, wlen/2), w, wlen, wlen/2);
642
643 const long minsamples = std::min(samples1.nc(), samples2.nc());
644 DLIB_TEST(max(abs(imag(samples2))) < tol);
645 DLIB_TEST(max(abs(subm(samples1, 0, 0, 1, minsamples) - subm(real(samples2), 0, 0, 1, minsamples))) < tol);
646
647 if (test++ % 10 == 0)
648 print_spinner();
649 }
650 }
651
652 template<typename R>
653 void test_random_stfts()

Callers

nothing calls this directly

Calls 11

istftFunction · 0.85
stftFunction · 0.85
absFunction · 0.85
imagFunction · 0.85
submFunction · 0.85
realFunction · 0.85
print_spinnerFunction · 0.85
randmFunction · 0.70
minFunction · 0.50
maxFunction · 0.50
ncMethod · 0.45

Tested by

no test coverage detected