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

Function solveTriangleTester

test/solve_common.hpp:91–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89
90template<typename T>
91void solveTriangleTester(const int n, const int k, bool is_upper, double eps,
92 int targetDevice = -1) {
93 if (targetDevice >= 0) af::setDevice(targetDevice);
94
95 af::deviceGC();
96
97 SUPPORTED_TYPE_CHECK(T);
98 LAPACK_ENABLED_CHECK();
99
100#if 1
101 af::array A = cpu_randu<T>(af::dim4(n, n));
102 af::array X0 = cpu_randu<T>(af::dim4(n, k));
103#else
104 af::array A = af::randu(n, n, (af::dtype)af::dtype_traits<T>::af_type);
105 af::array X0 = af::randu(n, k, (af::dtype)af::dtype_traits<T>::af_type);
106#endif
107
108 af::array L, U, pivot;
109 af::lu(L, U, pivot, A);
110
111 af::array AT = is_upper ? U : L;
112 af::array B0 = af::matmul(AT, X0);
113 af::array X1;
114
115 if (is_upper) {
116 //! [ex_solve_upper]
117 af::array X = af::solve(AT, B0, AF_MAT_UPPER);
118 //! [ex_solve_upper]
119
120 X1 = X;
121 } else {
122 //! [ex_solve_lower]
123 af::array X = af::solve(AT, B0, AF_MAT_LOWER);
124 //! [ex_solve_lower]
125
126 X1 = X;
127 }
128
129 af::array B1 = af::matmul(AT, X1);
130
131 ASSERT_ARRAYS_NEAR(B0, B1, eps);
132}

Callers

nothing calls this directly

Calls 7

deviceGCFunction · 0.85
randuFunction · 0.85
setDeviceFunction · 0.50
dim4Class · 0.50
luFunction · 0.50
matmulFunction · 0.50
solveFunction · 0.50

Tested by

no test coverage detected