| 140 | |
| 141 | template<typename T> |
| 142 | void approx1CubicTest(string pTestFile, const unsigned resultIdx, |
| 143 | const af_interp_type method, bool isSubRef = false, |
| 144 | const vector<af_seq>* seqv = NULL) { |
| 145 | SUPPORTED_TYPE_CHECK(T); |
| 146 | |
| 147 | typedef typename dtype_traits<T>::base_type BT; |
| 148 | vector<dim4> numDims; |
| 149 | vector<vector<BT>> in; |
| 150 | vector<vector<T>> tests; |
| 151 | readTests<BT, T, float>(pTestFile, numDims, in, tests); |
| 152 | |
| 153 | dim4 idims = numDims[0]; |
| 154 | dim4 pdims = numDims[1]; |
| 155 | |
| 156 | af_array inArray = 0; |
| 157 | af_array posArray = 0; |
| 158 | af_array outArray = 0; |
| 159 | af_array tempArray = 0; |
| 160 | |
| 161 | vector<T> input(in[0].begin(), in[0].end()); |
| 162 | |
| 163 | if (isSubRef) { |
| 164 | ASSERT_SUCCESS(af_create_array(&tempArray, &(input.front()), |
| 165 | idims.ndims(), idims.get(), |
| 166 | (af_dtype)dtype_traits<T>::af_type)); |
| 167 | ASSERT_SUCCESS( |
| 168 | af_index(&inArray, tempArray, seqv->size(), &seqv->front())); |
| 169 | } else { |
| 170 | ASSERT_SUCCESS(af_create_array(&inArray, &(input.front()), |
| 171 | idims.ndims(), idims.get(), |
| 172 | (af_dtype)dtype_traits<T>::af_type)); |
| 173 | } |
| 174 | |
| 175 | ASSERT_SUCCESS(af_create_array(&posArray, &(in[1].front()), pdims.ndims(), |
| 176 | pdims.get(), |
| 177 | (af_dtype)dtype_traits<BT>::af_type)); |
| 178 | ASSERT_SUCCESS(af_approx1(&outArray, inArray, posArray, method, 0)); |
| 179 | |
| 180 | // Get result |
| 181 | T* outData = new T[tests[resultIdx].size()]; |
| 182 | ASSERT_SUCCESS(af_get_data_ptr((void*)outData, outArray)); |
| 183 | |
| 184 | // Compare result |
| 185 | size_t nElems = tests[resultIdx].size(); |
| 186 | bool ret = true; |
| 187 | |
| 188 | float max = real(outData[0]), min = real(outData[0]); |
| 189 | for (int i = 1; i < (int)nElems; ++i) { |
| 190 | min = (real(outData[i]) < min) ? real(outData[i]) : min; |
| 191 | max = (real(outData[i]) > max) ? real(outData[i]) : max; |
| 192 | } |
| 193 | float range = max - min; |
| 194 | ASSERT_GT(range, 0.f); |
| 195 | |
| 196 | for (size_t elIter = 0; elIter < nElems; ++elIter) { |
| 197 | double integral; |
| 198 | // Test that control points are exact |
| 199 | if ((std::modf(in[1][elIter], &integral) < 0.001) || |
nothing calls this directly
no test coverage detected