34#ifndef EIGEN_JACOBISVD_LAPACKE_H
35#define EIGEN_JACOBISVD_LAPACKE_H
38#include "./InternalHeaderCheck.h"
44#define EIGEN_LAPACKE_SVD(EIGTYPE, LAPACKE_TYPE, LAPACKE_RTYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW, OPTIONS) \
46 template <typename Derived> \
47 inline JacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, OPTIONS>& \
48 JacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, OPTIONS>::compute_impl( \
49 const MatrixBase<Derived>& matrix, unsigned int computationOptions) { \
52 allocate(matrix.rows(), matrix.cols(), computationOptions); \
55 m_nonzeroSingularValues = diagSize(); \
58 if (diagSize() == 0) { \
59 if (computeU()) m_matrixU.setIdentity(); \
60 if (computeV()) m_matrixV.setIdentity(); \
61 m_isInitialized = true; \
65 lapack_int ldu, ldvt; \
66 lapack_int matrix_order = LAPACKE_COLROW; \
68 LAPACKE_TYPE *u, *vt, dummy; \
69 jobu = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \
70 jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \
72 ldu = internal::convert_index<lapack_int>(m_matrixU.outerStride()); \
73 u = (LAPACKE_TYPE*)m_matrixU.data(); \
79 lapack_int vt_rows = (m_computeFullV) ? internal::convert_index<lapack_int>(cols()) \
80 : (m_computeThinV) ? internal::convert_index<lapack_int>(diagSize()) \
83 localV.resize(vt_rows, cols()); \
84 ldvt = internal::convert_index<lapack_int>(localV.outerStride()); \
85 vt = (LAPACKE_TYPE*)localV.data(); \
90 Matrix<LAPACKE_RTYPE, Dynamic, Dynamic> superb; \
91 superb.resize(diagSize(), 1); \
95 lapack_int lda = internal::convert_index<lapack_int>(m_temp.outerStride()); \
96 lapack_int info = LAPACKE_##LAPACKE_PREFIX##gesvd( \
97 matrix_order, jobu, jobvt, internal::convert_index<lapack_int>(rows()), \
98 internal::convert_index<lapack_int>(cols()), (LAPACKE_TYPE*)m_temp.data(), lda, \
99 (LAPACKE_RTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \
101 if (info < 0 || !m_singularValues.allFinite()) { \
102 m_info = InvalidInput; \
103 } else if (info > 0) { \
104 m_info = NoConvergence; \
107 if (computeV()) m_matrixV = localV.adjoint(); \
111 m_isInitialized = true; \
115#define EIGEN_LAPACK_SVD_OPTIONS(OPTIONS) \
116 EIGEN_LAPACKE_SVD(double, double, double, d, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
117 EIGEN_LAPACKE_SVD(float, float, float, s, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
118 EIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
119 EIGEN_LAPACKE_SVD(scomplex, lapack_complex_float, float, c, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
121 EIGEN_LAPACKE_SVD(double, double, double, d, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
122 EIGEN_LAPACKE_SVD(float, float, float, s, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
123 EIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
124 EIGEN_LAPACKE_SVD(scomplex, lapack_complex_float, float, c, RowMajor, LAPACK_ROW_MAJOR, OPTIONS)
126EIGEN_LAPACK_SVD_OPTIONS(0)
136#undef EIGEN_LAPACK_SVD_OPTIONS
138#undef EIGEN_LAPACKE_SVD
@ ComputeFullV
Definition Constants.h:398
@ ComputeThinV
Definition Constants.h:400
@ ComputeFullU
Definition Constants.h:394
@ ComputeThinU
Definition Constants.h:396