MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / transformCoordinatesTest

Function transformCoordinatesTest

test/transform_coordinates.cpp:37–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36template<typename T>
37void transformCoordinatesTest(string pTestFile) {
38 SUPPORTED_TYPE_CHECK(T);
39
40 vector<dim4> inDims;
41 vector<vector<T>> in;
42 vector<vector<float>> gold;
43
44 readTests<T, float, float>(pTestFile, inDims, in, gold);
45
46 af_array tfArray = 0;
47 af_array outArray = 0;
48 ASSERT_SUCCESS(af_create_array(&tfArray, &(in[0].front()),
49 inDims[0].ndims(), inDims[0].get(),
50 (af_dtype)dtype_traits<T>::af_type));
51
52 int nTests = in.size();
53
54 for (int test = 1; test < nTests; test++) {
55 dim_t d0 = (dim_t)in[test][0];
56 dim_t d1 = (dim_t)in[test][1];
57
58 ASSERT_SUCCESS(af_transform_coordinates(&outArray, tfArray, d0, d1));
59
60 // Get result
61 dim_t outEl = 0;
62 ASSERT_SUCCESS(af_get_elements(&outEl, outArray));
63 vector<T> outData(outEl);
64 ASSERT_SUCCESS(af_get_data_ptr((void *)&outData.front(), outArray));
65
66 ASSERT_SUCCESS(af_release_array(outArray));
67 const float thr = 1.f;
68
69 for (dim_t elIter = 0; elIter < outEl; elIter++) {
70 ASSERT_LE(fabs(outData[elIter] - gold[test - 1][elIter]), thr)
71 << "at: " << elIter << endl;
72 }
73 }
74
75 if (tfArray != 0) af_release_array(tfArray);
76}
77
78TYPED_TEST(TransformCoordinates, RotateMatrix) {
79 transformCoordinatesTest<TypeParam>(

Callers

nothing calls this directly

Calls 8

af_get_elementsFunction · 0.85
fabsFunction · 0.85
af_create_arrayFunction · 0.50
af_transform_coordinatesFunction · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected