diff --git a/Eigen/src/SVD/BDCSVD.h b/Eigen/src/SVD/BDCSVD.h index 85661a30d..6fab905e5 100644 --- a/Eigen/src/SVD/BDCSVD.h +++ b/Eigen/src/SVD/BDCSVD.h @@ -182,7 +182,9 @@ class BDCSVD : public SVDBase > { * \deprecated Will be removed in the next major Eigen version. Options should * be specified in the \a Options template parameter. */ - EIGEN_DEPRECATED BDCSVD(const MatrixType& matrix, unsigned int computationOptions) : m_algoswap(16), m_numIters(0) { + template + EIGEN_DEPRECATED BDCSVD(const MatrixBase& matrix, unsigned int computationOptions) + : m_algoswap(16), m_numIters(0) { internal::check_svd_options_assertions(computationOptions, matrix.rows(), matrix.cols()); compute_impl(matrix, computationOptions); } diff --git a/Eigen/src/SVD/BDCSVD_LAPACKE.h b/Eigen/src/SVD/BDCSVD_LAPACKE.h index 89d5cbd95..5d2b8c71a 100644 --- a/Eigen/src/SVD/BDCSVD_LAPACKE.h +++ b/Eigen/src/SVD/BDCSVD_LAPACKE.h @@ -58,7 +58,8 @@ class BDCSVD_LAPACKE : public BDCSVD { // construct this by moving from a parent object BDCSVD_LAPACKE(SVD&& svd) : SVD(std::move(svd)) {} - void compute_impl_lapacke(const MatrixType& matrix, unsigned int computationOptions) { + template + void compute_impl_lapacke(const MatrixBase& matrix, unsigned int computationOptions) { SVD::allocate(matrix.rows(), matrix.cols(), computationOptions); SVD::m_nonzeroSingularValues = SVD::m_diagSize; @@ -120,8 +121,8 @@ class BDCSVD_LAPACKE : public BDCSVD { } }; -template -BDCSVD& BDCSVD_wrapper(BDCSVD& svd, const MatrixType_& matrix, +template +BDCSVD& BDCSVD_wrapper(BDCSVD& svd, const MatrixBase& matrix, int computationOptions) { // we need to move to the wrapper type and back BDCSVD_LAPACKE tmpSvd(std::move(svd)); @@ -134,12 +135,13 @@ BDCSVD& BDCSVD_wrapper(BDCSVD& svd, } // end namespace internal -#define EIGEN_LAPACKE_SDD(EIGTYPE, EIGCOLROW, OPTIONS) \ - template <> \ - inline BDCSVD, OPTIONS>& \ - BDCSVD, OPTIONS>::compute_impl( \ - const Matrix& matrix, unsigned int computationOptions) { \ - return internal::lapacke_helpers::BDCSVD_wrapper(*this, matrix, computationOptions); \ +#define EIGEN_LAPACKE_SDD(EIGTYPE, EIGCOLROW, OPTIONS) \ + template <> \ + template \ + inline BDCSVD, OPTIONS>& \ + BDCSVD, OPTIONS>::compute_impl( \ + const MatrixBase& matrix, unsigned int computationOptions) { \ + return internal::lapacke_helpers::BDCSVD_wrapper(*this, matrix, computationOptions); \ } #define EIGEN_LAPACK_SDD_OPTIONS(OPTIONS) \ diff --git a/Eigen/src/SVD/JacobiSVD_LAPACKE.h b/Eigen/src/SVD/JacobiSVD_LAPACKE.h index df6a096d2..db2636690 100644 --- a/Eigen/src/SVD/JacobiSVD_LAPACKE.h +++ b/Eigen/src/SVD/JacobiSVD_LAPACKE.h @@ -40,65 +40,65 @@ namespace Eigen { /** \internal Specialization for the data types supported by LAPACKe */ -#define EIGEN_LAPACKE_SVD(EIGTYPE, LAPACKE_TYPE, LAPACKE_RTYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW, OPTIONS) \ - template <> \ - inline JacobiSVD, OPTIONS>& \ - JacobiSVD, OPTIONS>::compute_impl( \ - const Matrix& matrix, unsigned int computationOptions) { \ - typedef Matrix MatrixType; \ - /*typedef MatrixType::Scalar Scalar;*/ \ - /*typedef MatrixType::RealScalar RealScalar;*/ \ - allocate(matrix.rows(), matrix.cols(), computationOptions); \ - \ - /*const RealScalar precision = RealScalar(2) * NumTraits::epsilon();*/ \ - m_nonzeroSingularValues = diagSize(); \ - \ - lapack_int lda = internal::convert_index(matrix.outerStride()), ldu, ldvt; \ - lapack_int matrix_order = LAPACKE_COLROW; \ - char jobu, jobvt; \ - LAPACKE_TYPE *u, *vt, dummy; \ - jobu = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \ - jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \ - if (computeU()) { \ - ldu = internal::convert_index(m_matrixU.outerStride()); \ - u = (LAPACKE_TYPE*)m_matrixU.data(); \ - } else { \ - ldu = 1; \ - u = &dummy; \ - } \ - MatrixType localV; \ - lapack_int vt_rows = (m_computeFullV) ? internal::convert_index(cols()) \ - : (m_computeThinV) ? internal::convert_index(diagSize()) \ - : 1; \ - if (computeV()) { \ - localV.resize(vt_rows, cols()); \ - ldvt = internal::convert_index(localV.outerStride()); \ - vt = (LAPACKE_TYPE*)localV.data(); \ - } else { \ - ldvt = 1; \ - vt = &dummy; \ - } \ - Matrix superb; \ - superb.resize(diagSize(), 1); \ - MatrixType m_temp; \ - m_temp = matrix; \ - lapack_int info = LAPACKE_##LAPACKE_PREFIX##gesvd( \ - matrix_order, jobu, jobvt, internal::convert_index(rows()), \ - internal::convert_index(cols()), (LAPACKE_TYPE*)m_temp.data(), lda, \ - (LAPACKE_RTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \ - /* Check the result of the LAPACK call */ \ - if (info < 0 || !m_singularValues.allFinite()) { \ - m_info = InvalidInput; \ - } else if (info > 0) { \ - m_info = NoConvergence; \ - } else { \ - m_info = Success; \ - if (computeV()) m_matrixV = localV.adjoint(); \ - } \ - /* for(int i=0;i \ + template \ + inline JacobiSVD, OPTIONS>& \ + JacobiSVD, OPTIONS>::compute_impl( \ + const MatrixBase& matrix, unsigned int computationOptions) { \ + /*typedef MatrixType::Scalar Scalar;*/ \ + /*typedef MatrixType::RealScalar RealScalar;*/ \ + allocate(matrix.rows(), matrix.cols(), computationOptions); \ + \ + /*const RealScalar precision = RealScalar(2) * NumTraits::epsilon();*/ \ + m_nonzeroSingularValues = diagSize(); \ + \ + lapack_int lda = internal::convert_index(matrix.outerStride()), ldu, ldvt; \ + lapack_int matrix_order = LAPACKE_COLROW; \ + char jobu, jobvt; \ + LAPACKE_TYPE *u, *vt, dummy; \ + jobu = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \ + jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \ + if (computeU()) { \ + ldu = internal::convert_index(m_matrixU.outerStride()); \ + u = (LAPACKE_TYPE*)m_matrixU.data(); \ + } else { \ + ldu = 1; \ + u = &dummy; \ + } \ + MatrixType localV; \ + lapack_int vt_rows = (m_computeFullV) ? internal::convert_index(cols()) \ + : (m_computeThinV) ? internal::convert_index(diagSize()) \ + : 1; \ + if (computeV()) { \ + localV.resize(vt_rows, cols()); \ + ldvt = internal::convert_index(localV.outerStride()); \ + vt = (LAPACKE_TYPE*)localV.data(); \ + } else { \ + ldvt = 1; \ + vt = &dummy; \ + } \ + Matrix superb; \ + superb.resize(diagSize(), 1); \ + MatrixType m_temp; \ + m_temp = matrix; \ + lapack_int info = LAPACKE_##LAPACKE_PREFIX##gesvd( \ + matrix_order, jobu, jobvt, internal::convert_index(rows()), \ + internal::convert_index(cols()), (LAPACKE_TYPE*)m_temp.data(), lda, \ + (LAPACKE_RTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \ + /* Check the result of the LAPACK call */ \ + if (info < 0 || !m_singularValues.allFinite()) { \ + m_info = InvalidInput; \ + } else if (info > 0) { \ + m_info = NoConvergence; \ + } else { \ + m_info = Success; \ + if (computeV()) m_matrixV = localV.adjoint(); \ + } \ + /* for(int i=0;i