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(); \
57 lapack_int lda = internal::convert_index<lapack_int>(matrix.outerStride()), ldu, ldvt; \
58 lapack_int matrix_order = LAPACKE_COLROW; \
60 LAPACKE_TYPE *u, *vt, dummy; \
61 jobu = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \
62 jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \
64 ldu = internal::convert_index<lapack_int>(m_matrixU.outerStride()); \
65 u = (LAPACKE_TYPE*)m_matrixU.data(); \
71 lapack_int vt_rows = (m_computeFullV) ? internal::convert_index<lapack_int>(cols()) \
72 : (m_computeThinV) ? internal::convert_index<lapack_int>(diagSize()) \
75 localV.resize(vt_rows, cols()); \
76 ldvt = internal::convert_index<lapack_int>(localV.outerStride()); \
77 vt = (LAPACKE_TYPE*)localV.data(); \
82 Matrix<LAPACKE_RTYPE, Dynamic, Dynamic> superb; \
83 superb.resize(diagSize(), 1); \
86 lapack_int info = LAPACKE_##LAPACKE_PREFIX##gesvd( \
87 matrix_order, jobu, jobvt, internal::convert_index<lapack_int>(rows()), \
88 internal::convert_index<lapack_int>(cols()), (LAPACKE_TYPE*)m_temp.data(), lda, \
89 (LAPACKE_RTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \
91 if (info < 0 || !m_singularValues.allFinite()) { \
92 m_info = InvalidInput; \
93 } else if (info > 0) { \
94 m_info = NoConvergence; \
97 if (computeV()) m_matrixV = localV.adjoint(); \
101 m_isInitialized = true; \
105#define EIGEN_LAPACK_SVD_OPTIONS(OPTIONS) \
106 EIGEN_LAPACKE_SVD(double, double, double, d, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
107 EIGEN_LAPACKE_SVD(float, float, float, s, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
108 EIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
109 EIGEN_LAPACKE_SVD(scomplex, lapack_complex_float, float, c, ColMajor, LAPACK_COL_MAJOR, OPTIONS) \
111 EIGEN_LAPACKE_SVD(double, double, double, d, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
112 EIGEN_LAPACKE_SVD(float, float, float, s, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
113 EIGEN_LAPACKE_SVD(dcomplex, lapack_complex_double, double, z, RowMajor, LAPACK_ROW_MAJOR, OPTIONS) \
114 EIGEN_LAPACKE_SVD(scomplex, lapack_complex_float, float, c, RowMajor, LAPACK_ROW_MAJOR, OPTIONS)
116EIGEN_LAPACK_SVD_OPTIONS(0)
126#undef EIGEN_LAPACK_SVD_OPTIONS
128#undef EIGEN_LAPACKE_SVD
@ ComputeFullV
Definition Constants.h:398
@ ComputeThinV
Definition Constants.h:400
@ ComputeFullU
Definition Constants.h:394
@ ComputeThinU
Definition Constants.h:396