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

Function TEST

test/qr_dense.cpp:36–87  ·  view source on GitHub ↗

//////////////////////////// CPP ////////////////////////////////////

Source from the content-addressed store, hash-verified

34
35///////////////////////////////// CPP ////////////////////////////////////
36TEST(QRFactorized, CPP) {
37 LAPACK_ENABLED_CHECK();
38
39 int resultIdx = 0;
40
41 vector<dim4> numDims;
42 vector<vector<float>> in;
43 vector<vector<float>> tests;
44 readTests<float, float, float>(string(TEST_DIR "/lapack/qrfactorized.test"),
45 numDims, in, tests);
46
47 dim4 idims = numDims[0];
48 array input(idims, &(in[0].front()));
49
50 array q, r, tau;
51 qr(q, r, tau, input);
52
53 dim4 qdims = q.dims();
54 dim4 rdims = r.dims();
55
56 // Get result
57 float* qData = new float[qdims.elements()];
58 q.host((void*)qData);
59 float* rData = new float[rdims.elements()];
60 r.host((void*)rData);
61
62 // Compare result
63 for (int y = 0; y < (int)qdims[1]; ++y) {
64 for (int x = 0; x < (int)qdims[0]; ++x) {
65 int elIter = y * qdims[0] + x;
66 ASSERT_NEAR(tests[resultIdx][elIter], qData[elIter], 0.001)
67 << "at: " << elIter << endl;
68 }
69 }
70
71 resultIdx = 1;
72
73 for (int y = 0; y < (int)rdims[1]; ++y) {
74 for (int x = 0; x < (int)rdims[0]; ++x) {
75 // Test only upper half
76 if (x <= y) {
77 int elIter = y * rdims[0] + x;
78 ASSERT_NEAR(tests[resultIdx][elIter], rData[elIter], 0.001)
79 << "at: " << elIter << endl;
80 }
81 }
82 }
83
84 // Delete
85 delete[] qData;
86 delete[] rData;
87}
88
89template<typename T>
90void qrTester(const int m, const int n, double eps) {

Callers

nothing calls this directly

Calls 9

hostMethod · 0.80
qrFunction · 0.50
af_randuFunction · 0.50
af_qr_inplaceFunction · 0.50
af_release_arrayFunction · 0.50
dimsMethod · 0.45
elementsMethod · 0.45
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected