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

Method perform_test

dlib/test/sparse_vector.cpp:192–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190
191
192 void perform_test (
193 )
194 {
195 test_make_sparse_vector_inplace();
196 test_normalize();
197
198 std::map<unsigned int, double> v;
199 v[4] = 8;
200 v[2] = -4;
201 v[9] = 10;
202
203 DLIB_TEST(max(v) == 10);
204 DLIB_TEST(min(v) == -4);
205
206 v.clear();
207 v[4] = 8;
208 v[9] = 10;
209 DLIB_TEST(max(v) == 10);
210 DLIB_TEST(min(v) == 0);
211
212
213 v.clear();
214 v[4] = -9;
215 v[9] = -4;
216 DLIB_TEST(max(v) == 0);
217 DLIB_TEST(min(v) == -9);
218
219
220 {
221 matrix<double> a(2,2), b(2,2);
222 a = randm(2,2);
223 b = randm(2,2);
224
225 DLIB_TEST(equal(a-b, subtract(a,b)));
226 DLIB_TEST(equal(a+b, add(a,b)));
227 DLIB_TEST(equal(a-(b+b), subtract(a,b+b)));
228 DLIB_TEST(equal(a+b+b, add(a,b+b)));
229 }
230
231 {
232 std::map<unsigned long,double> a, b, c;
233 a[1] = 2;
234 a[3] = 5;
235
236 b[0] = 3;
237 b[1] = 1;
238
239 c = add(a,b);
240 DLIB_TEST(c.size() == 3);
241 DLIB_TEST(c[0] == 3);
242 DLIB_TEST(c[1] == 3);
243 DLIB_TEST(c[3] == 5);
244
245 c = subtract(a,b);
246 DLIB_TEST(c.size() == 3);
247 DLIB_TEST(c[0] == -3);
248 DLIB_TEST(c[1] == 1);
249 DLIB_TEST(c[3] == 5);

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected