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

Function matrix_test2

dlib/test/matrix2.cpp:751–1144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

749
750
751 void matrix_test2 (
752 )
753 {
754 typedef memory_manager_stateless<char>::kernel_2_2a MM;
755 {
756 srand(423452);
757 const long M = 10;
758 const long N = 7;
759
760 matrix<double> a(M,N);
761 for (long r = 0; r < a.nr(); ++r)
762 {
763 for (long c = 0; c < a.nc(); ++c)
764 {
765 a(r,c) = 10*((double)::rand())/RAND_MAX;
766 }
767 }
768
769 matrix<double,M> u(M,N);
770 matrix<double> w;
771 matrix<double,N,N> v(N,N);
772
773 matrix<double,M,N,MM> a2;
774 a2 = tmp(a/2);
775
776
777 svd(a2+a2,u,w,v);
778
779 DLIB_TEST( sum(round(1e10*(a - u*w*trans(v)))) == 0);
780 DLIB_TEST((round(1e10*trans(u)*u) == 1e10*identity_matrix<double,N>()));
781 DLIB_TEST((round(1e10*trans(v)*v) == 1e10*identity_matrix<double,N>()));
782 }
783
784 {
785 srand(423452);
786 const long M = 1;
787 const long N = 1;
788
789 matrix<double> a(M,N);
790 for (long r = 0; r < a.nr(); ++r)
791 {
792 for (long c = 0; c < a.nc(); ++c)
793 {
794 a(r,c) = 10*((double)::rand())/RAND_MAX;
795 }
796 }
797
798 matrix<double,M,N> u;
799 matrix<double> w;
800 matrix<double,N,N> v;
801
802 matrix<double,M,N> a2;
803 a2 = 0;
804 a2 = tmp(a/2);
805
806
807 svd(a2+a2,u,w,v);
808

Callers 1

perform_testMethod · 0.70

Calls 15

tmpFunction · 0.85
svdFunction · 0.85
roundFunction · 0.85
set_all_elementsFunction · 0.85
pointwise_multiplyFunction · 0.85
complex_matrixFunction · 0.85
pointwise_divideFunction · 0.85
round_zerosFunction · 0.85
meanFunction · 0.85
absFunction · 0.85
varianceFunction · 0.85
submFunction · 0.85

Tested by

no test coverage detected