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

Function test_conversions

dlib/test/simd.cpp:16–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15 template <typename float_vector, typename int_vector>
16 void test_conversions()
17 {
18 const float input[] = {
19 1.75f, -2.5f, 0.0f, 17.0f,
20 0.6875f, -0.6875f, 1.0625f, -1.0625f,
21 2147483520.0f, -2147483648.0f, 16777215.0f, -16777215.0f,
22 0.0f, -0.0f, 123.875f, -123.875f
23 };
24 float_vector values;
25 for (unsigned int offset = 0; offset < 16; offset += values.size())
26 {
27 values.load(input + offset);
28 const int_vector converted(values);
29 const float_vector restored(converted);
30 const float_vector fractions = values - converted;
31 for (unsigned int i = 0; i < values.size(); ++i)
32 {
33 const int32 expected = static_cast<int32>(input[offset+i]);
34 DLIB_TEST(converted[i] == expected);
35 DLIB_TEST(restored[i] == static_cast<float>(expected));
36 DLIB_TEST(fractions[i] == input[offset+i] - static_cast<float>(expected));
37 }
38 }
39 }
40
41 void test_resize()
42 {

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected