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

Function resizeTest

test/resize.cpp:116–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114
115template<typename T>
116void resizeTest(string pTestFile, const unsigned resultIdx, const dim_t odim0,
117 const dim_t odim1, const af_interp_type method,
118 bool isSubRef = false, const vector<af_seq>* seqv = NULL) {
119 SUPPORTED_TYPE_CHECK(T);
120
121 vector<dim4> numDims;
122 vector<vector<T>> in;
123 vector<vector<T>> tests;
124 readTests<T, T, float>(pTestFile, numDims, in, tests);
125
126 dim4 dims = numDims[0];
127
128 af_array inArray = 0;
129 af_array outArray = 0;
130 af_array tempArray = 0;
131 if (isSubRef) {
132 ASSERT_SUCCESS(af_create_array(&tempArray, &(in[0].front()),
133 dims.ndims(), dims.get(),
134 (af_dtype)dtype_traits<T>::af_type));
135
136 ASSERT_SUCCESS(
137 af_index(&inArray, tempArray, seqv->size(), &seqv->front()));
138 } else {
139 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()), dims.ndims(),
140 dims.get(),
141 (af_dtype)dtype_traits<T>::af_type));
142 }
143
144 ASSERT_SUCCESS(af_resize(&outArray, inArray, odim0, odim1, method));
145
146 // Get result
147 dim4 odims(odim0, odim1, dims[2], dims[3]);
148 T* outData = new T[odims.elements()];
149 ASSERT_SUCCESS(af_get_data_ptr((void*)outData, outArray));
150
151 // Compare result
152 size_t nElems = tests[resultIdx].size();
153 for (size_t elIter = 0; elIter < nElems; ++elIter) {
154 compare<T>(tests[resultIdx][elIter], outData[elIter], 0.0001, elIter);
155 }
156
157 // Delete
158 delete[] outData;
159
160 if (inArray != 0) af_release_array(inArray);
161 if (outArray != 0) af_release_array(outArray);
162 if (tempArray != 0) af_release_array(tempArray);
163}
164
165///////////////////////////////////////////////////////////////////////////////
166// Float Types

Callers

nothing calls this directly

Calls 8

af_create_arrayFunction · 0.50
af_indexFunction · 0.50
af_resizeFunction · 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