| 45 | |
| 46 | template<typename T> |
| 47 | void solveTester(const int m, const int n, const int k, const int b, double eps, |
| 48 | int targetDevice = -1) { |
| 49 | if (targetDevice >= 0) setDevice(targetDevice); |
| 50 | |
| 51 | deviceGC(); |
| 52 | |
| 53 | SUPPORTED_TYPE_CHECK(T); |
| 54 | LAPACK_ENABLED_CHECK(); |
| 55 | |
| 56 | #if 1 |
| 57 | array A = cpu_randu<T>(dim4(m, n, b)); |
| 58 | array X0 = cpu_randu<T>(dim4(n, k, b)); |
| 59 | #else |
| 60 | array A = randu(m, n, (dtype)dtype_traits<T>::af_type); |
| 61 | array X0 = randu(n, k, (dtype)dtype_traits<T>::af_type); |
| 62 | #endif |
| 63 | array B0 = matmul(A, X0); |
| 64 | |
| 65 | //! [ex_solve] |
| 66 | array X1 = solve(A, B0); |
| 67 | //! [ex_solve] |
| 68 | |
| 69 | //! [ex_solve_recon] |
| 70 | array B1 = matmul(A, X1); |
| 71 | //! [ex_solve_recon] |
| 72 | |
| 73 | ASSERT_NEAR( |
| 74 | 0, |
| 75 | sum<typename dtype_traits<T>::base_type>(abs(real(B0 - B1))) / (m * k), |
| 76 | eps); |
| 77 | ASSERT_NEAR( |
| 78 | 0, |
| 79 | sum<typename dtype_traits<T>::base_type>(abs(imag(B0 - B1))) / (m * k), |
| 80 | eps); |
| 81 | } |
| 82 | |
| 83 | template<typename T> |
| 84 | void solveLUTester(const int n, const int k, double eps, |