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

Method perform_test

dlib/test/sparse_vector.cpp:157–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156
157 void perform_test (
158 )
159 {
160 test_make_sparse_vector_inplace();
161
162 std::map<unsigned int, double> v;
163 v[4] = 8;
164 v[2] = -4;
165 v[9] = 10;
166
167 DLIB_TEST(max(v) == 10);
168 DLIB_TEST(min(v) == -4);
169
170 v.clear();
171 v[4] = 8;
172 v[9] = 10;
173 DLIB_TEST(max(v) == 10);
174 DLIB_TEST(min(v) == 0);
175
176
177 v.clear();
178 v[4] = -9;
179 v[9] = -4;
180 DLIB_TEST(max(v) == 0);
181 DLIB_TEST(min(v) == -9);
182
183
184 {
185 matrix<double> a(2,2), b(2,2);
186 a = randm(2,2);
187 b = randm(2,2);
188
189 DLIB_TEST(equal(a-b, subtract(a,b)));
190 DLIB_TEST(equal(a+b, add(a,b)));
191 DLIB_TEST(equal(a-(b+b), subtract(a,b+b)));
192 DLIB_TEST(equal(a+b+b, add(a,b+b)));
193 }
194
195 {
196 std::map<unsigned long,double> a, b, c;
197 a[1] = 2;
198 a[3] = 5;
199
200 b[0] = 3;
201 b[1] = 1;
202
203 c = add(a,b);
204 DLIB_TEST(c.size() == 3);
205 DLIB_TEST(c[0] == 3);
206 DLIB_TEST(c[1] == 3);
207 DLIB_TEST(c[3] == 5);
208
209 c = subtract(a,b);
210 DLIB_TEST(c.size() == 3);
211 DLIB_TEST(c[0] == -3);
212 DLIB_TEST(c[1] == 1);
213 DLIB_TEST(c[3] == 5);
214

Callers

nothing calls this directly

Calls 15

subtractFunction · 0.85
gaussian_randmFunction · 0.85
absFunction · 0.85
randmFunction · 0.70
addFunction · 0.70
maxFunction · 0.50
minFunction · 0.50
equalFunction · 0.50

Tested by

no test coverage detected