| 33 | |
| 34 | template<typename T> |
| 35 | void inverseTester(const int m, const int n, double eps) { |
| 36 | SUPPORTED_TYPE_CHECK(T); |
| 37 | LAPACK_ENABLED_CHECK(); |
| 38 | #if 1 |
| 39 | array A = cpu_randu<T>(dim4(m, n)); |
| 40 | #else |
| 41 | array A = randu(m, n, (dtype)dtype_traits<T>::af_type); |
| 42 | #endif |
| 43 | |
| 44 | //! [ex_inverse] |
| 45 | array IA = inverse(A); |
| 46 | array I = matmul(A, IA); |
| 47 | //! [ex_inverse] |
| 48 | |
| 49 | array I2 = identity(m, n, (dtype)dtype_traits<T>::af_type); |
| 50 | |
| 51 | ASSERT_NEAR(0, max<typename dtype_traits<T>::base_type>(abs(real(I - I2))), |
| 52 | eps); |
| 53 | ASSERT_NEAR(0, max<typename dtype_traits<T>::base_type>(abs(imag(I - I2))), |
| 54 | eps); |
| 55 | } |
| 56 | |
| 57 | template<typename T> |
| 58 | class Inverse : public ::testing::Test {}; |