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

Function stdevDimIndexTest

test/stdev.cpp:154–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152
153template<typename T>
154void 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
195TYPED_TEST(StandardDev, IndexedArrayDim0) {
196 stdevDimIndexTest<TypeParam>(

Callers

nothing calls this directly

Calls 5

seqClass · 0.85
hostMethod · 0.80
realFunction · 0.70
imagFunction · 0.70
stdevFunction · 0.50

Tested by

no test coverage detected