| 73 | |
| 74 | template<typename T> |
| 75 | void covTest(string pFileName, bool isbiased = true, |
| 76 | const bool useDeprecatedAPI = false) { |
| 77 | typedef typename covOutType<T>::type outType; |
| 78 | SUPPORTED_TYPE_CHECK(T); |
| 79 | SUPPORTED_TYPE_CHECK(outType); |
| 80 | |
| 81 | vector<dim4> numDims; |
| 82 | vector<vector<int>> in; |
| 83 | vector<vector<float>> tests; |
| 84 | |
| 85 | readTestsFromFile<int, float>(pFileName, numDims, in, tests); |
| 86 | |
| 87 | dim4 dims1 = numDims[0]; |
| 88 | dim4 dims2 = numDims[1]; |
| 89 | vector<T> input1(in[0].begin(), in[0].end()); |
| 90 | vector<T> input2(in[1].begin(), in[1].end()); |
| 91 | |
| 92 | array a(dims1, &(input1.front())); |
| 93 | array b(dims2, &(input2.front())); |
| 94 | |
| 95 | #pragma GCC diagnostic push |
| 96 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
| 97 | array c = |
| 98 | (useDeprecatedAPI |
| 99 | ? cov(a, b, isbiased) |
| 100 | : cov(a, b, |
| 101 | (isbiased ? AF_VARIANCE_SAMPLE : AF_VARIANCE_POPULATION))); |
| 102 | #pragma GCC diagnostic pop |
| 103 | |
| 104 | vector<outType> currGoldBar(tests[0].begin(), tests[0].end()); |
| 105 | |
| 106 | size_t nElems = currGoldBar.size(); |
| 107 | vector<outType> outData(nElems); |
| 108 | |
| 109 | c.host((void*)outData.data()); |
| 110 | |
| 111 | for (size_t elIter = 0; elIter < nElems; ++elIter) { |
| 112 | ASSERT_NEAR(::real(currGoldBar[elIter]), ::real(outData[elIter]), |
| 113 | 1.0e-3) |
| 114 | << "at: " << elIter << endl; |
| 115 | ASSERT_NEAR(::imag(currGoldBar[elIter]), ::imag(outData[elIter]), |
| 116 | 1.0e-3) |
| 117 | << "at: " << elIter << endl; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | TYPED_TEST(Covariance, Vector) { |
| 122 | covTest<TypeParam>(string(TEST_DIR "/covariance/vec_size60.test")); |