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); \
54 m_nonzeroSingularValues = diagSize(); \
57 if (diagSize() == 0) { \
58 if (computeU()) m_matrixU.setIdentity(); \
59 if (computeV()) m_matrixV.setIdentity(); \
60 m_isInitialized = true; \
64 lapack_int ldu, ldvt; \
65 lapack_int matrix_order = LAPACKE_COLROW; \
67 LAPACKE_TYPE *u, *vt, dummy; \
68 jobu = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \
69 jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \
71 ldu = internal::convert_index<lapack_int>(m_matrixU.outerStride()); \
72 u = (LAPACKE_TYPE*)m_matrixU.data(); \
78 lapack_int vt_rows = (m_computeFullV) ? internal::convert_index<lapack_int>(cols()) \
79 : (m_computeThinV) ? internal::convert_index<lapack_int>(diagSize()) \
82 localV.resize(vt_rows, cols()); \
83 ldvt = internal::convert_index<lapack_int>(localV.outerStride()); \
84 vt = (LAPACKE_TYPE*)localV.data(); \
89 Matrix<LAPACKE_RTYPE, Dynamic, Dynamic> superb; \
90 superb.resize(diagSize(), 1); \
94 lapack_int lda = internal::convert_index<lapack_int>(m_temp.outerStride()); \
95 lapack_int info = LAPACKE_##LAPACKE_PREFIX##gesvd( \
96 matrix_order, jobu, jobvt, internal::convert_index<lapack_int>(rows()), \
97 internal::convert_index<lapack_int>(cols()), (LAPACKE_TYPE*)m_temp.data(), lda, \
98 (LAPACKE_RTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \
100 if (info < 0 || !m_singularValues.allFinite()) { \
101 m_info = InvalidInput; \
102 m_nonzeroSingularValues = 0; \
103 m_singularValues.setZero(); \
104 } else if (info > 0) { \
105 m_info = NoConvergence; \
108 if (computeV()) m_matrixV = localV.adjoint(); \
109 m_nonzeroSingularValues = internal::count_nonzero_singular_values(m_singularValues); \
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