33 #ifndef EIGEN_JACOBISVD_LAPACKE_H
34 #define EIGEN_JACOBISVD_LAPACKE_H
42 #define EIGEN_LAPACKE_SVD(EIGTYPE, LAPACKE_TYPE, LAPACKE_RTYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW, OPTIONS) \
44 JacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, OPTIONS>& \
45 JacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, OPTIONS>::compute_impl(const Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>& matrix, \
46 unsigned int computationOptions) \
48 typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> MatrixType; \
51 allocate(matrix.rows(), matrix.cols(), computationOptions); \
54 m_nonzeroSingularValues = m_diagSize; \
56 lapack_int lda = internal::convert_index<lapack_int>(matrix.outerStride()), ldu, ldvt; \
57 lapack_int matrix_order = LAPACKE_COLROW; \
59 LAPACKE_TYPE *u, *vt, dummy; \
60 jobu = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \
61 jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \
63 ldu = internal::convert_index<lapack_int>(m_matrixU.outerStride()); \
64 u = (LAPACKE_TYPE*)m_matrixU.data(); \
65 } else { ldu=1; u=&dummy; }\
67 lapack_int vt_rows = (m_computeFullV) ? internal::convert_index<lapack_int>(m_cols) : (m_computeThinV) ? internal::convert_index<lapack_int>(m_diagSize) : 1; \
69 localV.resize(vt_rows, m_cols); \
70 ldvt = internal::convert_index<lapack_int>(localV.outerStride()); \
71 vt = (LAPACKE_TYPE*)localV.data(); \
72 } else { ldvt=1; vt=&dummy; }\
73 Matrix<LAPACKE_RTYPE, Dynamic, Dynamic> superb; superb.resize(m_diagSize, 1); \
74 MatrixType m_temp; m_temp = matrix; \
75 lapack_int info = LAPACKE_##LAPACKE_PREFIX##gesvd( matrix_order, jobu, jobvt, internal::convert_index<lapack_int>(m_rows), internal::convert_index<lapack_int>(m_cols), (LAPACKE_TYPE*)m_temp.data(), lda, (LAPACKE_RTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \
77 if (info < 0 || !m_singularValues.allFinite()) { \
78 m_info = InvalidInput; \
79 } else if (info > 0 ) { \
80 m_info = NoConvergence; \
83 if (computeV()) m_matrixV = localV.adjoint(); \
86 m_isInitialized = true; \
90 #define EIGEN_LAPACK_SVD_OPTIONS(OPTIONS) \
91 EIGEN_LAPACKE_SVD(double, double, double, d, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
92 EIGEN_LAPACKE_SVD(float, float, float , s, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
93 EIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
94 EIGEN_LAPACKE_SVD(scomplex, lapack_complex_float, float , c, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
96 EIGEN_LAPACKE_SVD(double, double, double, d, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
97 EIGEN_LAPACKE_SVD(float, float, float , s, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
98 EIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
99 EIGEN_LAPACKE_SVD(scomplex, lapack_complex_float, float , c, RowMajor, LAPACK_ROW_MAJOR, OPTIONS)
#define EIGEN_LAPACK_SVD_OPTIONS(OPTIONS)