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

Function matrix_test2

dlib/test/matrix.cpp:782–1622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780
781
782 void matrix_test2()
783 {
784 print_spinner();
785
786
787 {
788
789 const double stuff[] = {
790 1, 2, 3,
791 6, 3, 3,
792 7, 3, 9};
793
794 matrix<double,3,3> m(stuff);
795
796 // make m be symmetric
797 m = m*trans(m);
798
799 matrix<double> L = chol(m);
800 DLIB_TEST(equal(L*trans(L), m));
801
802 DLIB_TEST_MSG(equal(inv(m), inv_upper_triangular(trans(L))*inv_lower_triangular((L))), "");
803 DLIB_TEST(equal(round_zeros(inv_upper_triangular(trans(L))*trans(L),1e-10), identity_matrix<double>(3), 1e-10));
804 DLIB_TEST(equal(round_zeros(inv_lower_triangular((L))*(L),1e-10) ,identity_matrix<double>(3),1e-10));
805
806 }
807
808 {
809
810 const double stuff[] = {
811 1, 2, 3, 6, 3, 4,
812 6, 3, 3, 1, 2, 3,
813 7, 3, 9, 54.3, 5, 3,
814 -6, 3, -3, 1, 2, 3,
815 1, 2, 3, 5, -3, 3,
816 7, 3, -9, 54.3, 5, 3
817 };
818
819 matrix<double,6,6> m(stuff);
820
821 // make m be symmetric
822 m = m*trans(m);
823
824 matrix<double> L = chol(m);
825 DLIB_TEST_MSG(equal(L*trans(L), m, 1e-10), L*trans(L)-m);
826
827 DLIB_TEST_MSG(equal(inv(m), inv_upper_triangular(trans(L))*inv_lower_triangular((L))), "");
828 DLIB_TEST_MSG(equal(inv(m), trans(inv_lower_triangular(L))*inv_lower_triangular((L))), "");
829 DLIB_TEST_MSG(equal(inv(m), trans(inv_lower_triangular(L))*trans(inv_upper_triangular(trans(L)))), "");
830 DLIB_TEST_MSG(equal(round_zeros(inv_upper_triangular(trans(L))*trans(L),1e-10) , identity_matrix<double>(6), 1e-10),
831 round_zeros(inv_upper_triangular(trans(L))*trans(L),1e-10));
832 DLIB_TEST_MSG(equal(round_zeros(inv_lower_triangular((L))*(L),1e-10) ,identity_matrix<double>(6), 1e-10),
833 round_zeros(inv_lower_triangular((L))*(L),1e-10));
834
835 }
836
837 {
838 // Test band chol
839 matrix<double> m = rand_sp_banded<double>(10, 3);

Callers 1

perform_testMethod · 0.70

Calls 15

print_spinnerFunction · 0.85
cholFunction · 0.85
inv_upper_triangularFunction · 0.85
inv_lower_triangularFunction · 0.85
round_zerosFunction · 0.85
roundFunction · 0.85
tmpFunction · 0.85
absFunction · 0.85
set_all_elementsFunction · 0.85
diagmFunction · 0.85
submFunction · 0.85
max_pointwiseFunction · 0.85

Tested by

no test coverage detected