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

Function test_matrix_IO

dlib/test/matrix3.cpp:1021–1075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1019
1020
1021 void test_matrix_IO()
1022 {
1023 dlib::rand rnd;
1024 print_spinner();
1025
1026 for (int i = 0; i < 400; ++i)
1027 {
1028 ostringstream sout;
1029 sout.precision(20);
1030
1031 matrix<double> m1, m2, m3;
1032
1033 const long r = rnd.get_random_32bit_number()%7+1;
1034 const long c = rnd.get_random_32bit_number()%7+1;
1035 const long num = rnd.get_random_32bit_number()%2+1;
1036
1037 m1 = randm(r,c,rnd);
1038 sout << m1;
1039 if (num != 1)
1040 sout << "\n" << m1;
1041
1042 if (rnd.get_random_double() < 0.3)
1043 sout << " \n";
1044 else if (rnd.get_random_double() < 0.3)
1045 sout << " \n\n 3 3 3 3";
1046 else if (rnd.get_random_double() < 0.3)
1047 sout << " \n \n v 3 3 3 3 3";
1048
1049 istringstream sin(sout.str());
1050 sin >> m2;
1051 DLIB_TEST_MSG(equal(m1,m2), m1 << "\n***********\n" << m2);
1052
1053 if (num != 1)
1054 {
1055 sin >> m3;
1056 DLIB_TEST_MSG(equal(m1,m3), m1 << "\n***********\n" << m3);
1057 }
1058 }
1059
1060
1061 {
1062 istringstream sin(" 1 2\n3");
1063 matrix<double> m;
1064 DLIB_TEST(sin.good());
1065 sin >> m;
1066 DLIB_TEST(!sin.good());
1067 }
1068 {
1069 istringstream sin("");
1070 matrix<double> m;
1071 DLIB_TEST(sin.good());
1072 sin >> m;
1073 DLIB_TEST(!sin.good());
1074 }
1075 }
1076
1077
1078 void test_axpy()

Callers 1

perform_testMethod · 0.85

Calls 6

print_spinnerFunction · 0.85
get_random_doubleMethod · 0.80
randmFunction · 0.70
equalFunction · 0.50
strMethod · 0.45

Tested by

no test coverage detected