| 484 | |
| 485 | template<typename R> |
| 486 | void test_vector_overload_outplace() |
| 487 | { |
| 488 | static constexpr double tol = std::is_same<R,double>::value ? 1e-15 : 5e-2; |
| 489 | static constexpr const char* typelabel = std::is_same<R,double>::value ? "double" : "float"; |
| 490 | |
| 491 | int test = 0; |
| 492 | |
| 493 | auto func = [&](long size) |
| 494 | { |
| 495 | if (++test % 100 == 0) |
| 496 | print_spinner(); |
| 497 | |
| 498 | const matrix<complex<R>,0,1> m1 = rand_complex<R>(size,1); |
| 499 | const matrix<complex<R>,0,1> f1 = fft(m1); //this fft uses the dlib::matrix overload |
| 500 | |
| 501 | const std::vector<complex<R>> m1_v(m1.begin(), m1.end()); //target |
| 502 | const std::vector<complex<R>> f1_v(f1.begin(), f1.end()); //target |
| 503 | |
| 504 | const matrix<complex<R>,0,1> f2 = fft(m1_v); //this fft uses the std::vector overload |
| 505 | const matrix<complex<R>,0,1> m2 = ifft(f1_v); //this ifft uses the std::vector overload |
| 506 | |
| 507 | R diff = max(norm(f2 - f1)); |
| 508 | DLIB_TEST_MSG(diff < tol, "diff " << diff << " not within tol " << tol << " where (size) = (" << size << ")" << " type " << typelabel); |
| 509 | |
| 510 | diff = max(norm(m2 - m1)); |
| 511 | DLIB_TEST_MSG(diff < tol, "diff " << diff << " not within tol " << tol << " where (size) = (" << size << ")" << " type " << typelabel); |
| 512 | }; |
| 513 | |
| 514 | for (long size = 1; size <= 64; size++) |
| 515 | func(size); |
| 516 | |
| 517 | //some odd balls... |
| 518 | func(103); print_spinner(); |
| 519 | func(123); print_spinner(); |
| 520 | func(131); print_spinner(); |
| 521 | } |
| 522 | |
| 523 | template<typename R> |
| 524 | void test_vector_overload_inplace() |