| 86 | |
| 87 | template<typename T> |
| 88 | void svdInPlaceTest(const int M, const int N) { |
| 89 | SUPPORTED_TYPE_CHECK(T); |
| 90 | LAPACK_ENABLED_CHECK(); |
| 91 | |
| 92 | dtype ty = (dtype)dtype_traits<T>::af_type; |
| 93 | |
| 94 | array A = randu(M, N, ty); |
| 95 | array A_copy = A.copy(); |
| 96 | |
| 97 | array U, S, Vt; |
| 98 | af::svdInPlace(U, S, Vt, A); |
| 99 | |
| 100 | const int MN = std::min(M, N); |
| 101 | |
| 102 | array UU = U(span, seq(MN)); |
| 103 | array SS = diag(S, 0, false).as(ty); |
| 104 | array VV = Vt(seq(MN), span); |
| 105 | |
| 106 | array AA = matmul(UU, SS, VV); |
| 107 | |
| 108 | #if defined(OS_MAC) |
| 109 | ASSERT_ARRAYS_NEAR(A_copy, AA, 3E-3); |
| 110 | #else |
| 111 | ASSERT_ARRAYS_NEAR(A_copy, AA, 1E-3); |
| 112 | #endif |
| 113 | } |
| 114 | |
| 115 | template<typename T> |
| 116 | void checkInPlaceSameResults(const int M, const int N) { |