20 #include <tensor/tensor.h>
21 #include <tensor/tensor_lapack.h>
22 #include <tensor/linalg.h>
26 using namespace lapack;
31 bool accurate_svd = 0;
60 assert(A.
rank() == 2);
64 integer k = std::min(m, n);
65 integer lwork, ldu, lda, ldv, info;
68 double *a = tensor_pointer(A), *s = tensor_pointer(output), foo;
69 char jobv[1], jobu[1];
72 *U =
RTensor(m, economic? k : m);
73 u = tensor_pointer(*U);
74 jobu[0] = economic?
'S' :
'A';
82 (*VT) =
RTensor(economic? k : n, n);
83 v = tensor_pointer(*VT);
84 jobv[0] = economic?
'S' :
'A';
85 ldv = economic? k : n;
92 #ifdef TENSOR_USE_ACML
93 dgesvd(*jobu, *jobv, m, n, a, lda, s, u, ldu, v, ldv, &info);
97 F77NAME(dgesvd)(jobu, jobv, &m, &n, a, &lda, s, u, &ldu, v, &ldv,
100 work =
new double[lwork];
101 F77NAME(dgesvd)(jobu, jobv, &m, &n, a, &lda, s, u, &ldu, v, &ldv,
102 work, &lwork, &info);
int rank() const
Number of Tensor indices.
index columns() const
Query the size of 2nd index.
index rows() const
Query then size of 1st index.
Real Tensor with elements of type "double".
RTensor svd(RTensor A, RTensor *pU=0, RTensor *pVT=0, bool economic=0)
Singular value decomposition of a real matrix.