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

Function stdevDimTest

test/stdev.cpp:78–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76
77template<typename T>
78void stdevDimTest(string pFileName, dim_t dim,
79 const bool useDeprecatedAPI = false) {
80 typedef typename sdOutType<T>::type outType;
81 SUPPORTED_TYPE_CHECK(T);
82 SUPPORTED_TYPE_CHECK(outType);
83
84 vector<dim4> numDims;
85 vector<vector<int>> in;
86 vector<vector<float>> tests;
87
88 readTestsFromFile<int, float>(pFileName, numDims, in, tests);
89
90 dim4 dims = numDims[0];
91 vector<T> input(in[0].begin(), in[0].end());
92
93 array a(dims, &(input.front()));
94
95#pragma GCC diagnostic push
96#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
97 array b = (useDeprecatedAPI ? stdev(a, dim)
98 : stdev(a, AF_VARIANCE_POPULATION, dim));
99#pragma GCC diagnostic pop
100
101 vector<outType> currGoldBar(tests[0].begin(), tests[0].end());
102
103 size_t nElems = currGoldBar.size();
104 vector<outType> outData(nElems);
105
106 b.host((void*)outData.data());
107
108 for (size_t elIter = 0; elIter < nElems; ++elIter) {
109 ASSERT_NEAR(::real(currGoldBar[elIter]), ::real(outData[elIter]),
110 1.0e-3)
111 << "at: " << elIter << endl;
112 ASSERT_NEAR(::imag(currGoldBar[elIter]), ::imag(outData[elIter]),
113 1.0e-3)
114 << "at: " << elIter << endl;
115 }
116}
117
118TYPED_TEST(StandardDev, Dim0) {
119 stdevDimTest<TypeParam>(string(TEST_DIR "/stdev/mat_10x10_dim0.test"), 0);

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected