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

Function rangeTest

test/range.cpp:63–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62template<typename T>
63void rangeTest(const uint x, const uint y, const uint z, const uint w,
64 const uint dim) {
65 SUPPORTED_TYPE_CHECK(T);
66
67 dim4 idims(x, y, z, w);
68
69 af_array outArray = 0;
70
71 ASSERT_SUCCESS(af_range(&outArray, idims.ndims(), idims.get(), dim,
72 (af_dtype)dtype_traits<T>::af_type));
73
74 // Get result
75 T* outData = new T[idims.elements()];
76 ASSERT_SUCCESS(af_get_data_ptr((void*)outData, outArray));
77
78 // Compare result
79 for (int w = 0; w < (int)idims[3]; w++) {
80 for (int z = 0; z < (int)idims[2]; z++) {
81 for (int y = 0; y < (int)idims[1]; y++) {
82 for (int x = 0; x < (int)idims[0]; x++) {
83 T val(0);
84 if (dim == 0) {
85 val = x;
86 } else if (dim == 1) {
87 val = y;
88 } else if (dim == 2) {
89 val = z;
90 } else if (dim == 3) {
91 val = w;
92 }
93 dim_t idx = w * idims[0] * idims[1] * idims[2] +
94 z * idims[0] * idims[1] + y * idims[0] + x;
95
96 ASSERT_EQ(val, outData[idx]) << "at: " << idx;
97 }
98 }
99 }
100 }
101
102 // Delete
103 delete[] outData;
104
105 if (outArray != 0) af_release_array(outArray);
106}
107
108#define RANGE_INIT(desc, x, y, z, w, rep) \
109 TYPED_TEST(Range, desc) { rangeTest<TypeParam>(x, y, z, w, rep); }

Callers

nothing calls this directly

Calls 6

af_rangeFunction · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected