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

Function matrix_test

dlib/test/matrix4.cpp:28–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26 logger dlog("test.matrix4");
27
28 void matrix_test (
29 )
30 /*!
31 ensures
32 - runs tests on the matrix stuff compliance with the specs
33 !*/
34 {
35 print_spinner();
36
37 {
38 matrix<double,3,3> m = round(10*randm(3,3));
39 matrix<double,3,1> v = round(10*randm(3,1));
40
41 DLIB_TEST(equal( m*diagm(v) , m*tmp(diagm(v)) ));
42 DLIB_TEST(equal( scale_columns(m,v) , m*tmp(diagm(v)) ));
43
44 DLIB_TEST(equal( diagm(v)*m , tmp(diagm(v))*m ));
45 DLIB_TEST(equal( scale_rows(m,v) , tmp(diagm(v))*m ));
46 }
47
48 {
49 matrix<double,3,3> m = round(10*randm(3,3));
50 matrix<double,1,3> v = round(10*randm(1,3));
51
52 DLIB_TEST(equal( m*diagm(v) , m*tmp(diagm(v)) ));
53 DLIB_TEST(equal( scale_columns(m,v) , m*tmp(diagm(v)) ));
54
55 DLIB_TEST(equal( diagm(v)*m , tmp(diagm(v))*m ));
56 DLIB_TEST(equal( scale_rows(m,v) , tmp(diagm(v))*m ));
57 }
58
59 {
60 matrix<double> m = round(10*randm(3,3));
61 matrix<double,1,3> v = round(10*randm(1,3));
62
63 DLIB_TEST(equal( m*diagm(v) , m*tmp(diagm(v)) ));
64 DLIB_TEST(equal( scale_columns(m,v) , m*tmp(diagm(v)) ));
65
66 DLIB_TEST(equal( diagm(v)*m , tmp(diagm(v))*m ));
67 DLIB_TEST(equal( scale_rows(m,v) , tmp(diagm(v))*m ));
68 }
69
70 {
71 matrix<double> m = round(10*randm(3,3));
72 matrix<double,0,3> v = round(10*randm(1,3));
73
74 DLIB_TEST(equal( m*diagm(v) , m*tmp(diagm(v)) ));
75 DLIB_TEST(equal( scale_columns(m,v) , m*tmp(diagm(v)) ));
76
77 DLIB_TEST(equal( diagm(v)*m , tmp(diagm(v))*m ));
78 DLIB_TEST(equal( scale_rows(m,v) , tmp(diagm(v))*m ));
79 }
80
81
82 {
83 matrix<double> m = round(10*randm(3,3));
84 matrix<double,1,0> v = round(10*randm(1,3));
85

Callers 1

perform_testMethod · 0.70

Calls 8

print_spinnerFunction · 0.85
roundFunction · 0.85
diagmFunction · 0.85
tmpFunction · 0.85
randmFunction · 0.70
equalFunction · 0.50
scale_columnsFunction · 0.50
scale_rowsFunction · 0.50

Tested by

no test coverage detected