| 152 | |
| 153 | template<typename T> |
| 154 | void stdevDimIndexTest(string pFileName, dim_t dim, |
| 155 | const bool useDeprecatedAPI = false) { |
| 156 | typedef typename sdOutType<T>::type outType; |
| 157 | SUPPORTED_TYPE_CHECK(T); |
| 158 | SUPPORTED_TYPE_CHECK(outType); |
| 159 | |
| 160 | vector<dim4> numDims; |
| 161 | vector<vector<int>> in; |
| 162 | vector<vector<float>> tests; |
| 163 | |
| 164 | readTestsFromFile<int, float>(pFileName, numDims, in, tests); |
| 165 | |
| 166 | dim4 dims = numDims[0]; |
| 167 | vector<T> input(in[0].begin(), in[0].end()); |
| 168 | |
| 169 | array a(dims, &(input.front())); |
| 170 | array b = a(seq(2, 6), seq(1, 7)); |
| 171 | |
| 172 | #pragma GCC diagnostic push |
| 173 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
| 174 | array c = (useDeprecatedAPI ? stdev(b, dim) |
| 175 | : stdev(b, AF_VARIANCE_POPULATION, dim)); |
| 176 | #pragma GCC diagnostic pop |
| 177 | |
| 178 | vector<outType> currGoldBar(tests[0].begin(), tests[0].end()); |
| 179 | |
| 180 | size_t nElems = currGoldBar.size(); |
| 181 | vector<outType> outData(nElems); |
| 182 | |
| 183 | c.host((void*)outData.data()); |
| 184 | |
| 185 | for (size_t elIter = 0; elIter < nElems; ++elIter) { |
| 186 | ASSERT_NEAR(::real(currGoldBar[elIter]), ::real(outData[elIter]), |
| 187 | 1.0e-3) |
| 188 | << "at: " << elIter << endl; |
| 189 | ASSERT_NEAR(::imag(currGoldBar[elIter]), ::imag(outData[elIter]), |
| 190 | 1.0e-3) |
| 191 | << "at: " << elIter << endl; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | TYPED_TEST(StandardDev, IndexedArrayDim0) { |
| 196 | stdevDimIndexTest<TypeParam>( |