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

Function svdTest

test/svd_dense.cpp:59–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57
58template<typename T>
59void svdTest(const int M, const int N) {
60 SUPPORTED_TYPE_CHECK(T);
61 LAPACK_ENABLED_CHECK();
62
63 dtype ty = (dtype)dtype_traits<T>::af_type;
64
65 array A = randu(M, N, ty);
66
67 //! [ex_svd_reg]
68 array U, S, Vt;
69 af::svd(U, S, Vt, A);
70
71 const int MN = std::min(M, N);
72
73 array UU = U(span, seq(MN));
74 array SS = diag(S, 0, false).as(ty);
75 array VV = Vt(seq(MN), span);
76
77 array AA = matmul(UU, SS, VV);
78 //! [ex_svd_reg]
79
80#if defined(OS_MAC)
81 ASSERT_ARRAYS_NEAR(A, AA, 3E-3);
82#else
83 ASSERT_ARRAYS_NEAR(A, AA, 1E-3);
84#endif
85}
86
87template<typename T>
88void svdInPlaceTest(const int M, const int N) {

Callers

nothing calls this directly

Calls 7

randuFunction · 0.85
seqClass · 0.85
diagFunction · 0.85
asMethod · 0.80
svdClass · 0.70
minFunction · 0.70
matmulFunction · 0.50

Tested by

no test coverage detected