diff --git a/Eigen/src/Cholesky/LLT_LAPACKE.h b/Eigen/src/Cholesky/LLT_LAPACKE.h index 62bc679d4..a32ff2307 100644 --- a/Eigen/src/Cholesky/LLT_LAPACKE.h +++ b/Eigen/src/Cholesky/LLT_LAPACKE.h @@ -70,6 +70,7 @@ namespace lapacke_helpers { template struct lapacke_llt { + EIGEN_STATIC_ASSERT(((Mode == Lower) || (Mode == Upper)),MODE_MUST_BE_UPPER_OR_LOWER) template static Index blocked(MatrixType& m) { @@ -80,10 +81,11 @@ namespace lapacke_helpers { /* Set up parameters for ?potrf */ lapack_int size = to_lapack(m.rows()); lapack_int matrix_order = lapack_storage_of(m); + constexpr char uplo = Mode == Upper ? 'U' : 'L'; Scalar* a = &(m.coeffRef(0,0)); lapack_int lda = to_lapack(m.outerStride()); - lapack_int info = potrf(matrix_order, translate_mode, size, to_lapack(a), lda ); + lapack_int info = potrf(matrix_order, uplo, size, to_lapack(a), lda ); info = (info==0) ? -1 : info>0 ? info-1 : size; return info; } diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index ea2178fe3..8767e1f50 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -362,9 +362,9 @@ template class MatrixBase /////////// QR module /////////// inline const HouseholderQR householderQr() const; - inline const ColPivHouseholderQR colPivHouseholderQr() const; - inline const FullPivHouseholderQR fullPivHouseholderQr() const; - inline const CompleteOrthogonalDecomposition completeOrthogonalDecomposition() const; + template inline const ColPivHouseholderQR colPivHouseholderQr() const; + template inline const FullPivHouseholderQR fullPivHouseholderQr() const; + template inline const CompleteOrthogonalDecomposition completeOrthogonalDecomposition() const; /////////// Eigenvalues module /////////// diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 8f87c4a2c..c63ef3629 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -252,15 +252,22 @@ template class VectorwiseOp; template class Replicate; template class Reverse; +#if defined(EIGEN_USE_LAPACKE) +// Lapacke interface requires StorageIndex to be lapack_int +typedef lapack_int DefaultPermutationIndex; +#else +typedef int DefaultPermutationIndex; +#endif + template class FullPivLU; template class PartialPivLU; namespace internal { template struct inverse_impl; } template class HouseholderQR; -template class ColPivHouseholderQR; -template class FullPivHouseholderQR; -template class CompleteOrthogonalDecomposition; +template class ColPivHouseholderQR; +template class FullPivHouseholderQR; +template class CompleteOrthogonalDecomposition; template class SVDBase; template class JacobiSVD; template class BDCSVD; diff --git a/Eigen/src/QR/ColPivHouseholderQR.h b/Eigen/src/QR/ColPivHouseholderQR.h index c906997fc..53e386574 100644 --- a/Eigen/src/QR/ColPivHouseholderQR.h +++ b/Eigen/src/QR/ColPivHouseholderQR.h @@ -16,12 +16,12 @@ namespace Eigen { namespace internal { -template struct traits > +template struct traits > : traits { typedef MatrixXpr XprKind; typedef SolverStorage StorageKind; - typedef int StorageIndex; + typedef PermutationIndex_ PermutationIndex; enum { Flags = 0 }; }; @@ -50,31 +50,41 @@ template struct traits > * * \sa MatrixBase::colPivHouseholderQr() */ -template class ColPivHouseholderQR - : public SolverBase > +template class ColPivHouseholderQR + : public SolverBase > { public: typedef MatrixType_ MatrixType; typedef SolverBase Base; friend class SolverBase; - + typedef PermutationIndex_ PermutationIndex; EIGEN_GENERIC_PUBLIC_INTERFACE(ColPivHouseholderQR) + enum { MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }; typedef typename internal::plain_diag_type::type HCoeffsType; - typedef PermutationMatrix PermutationType; - typedef typename internal::plain_row_type::type IntRowVectorType; + typedef PermutationMatrix PermutationType; + typedef typename internal::plain_row_type::type IntRowVectorType; typedef typename internal::plain_row_type::type RowVectorType; typedef typename internal::plain_row_type::type RealRowVectorType; typedef HouseholderSequence> HouseholderSequenceType; typedef typename MatrixType::PlainObject PlainObject; - private: - - typedef typename PermutationType::StorageIndex PermIndexType; +private: + void init(Index rows, Index cols) { + Index diag = numext::mini(rows, cols); + m_hCoeffs = HCoeffsType(diag); + m_colsPermutation = PermutationType(cols); + m_colsTranspositions = IntRowVectorType(cols); + m_temp = RealRowVectorType(cols); + m_colNormsUpdated = RealRowVectorType(cols); + m_colNormsDirect = RealRowVectorType(cols); + m_isInitialized = false; + m_usePrescribedThreshold = false; + } public: @@ -101,16 +111,7 @@ template class ColPivHouseholderQR * according to the specified problem \a size. * \sa ColPivHouseholderQR() */ - ColPivHouseholderQR(Index rows, Index cols) - : m_qr(rows, cols), - m_hCoeffs((std::min)(rows,cols)), - m_colsPermutation(PermIndexType(cols)), - m_colsTranspositions(cols), - m_temp(cols), - m_colNormsUpdated(cols), - m_colNormsDirect(cols), - m_isInitialized(false), - m_usePrescribedThreshold(false) {} + ColPivHouseholderQR(Index rows, Index cols) : m_qr(rows, cols) { init(rows, cols); } /** \brief Constructs a QR factorization from a given matrix * @@ -124,18 +125,9 @@ template class ColPivHouseholderQR * * \sa compute() */ - template - explicit ColPivHouseholderQR(const EigenBase& matrix) - : m_qr(matrix.rows(), matrix.cols()), - m_hCoeffs((std::min)(matrix.rows(),matrix.cols())), - m_colsPermutation(PermIndexType(matrix.cols())), - m_colsTranspositions(matrix.cols()), - m_temp(matrix.cols()), - m_colNormsUpdated(matrix.cols()), - m_colNormsDirect(matrix.cols()), - m_isInitialized(false), - m_usePrescribedThreshold(false) - { + template + explicit ColPivHouseholderQR(const EigenBase& matrix) : m_qr(matrix.rows(), matrix.cols()) { + init(matrix.rows(), matrix.cols()); compute(matrix.derived()); } @@ -145,18 +137,9 @@ template class ColPivHouseholderQR * * \sa ColPivHouseholderQR(const EigenBase&) */ - template - explicit ColPivHouseholderQR(EigenBase& matrix) - : m_qr(matrix.derived()), - m_hCoeffs((std::min)(matrix.rows(),matrix.cols())), - m_colsPermutation(PermIndexType(matrix.cols())), - m_colsTranspositions(matrix.cols()), - m_temp(matrix.cols()), - m_colNormsUpdated(matrix.cols()), - m_colNormsDirect(matrix.cols()), - m_isInitialized(false), - m_usePrescribedThreshold(false) - { + template + explicit ColPivHouseholderQR(EigenBase& matrix) : m_qr(matrix.derived()) { + init(matrix.rows(), matrix.cols()); computeInPlace(); } @@ -441,7 +424,7 @@ template class ColPivHouseholderQR protected: - friend class CompleteOrthogonalDecomposition; + friend class CompleteOrthogonalDecomposition; EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar) @@ -460,8 +443,8 @@ template class ColPivHouseholderQR Index m_det_p; }; -template -typename MatrixType::Scalar ColPivHouseholderQR::determinant() const +template +typename MatrixType::Scalar ColPivHouseholderQR::determinant() const { eigen_assert(m_isInitialized && "HouseholderQR is not initialized."); eigen_assert(m_qr.rows() == m_qr.cols() && "You can't take the determinant of a non-square matrix!"); @@ -470,8 +453,8 @@ typename MatrixType::Scalar ColPivHouseholderQR::determinant() const return m_qr.diagonal().prod() * detQ * Scalar(m_det_p); } -template -typename MatrixType::RealScalar ColPivHouseholderQR::absDeterminant() const +template +typename MatrixType::RealScalar ColPivHouseholderQR::absDeterminant() const { using std::abs; eigen_assert(m_isInitialized && "ColPivHouseholderQR is not initialized."); @@ -479,8 +462,8 @@ typename MatrixType::RealScalar ColPivHouseholderQR::absDeterminant( return abs(m_qr.diagonal().prod()); } -template -typename MatrixType::RealScalar ColPivHouseholderQR::logAbsDeterminant() const +template +typename MatrixType::RealScalar ColPivHouseholderQR::logAbsDeterminant() const { eigen_assert(m_isInitialized && "ColPivHouseholderQR is not initialized."); eigen_assert(m_qr.rows() == m_qr.cols() && "You can't take the determinant of a non-square matrix!"); @@ -493,20 +476,20 @@ typename MatrixType::RealScalar ColPivHouseholderQR::logAbsDetermina * * \sa class ColPivHouseholderQR, ColPivHouseholderQR(const MatrixType&) */ -template +template template -ColPivHouseholderQR& ColPivHouseholderQR::compute(const EigenBase& matrix) +ColPivHouseholderQR& ColPivHouseholderQR::compute(const EigenBase& matrix) { m_qr = matrix.derived(); computeInPlace(); return *this; } -template -void ColPivHouseholderQR::computeInPlace() +template +void ColPivHouseholderQR::computeInPlace() { - // the column permutation is stored as int indices, so just to be sure: - eigen_assert(m_qr.cols()<=NumTraits::highest()); + + eigen_assert(m_qr.cols()<=NumTraits::highest()); using std::abs; @@ -549,7 +532,7 @@ void ColPivHouseholderQR::computeInPlace() m_nonzero_pivots = k; // apply the transposition to the columns - m_colsTranspositions.coeffRef(k) = biggest_col_index; + m_colsTranspositions.coeffRef(k) = static_cast(biggest_col_index); if(k != biggest_col_index) { m_qr.col(k).swap(m_qr.col(biggest_col_index)); std::swap(m_colNormsUpdated.coeffRef(k), m_colNormsUpdated.coeffRef(biggest_col_index)); @@ -595,18 +578,18 @@ void ColPivHouseholderQR::computeInPlace() } } - m_colsPermutation.setIdentity(PermIndexType(cols)); - for(PermIndexType k = 0; k < size/*m_nonzero_pivots*/; ++k) - m_colsPermutation.applyTranspositionOnTheRight(k, PermIndexType(m_colsTranspositions.coeff(k))); + m_colsPermutation.setIdentity(cols); + for(Index k = 0; k < size/*m_nonzero_pivots*/; ++k) + m_colsPermutation.applyTranspositionOnTheRight(k, static_cast(m_colsTranspositions.coeff(k))); m_det_p = (number_of_transpositions%2) ? -1 : 1; m_isInitialized = true; } #ifndef EIGEN_PARSED_BY_DOXYGEN -template +template template -void ColPivHouseholderQR::_solve_impl(const RhsType &rhs, DstType &dst) const +void ColPivHouseholderQR::_solve_impl(const RhsType &rhs, DstType &dst) const { const Index nonzero_pivots = nonzeroPivots(); @@ -628,9 +611,9 @@ void ColPivHouseholderQR::_solve_impl(const RhsType &rhs, DstType & for(Index i = nonzero_pivots; i < cols(); ++i) dst.row(m_colsPermutation.indices().coeff(i)).setZero(); } -template +template template -void ColPivHouseholderQR::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const +void ColPivHouseholderQR::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const { const Index nonzero_pivots = nonzeroPivots(); @@ -656,10 +639,10 @@ void ColPivHouseholderQR::_solve_impl_transposed(const RhsType &rhs namespace internal { -template -struct Assignment >, internal::assign_op::Scalar>, Dense2Dense> +template +struct Assignment >, internal::assign_op::Scalar>, Dense2Dense> { - typedef ColPivHouseholderQR QrType; + typedef ColPivHouseholderQR QrType; typedef Inverse SrcXprType; static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op &) { @@ -672,8 +655,8 @@ struct Assignment >, interna /** \returns the matrix Q as a sequence of householder transformations. * You can extract the meaningful part only by using: * \code qr.householderQ().setLength(qr.nonzeroPivots()) \endcode*/ -template -typename ColPivHouseholderQR::HouseholderSequenceType ColPivHouseholderQR +template +typename ColPivHouseholderQR::HouseholderSequenceType ColPivHouseholderQR ::householderQ() const { eigen_assert(m_isInitialized && "ColPivHouseholderQR is not initialized."); @@ -685,10 +668,11 @@ typename ColPivHouseholderQR::HouseholderSequenceType ColPivHousehol * \sa class ColPivHouseholderQR */ template -const ColPivHouseholderQR::PlainObject> +template +const ColPivHouseholderQR::PlainObject, PermutationIndexType> MatrixBase::colPivHouseholderQr() const { - return ColPivHouseholderQR(eval()); + return ColPivHouseholderQR(eval()); } } // end namespace Eigen diff --git a/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h b/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h index 7652d3130..6b8fb0384 100644 --- a/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +++ b/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h @@ -36,64 +36,117 @@ #include "./InternalHeaderCheck.h" -namespace Eigen { +namespace Eigen { -/** \internal Specialization for the data types supported by LAPACKe */ +#if defined(EIGEN_USE_LAPACKE) -#define EIGEN_LAPACKE_QR_COLPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW) \ -template<> template inline \ -ColPivHouseholderQR >& \ -ColPivHouseholderQR >::compute( \ - const EigenBase& matrix) \ -\ -{ \ - using std::abs; \ - typedef Matrix MatrixType; \ - typedef MatrixType::RealScalar RealScalar; \ - Index rows = matrix.rows();\ - Index cols = matrix.cols();\ -\ - m_qr = matrix;\ - Index size = m_qr.diagonalSize();\ - m_hCoeffs.resize(size);\ -\ - m_colsTranspositions.resize(cols);\ - /*Index number_of_transpositions = 0;*/ \ -\ - m_nonzero_pivots = 0; \ - m_maxpivot = RealScalar(0);\ - m_colsPermutation.resize(cols); \ - m_colsPermutation.indices().setZero(); \ -\ - lapack_int lda = internal::convert_index(m_qr.outerStride()); \ - lapack_int matrix_order = LAPACKE_COLROW; \ - LAPACKE_##LAPACKE_PREFIX##geqp3( matrix_order, internal::convert_index(rows), internal::convert_index(cols), \ - (LAPACKE_TYPE*)m_qr.data(), lda, (lapack_int*)m_colsPermutation.indices().data(), (LAPACKE_TYPE*)m_hCoeffs.data()); \ - m_isInitialized = true; \ - m_maxpivot=m_qr.diagonal().cwiseAbs().maxCoeff(); \ - m_hCoeffs.adjointInPlace(); \ - RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold(); \ - lapack_int *perm = m_colsPermutation.indices().data(); \ - for(Index i=0;i premultiplied_threshold);\ - } \ - for(Index i=0;i + inline lapack_int call_geqp3(int matrix_layout, lapack_int m, lapack_int n, Scalar* a, lapack_int lda, lapack_int* jpvt, Scalar* tau); + template<> + inline lapack_int call_geqp3(int matrix_layout, lapack_int m, lapack_int n, float* a, lapack_int lda, lapack_int* jpvt, float* tau) + { return LAPACKE_sgeqp3(matrix_layout, m, n, a, lda, jpvt, tau); } + template<> + inline lapack_int call_geqp3(int matrix_layout, lapack_int m, lapack_int n, double* a, lapack_int lda, lapack_int* jpvt, double* tau) + { return LAPACKE_dgeqp3(matrix_layout, m, n, a, lda, jpvt, tau); } + template<> + inline lapack_int call_geqp3(int matrix_layout, lapack_int m, lapack_int n, lapack_complex_float* a, lapack_int lda, lapack_int* jpvt, lapack_complex_float* tau) + { return LAPACKE_cgeqp3(matrix_layout, m, n, a, lda, jpvt, tau); } + template<> + inline lapack_int call_geqp3(int matrix_layout, lapack_int m, lapack_int n, lapack_complex_double* a, lapack_int lda, lapack_int* jpvt, lapack_complex_double* tau) + { return LAPACKE_zgeqp3(matrix_layout, m, n, a, lda, jpvt, tau); } -EIGEN_LAPACKE_QR_COLPIV(double, double, d, ColMajor, LAPACK_COL_MAJOR) -EIGEN_LAPACKE_QR_COLPIV(float, float, s, ColMajor, LAPACK_COL_MAJOR) -EIGEN_LAPACKE_QR_COLPIV(dcomplex, lapack_complex_double, z, ColMajor, LAPACK_COL_MAJOR) -EIGEN_LAPACKE_QR_COLPIV(scomplex, lapack_complex_float, c, ColMajor, LAPACK_COL_MAJOR) + template + struct ColPivHouseholderQR_LAPACKE_impl { + typedef typename MatrixType::Scalar Scalar; + typedef typename MatrixType::RealScalar RealScalar; + typedef typename internal::lapacke_helpers::translate_type_imp::type LapackeType; + static constexpr int LapackeStorage = MatrixType::IsRowMajor ? (LAPACK_ROW_MAJOR) : (LAPACK_COL_MAJOR); -EIGEN_LAPACKE_QR_COLPIV(double, double, d, RowMajor, LAPACK_ROW_MAJOR) -EIGEN_LAPACKE_QR_COLPIV(float, float, s, RowMajor, LAPACK_ROW_MAJOR) -EIGEN_LAPACKE_QR_COLPIV(dcomplex, lapack_complex_double, z, RowMajor, LAPACK_ROW_MAJOR) -EIGEN_LAPACKE_QR_COLPIV(scomplex, lapack_complex_float, c, RowMajor, LAPACK_ROW_MAJOR) + typedef typename internal::plain_diag_type::type HCoeffsType; + typedef PermutationMatrix PermutationType; -} // end namespace Eigen + static void run(MatrixType& qr, HCoeffsType& hCoeffs, PermutationType& colsPermutation, Index& nonzero_pivots, + RealScalar& maxpivot, bool usePrescribedThreshold, RealScalar prescribedThreshold, Index& det_p, + bool& isInitialized) { -#endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H + isInitialized = false; + hCoeffs.resize(qr.diagonalSize()); + nonzero_pivots = 0; + maxpivot = RealScalar(0); + colsPermutation.resize(qr.cols()); + colsPermutation.indices().setZero(); + + lapack_int rows = internal::lapacke_helpers::to_lapack(qr.rows()); + lapack_int cols = internal::lapacke_helpers::to_lapack(qr.cols()); + LapackeType* qr_data = (LapackeType*)(qr.data()); + lapack_int lda = internal::lapacke_helpers::to_lapack(qr.outerStride()); + lapack_int* perm_data = colsPermutation.indices().data(); + LapackeType* hCoeffs_data = (LapackeType*)(hCoeffs.data()); + + lapack_int info = call_geqp3(LapackeStorage, rows, cols, qr_data, lda, perm_data, hCoeffs_data); + if (info != 0) return; + + maxpivot = qr.diagonal().cwiseAbs().maxCoeff(); + hCoeffs.adjointInPlace(); + RealScalar defaultThreshold = NumTraits::epsilon() * RealScalar(qr.diagonalSize()); + RealScalar threshold = usePrescribedThreshold ? prescribedThreshold : defaultThreshold; + RealScalar premultiplied_threshold = maxpivot * threshold; + nonzero_pivots = (qr.diagonal().cwiseAbs().array() > premultiplied_threshold).count(); + colsPermutation.indices().array() -= 1; + det_p = colsPermutation.determinant(); + isInitialized = true; + }; + + static void init(Index rows, Index cols, HCoeffsType& hCoeffs, PermutationType& colsPermutation, + bool& usePrescribedThreshold, bool& isInitialized) { + + Index diag = numext::mini(rows, cols); + hCoeffs = HCoeffsType(diag); + colsPermutation = PermutationType(cols); + usePrescribedThreshold = false; + isInitialized = false; + } + }; + + #define COLPIVQR_LAPACKE_COMPUTEINPLACE(EIGTYPE) \ + template <> inline void ColPivHouseholderQR::computeInPlace() { \ + ColPivHouseholderQR_LAPACKE_impl::run(m_qr, m_hCoeffs, m_colsPermutation, m_nonzero_pivots, \ + m_maxpivot, m_usePrescribedThreshold, m_prescribedThreshold, \ + m_det_p, m_isInitialized); } \ + + #define COLPIVQR_LAPACKE_INIT(EIGTYPE) \ + template <> inline void ColPivHouseholderQR::init(Index rows, Index cols) { \ + ColPivHouseholderQR_LAPACKE_impl::init(rows, cols, m_hCoeffs, m_colsPermutation, m_isInitialized, \ + m_usePrescribedThreshold); } \ + + #define COLPIVQR_LAPACKE(EIGTYPE) \ + COLPIVQR_LAPACKE_COMPUTEINPLACE(EIGTYPE) \ + COLPIVQR_LAPACKE_INIT(EIGTYPE) \ + + typedef Matrix MatrixXfR; + typedef Matrix MatrixXdR; + typedef Matrix MatrixXcfR; + typedef Matrix MatrixXcdR; + + COLPIVQR_LAPACKE(MatrixXf) + COLPIVQR_LAPACKE(MatrixXd) + COLPIVQR_LAPACKE(MatrixXcf) + COLPIVQR_LAPACKE(MatrixXcd) + COLPIVQR_LAPACKE(MatrixXfR) + COLPIVQR_LAPACKE(MatrixXdR) + COLPIVQR_LAPACKE(MatrixXcfR) + COLPIVQR_LAPACKE(MatrixXcdR) + + COLPIVQR_LAPACKE(Ref) + COLPIVQR_LAPACKE(Ref) + COLPIVQR_LAPACKE(Ref) + COLPIVQR_LAPACKE(Ref) + COLPIVQR_LAPACKE(Ref) + COLPIVQR_LAPACKE(Ref) + COLPIVQR_LAPACKE(Ref) + COLPIVQR_LAPACKE(Ref) + +#endif +} // end namespace Eigen + +#endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H diff --git a/Eigen/src/QR/CompleteOrthogonalDecomposition.h b/Eigen/src/QR/CompleteOrthogonalDecomposition.h index 02583a2fd..171e60115 100644 --- a/Eigen/src/QR/CompleteOrthogonalDecomposition.h +++ b/Eigen/src/QR/CompleteOrthogonalDecomposition.h @@ -15,12 +15,12 @@ namespace Eigen { namespace internal { -template -struct traits > +template +struct traits > : traits { typedef MatrixXpr XprKind; typedef SolverStorage StorageKind; - typedef int StorageIndex; + typedef PermutationIndex_ PermutationIndex; enum { Flags = 0 }; }; @@ -49,8 +49,8 @@ struct traits > * * \sa MatrixBase::completeOrthogonalDecomposition() */ -template class CompleteOrthogonalDecomposition - : public SolverBase > +template class CompleteOrthogonalDecomposition + : public SolverBase > { public: typedef MatrixType_ MatrixType; @@ -58,14 +58,14 @@ template class CompleteOrthogonalDecomposition template friend struct internal::solve_assertion; - + typedef PermutationIndex_ PermutationIndex; EIGEN_GENERIC_PUBLIC_INTERFACE(CompleteOrthogonalDecomposition) enum { MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }; typedef typename internal::plain_diag_type::type HCoeffsType; - typedef PermutationMatrix + typedef PermutationMatrix PermutationType; typedef typename internal::plain_row_type::type IntRowVectorType; @@ -78,9 +78,6 @@ template class CompleteOrthogonalDecomposition HouseholderSequenceType; typedef typename MatrixType::PlainObject PlainObject; - private: - typedef typename PermutationType::Index PermIndexType; - public: /** * \brief Default Constructor. @@ -417,26 +414,26 @@ template class CompleteOrthogonalDecomposition template void applyZAdjointOnTheLeftInPlace(Rhs& rhs) const; - ColPivHouseholderQR m_cpqr; + ColPivHouseholderQR m_cpqr; HCoeffsType m_zCoeffs; RowVectorType m_temp; }; -template +template typename MatrixType::Scalar -CompleteOrthogonalDecomposition::determinant() const { +CompleteOrthogonalDecomposition::determinant() const { return m_cpqr.determinant(); } -template +template typename MatrixType::RealScalar -CompleteOrthogonalDecomposition::absDeterminant() const { +CompleteOrthogonalDecomposition::absDeterminant() const { return m_cpqr.absDeterminant(); } -template +template typename MatrixType::RealScalar -CompleteOrthogonalDecomposition::logAbsDeterminant() const { +CompleteOrthogonalDecomposition::logAbsDeterminant() const { return m_cpqr.logAbsDeterminant(); } @@ -447,11 +444,10 @@ CompleteOrthogonalDecomposition::logAbsDeterminant() const { * \sa class CompleteOrthogonalDecomposition, * CompleteOrthogonalDecomposition(const MatrixType&) */ -template -void CompleteOrthogonalDecomposition::computeInPlace() +template +void CompleteOrthogonalDecomposition::computeInPlace() { - // the column permutation is stored as int indices, so just to be sure: - eigen_assert(m_cpqr.cols() <= NumTraits::highest()); + eigen_assert(m_cpqr.cols() <= NumTraits::highest()); const Index rank = m_cpqr.rank(); const Index cols = m_cpqr.cols(); @@ -503,9 +499,9 @@ void CompleteOrthogonalDecomposition::computeInPlace() } } -template +template template -void CompleteOrthogonalDecomposition::applyZOnTheLeftInPlace( +void CompleteOrthogonalDecomposition::applyZOnTheLeftInPlace( Rhs& rhs) const { const Index cols = this->cols(); const Index nrhs = rhs.cols(); @@ -525,9 +521,9 @@ void CompleteOrthogonalDecomposition::applyZOnTheLeftInPlace( } } -template +template template -void CompleteOrthogonalDecomposition::applyZAdjointOnTheLeftInPlace( +void CompleteOrthogonalDecomposition::applyZAdjointOnTheLeftInPlace( Rhs& rhs) const { const Index cols = this->cols(); const Index nrhs = rhs.cols(); @@ -548,9 +544,9 @@ void CompleteOrthogonalDecomposition::applyZAdjointOnTheLeftInPlace( } #ifndef EIGEN_PARSED_BY_DOXYGEN -template +template template -void CompleteOrthogonalDecomposition::_solve_impl( +void CompleteOrthogonalDecomposition::_solve_impl( const RhsType& rhs, DstType& dst) const { const Index rank = this->rank(); if (rank == 0) { @@ -580,9 +576,9 @@ void CompleteOrthogonalDecomposition::_solve_impl( dst = colsPermutation() * dst; } -template +template template -void CompleteOrthogonalDecomposition::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const +void CompleteOrthogonalDecomposition::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const { const Index rank = this->rank(); @@ -611,17 +607,17 @@ void CompleteOrthogonalDecomposition::_solve_impl_transposed(const namespace internal { -template -struct traits > > +template +struct traits > > : traits::PlainObject> { enum { Flags = 0 }; }; -template -struct Assignment >, internal::assign_op::Scalar>, Dense2Dense> +template +struct Assignment >, internal::assign_op::Scalar>, Dense2Dense> { - typedef CompleteOrthogonalDecomposition CodType; + typedef CompleteOrthogonalDecomposition CodType; typedef Inverse SrcXprType; static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op &) { @@ -633,9 +629,9 @@ struct Assignment -typename CompleteOrthogonalDecomposition::HouseholderSequenceType -CompleteOrthogonalDecomposition::householderQ() const { +template +typename CompleteOrthogonalDecomposition::HouseholderSequenceType +CompleteOrthogonalDecomposition::householderQ() const { return m_cpqr.householderQ(); } @@ -644,7 +640,8 @@ CompleteOrthogonalDecomposition::householderQ() const { * \sa class CompleteOrthogonalDecomposition */ template -const CompleteOrthogonalDecomposition::PlainObject> +template +const CompleteOrthogonalDecomposition::PlainObject, PermutationIndex> MatrixBase::completeOrthogonalDecomposition() const { return CompleteOrthogonalDecomposition(eval()); } diff --git a/Eigen/src/QR/FullPivHouseholderQR.h b/Eigen/src/QR/FullPivHouseholderQR.h index ec7e19b55..588f917fd 100644 --- a/Eigen/src/QR/FullPivHouseholderQR.h +++ b/Eigen/src/QR/FullPivHouseholderQR.h @@ -17,19 +17,19 @@ namespace Eigen { namespace internal { -template struct traits > +template struct traits > : traits { typedef MatrixXpr XprKind; typedef SolverStorage StorageKind; - typedef int StorageIndex; + typedef PermutationIndex_ PermutationIndex; enum { Flags = 0 }; }; -template struct FullPivHouseholderQRMatrixQReturnType; +template struct FullPivHouseholderQRMatrixQReturnType; -template -struct traits > +template +struct traits > { typedef typename MatrixType::PlainObject ReturnType; }; @@ -59,26 +59,27 @@ struct traits > * * \sa MatrixBase::fullPivHouseholderQr() */ -template class FullPivHouseholderQR - : public SolverBase > +template class FullPivHouseholderQR + : public SolverBase > { public: typedef MatrixType_ MatrixType; typedef SolverBase Base; friend class SolverBase; - + typedef PermutationIndex_ PermutationIndex; EIGEN_GENERIC_PUBLIC_INTERFACE(FullPivHouseholderQR) + enum { MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }; - typedef internal::FullPivHouseholderQRMatrixQReturnType MatrixQReturnType; + typedef internal::FullPivHouseholderQRMatrixQReturnType MatrixQReturnType; typedef typename internal::plain_diag_type::type HCoeffsType; - typedef Matrix IntDiagSizeVectorType; - typedef PermutationMatrix PermutationType; + typedef PermutationMatrix PermutationType; typedef typename internal::plain_row_type::type RowVectorType; typedef typename internal::plain_col_type::type ColVectorType; typedef typename MatrixType::PlainObject PlainObject; @@ -437,8 +438,8 @@ template class FullPivHouseholderQR Index m_det_p; }; -template -typename MatrixType::Scalar FullPivHouseholderQR::determinant() const +template +typename MatrixType::Scalar FullPivHouseholderQR::determinant() const { eigen_assert(m_isInitialized && "HouseholderQR is not initialized."); eigen_assert(m_qr.rows() == m_qr.cols() && "You can't take the determinant of a non-square matrix!"); @@ -447,8 +448,8 @@ typename MatrixType::Scalar FullPivHouseholderQR::determinant() cons return m_qr.diagonal().prod() * detQ * Scalar(m_det_p); } -template -typename MatrixType::RealScalar FullPivHouseholderQR::absDeterminant() const +template +typename MatrixType::RealScalar FullPivHouseholderQR::absDeterminant() const { using std::abs; eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized."); @@ -456,8 +457,8 @@ typename MatrixType::RealScalar FullPivHouseholderQR::absDeterminant return abs(m_qr.diagonal().prod()); } -template -typename MatrixType::RealScalar FullPivHouseholderQR::logAbsDeterminant() const +template +typename MatrixType::RealScalar FullPivHouseholderQR::logAbsDeterminant() const { eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized."); eigen_assert(m_qr.rows() == m_qr.cols() && "You can't take the determinant of a non-square matrix!"); @@ -470,18 +471,19 @@ typename MatrixType::RealScalar FullPivHouseholderQR::logAbsDetermin * * \sa class FullPivHouseholderQR, FullPivHouseholderQR(const MatrixType&) */ -template +template template -FullPivHouseholderQR& FullPivHouseholderQR::compute(const EigenBase& matrix) +FullPivHouseholderQR& FullPivHouseholderQR::compute(const EigenBase& matrix) { m_qr = matrix.derived(); computeInPlace(); return *this; } -template -void FullPivHouseholderQR::computeInPlace() +template +void FullPivHouseholderQR::computeInPlace() { + eigen_assert(m_qr.cols() <= NumTraits::highest()); using std::abs; Index rows = m_qr.rows(); Index cols = m_qr.cols(); @@ -523,15 +525,15 @@ void FullPivHouseholderQR::computeInPlace() m_nonzero_pivots = k; for(Index i = k; i < size; i++) { - m_rows_transpositions.coeffRef(i) = internal::convert_index(i); - m_cols_transpositions.coeffRef(i) = internal::convert_index(i); + m_rows_transpositions.coeffRef(i) = internal::convert_index(i); + m_cols_transpositions.coeffRef(i) = internal::convert_index(i); m_hCoeffs.coeffRef(i) = Scalar(0); } break; } - m_rows_transpositions.coeffRef(k) = internal::convert_index(row_of_biggest_in_corner); - m_cols_transpositions.coeffRef(k) = internal::convert_index(col_of_biggest_in_corner); + m_rows_transpositions.coeffRef(k) = internal::convert_index(row_of_biggest_in_corner); + m_cols_transpositions.coeffRef(k) = internal::convert_index(col_of_biggest_in_corner); if(k != row_of_biggest_in_corner) { m_qr.row(k).tail(cols-k).swap(m_qr.row(row_of_biggest_in_corner).tail(cols-k)); ++number_of_transpositions; @@ -561,9 +563,9 @@ void FullPivHouseholderQR::computeInPlace() } #ifndef EIGEN_PARSED_BY_DOXYGEN -template +template template -void FullPivHouseholderQR::_solve_impl(const RhsType &rhs, DstType &dst) const +void FullPivHouseholderQR::_solve_impl(const RhsType &rhs, DstType &dst) const { const Index l_rank = rank(); @@ -595,9 +597,9 @@ void FullPivHouseholderQR::_solve_impl(const RhsType &rhs, DstType for(Index i = l_rank; i < cols(); ++i) dst.row(m_cols_permutation.indices().coeff(i)).setZero(); } -template +template template -void FullPivHouseholderQR::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const +void FullPivHouseholderQR::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const { const Index l_rank = rank(); @@ -634,10 +636,10 @@ void FullPivHouseholderQR::_solve_impl_transposed(const RhsType &rh namespace internal { -template -struct Assignment >, internal::assign_op::Scalar>, Dense2Dense> +template +struct Assignment >, internal::assign_op::Scalar>, Dense2Dense> { - typedef FullPivHouseholderQR QrType; + typedef FullPivHouseholderQR QrType; typedef Inverse SrcXprType; static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op &) { @@ -651,11 +653,11 @@ struct Assignment >, intern * * \tparam MatrixType type of underlying dense matrix */ -template struct FullPivHouseholderQRMatrixQReturnType - : public ReturnByValue > +template struct FullPivHouseholderQRMatrixQReturnType + : public ReturnByValue > { public: - typedef typename FullPivHouseholderQR::IntDiagSizeVectorType IntDiagSizeVectorType; + typedef typename FullPivHouseholderQR::IntDiagSizeVectorType IntDiagSizeVectorType; typedef typename internal::plain_diag_type::type HCoeffsType; typedef Matrix WorkVectorType; @@ -712,8 +714,8 @@ protected: } // end namespace internal -template -inline typename FullPivHouseholderQR::MatrixQReturnType FullPivHouseholderQR::matrixQ() const +template +inline typename FullPivHouseholderQR::MatrixQReturnType FullPivHouseholderQR::matrixQ() const { eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized."); return MatrixQReturnType(m_qr, m_hCoeffs, m_rows_transpositions); @@ -724,10 +726,11 @@ inline typename FullPivHouseholderQR::MatrixQReturnType FullPivHouse * \sa class FullPivHouseholderQR */ template -const FullPivHouseholderQR::PlainObject> +template +const FullPivHouseholderQR::PlainObject, PermutationIndex> MatrixBase::fullPivHouseholderQr() const { - return FullPivHouseholderQR(eval()); + return FullPivHouseholderQR(eval()); } } // end namespace Eigen diff --git a/Eigen/src/misc/lapacke_helpers.h b/Eigen/src/misc/lapacke_helpers.h index b6ad6e89e..0703c2b9b 100644 --- a/Eigen/src/misc/lapacke_helpers.h +++ b/Eigen/src/misc/lapacke_helpers.h @@ -76,12 +76,6 @@ EIGEN_ALWAYS_INLINE EIGEN_CONSTEXPR lapack_int lapack_storage_of(const EigenBase return Derived::IsRowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; } -/// translate UpLo type to the corresponding letter code -template char translate_mode; -template<> constexpr char translate_mode = 'L'; -template<> constexpr char translate_mode = 'U'; - - // --------------------------------------------------------------------------------------------------------------------- // Automatic generation of low-level wrappers // --------------------------------------------------------------------------------------------------------------------- diff --git a/test/qr_colpivoting.cpp b/test/qr_colpivoting.cpp index 4185f514e..27ef33ab9 100644 --- a/test/qr_colpivoting.cpp +++ b/test/qr_colpivoting.cpp @@ -13,9 +13,8 @@ #include #include "solverbase.h" -template +template void cod() { - STATIC_CHECK(( internal::is_same::StorageIndex,int>::value )); Index rows = internal::random(2, EIGEN_TEST_MAX_SIZE); Index cols = internal::random(2, EIGEN_TEST_MAX_SIZE); @@ -28,7 +27,7 @@ void cod() { MatrixQType; MatrixType matrix; createRandomPIMatrixOfRank(rank, rows, cols, matrix); - CompleteOrthogonalDecomposition cod(matrix); + CompleteOrthogonalDecomposition cod(matrix); VERIFY(rank == cod.rank()); VERIFY(cols - cod.rank() == cod.dimensionOfKernel()); VERIFY(!cod.isInjective()); @@ -63,14 +62,14 @@ void cod() { VERIFY_IS_APPROX(cod_solution, pinv * rhs); } -template +template void cod_fixedsize() { enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime }; typedef typename MatrixType::Scalar Scalar; - typedef CompleteOrthogonalDecomposition > COD; + typedef CompleteOrthogonalDecomposition, PermutationIndex> COD; int rank = internal::random(1, (std::min)(int(Rows), int(Cols)) - 1); Matrix matrix; createRandomPIMatrixOfRank(rank, Rows, Cols, matrix); @@ -96,12 +95,10 @@ void cod_fixedsize() { VERIFY_IS_APPROX(cod_solution, pinv * rhs); } -template void qr() +template void qr() { using std::sqrt; - STATIC_CHECK(( internal::is_same::StorageIndex,int>::value )); - Index rows = internal::random(2,EIGEN_TEST_MAX_SIZE), cols = internal::random(2,EIGEN_TEST_MAX_SIZE), cols2 = internal::random(2,EIGEN_TEST_MAX_SIZE); Index rank = internal::random(1, (std::min)(rows, cols)-1); @@ -110,7 +107,7 @@ template void qr() typedef Matrix MatrixQType; MatrixType m1; createRandomPIMatrixOfRank(rank,rows,cols,m1); - ColPivHouseholderQR qr(m1); + ColPivHouseholderQR qr(m1); VERIFY_IS_EQUAL(rank, qr.rank()); VERIFY_IS_EQUAL(cols - qr.rank(), qr.dimensionOfKernel()); VERIFY(!qr.isInjective()); @@ -158,7 +155,7 @@ template void qr() } } -template void qr_fixedsize() +template void qr_fixedsize() { using std::sqrt; using std::abs; @@ -168,7 +165,7 @@ template void qr_fixedsize() int rank = internal::random(1, (std::min)(int(Rows), int(Cols))-1); Matrix m1; createRandomPIMatrixOfRank(rank,Rows,Cols,m1); - ColPivHouseholderQR > qr(m1); + ColPivHouseholderQR, PermutationIndex> qr(m1); VERIFY_IS_EQUAL(rank, qr.rank()); VERIFY_IS_EQUAL(Cols - qr.rank(), qr.dimensionOfKernel()); VERIFY_IS_EQUAL(qr.isInjective(), (rank == Rows)); @@ -207,7 +204,7 @@ template void qr_fixedsize() // for rank-revealing QR. See // http://www.netlib.org/lapack/lawnspdf/lawn176.pdf // page 3 for more detail. -template void qr_kahan_matrix() +template void qr_kahan_matrix() { using std::sqrt; using std::abs; @@ -227,7 +224,7 @@ template void qr_kahan_matrix() pow_s_i *= s; } m1 = (m1 + m1.transpose()).eval(); - ColPivHouseholderQR qr(m1); + ColPivHouseholderQR qr(m1); MatrixType r = qr.matrixQR().template triangularView(); RealScalar threshold = @@ -247,7 +244,7 @@ template void qr_kahan_matrix() } } -template void qr_invertible() +template void qr_invertible() { using std::log; using std::abs; @@ -266,7 +263,7 @@ template void qr_invertible() m1 += a * a.adjoint(); } - ColPivHouseholderQR qr(m1); + ColPivHouseholderQR qr(m1); check_solverbase(m1, qr, size, size, size); @@ -283,11 +280,11 @@ template void qr_invertible() VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant()); } -template void qr_verify_assert() +template void qr_verify_assert() { MatrixType tmp; - ColPivHouseholderQR qr; + ColPivHouseholderQR qr; VERIFY_RAISES_ASSERT(qr.matrixQR()) VERIFY_RAISES_ASSERT(qr.solve(tmp)) VERIFY_RAISES_ASSERT(qr.transpose().solve(tmp)) @@ -303,11 +300,11 @@ template void qr_verify_assert() VERIFY_RAISES_ASSERT(qr.logAbsDeterminant()) } -template void cod_verify_assert() +template void cod_verify_assert() { MatrixType tmp; - CompleteOrthogonalDecomposition cod; + CompleteOrthogonalDecomposition cod; VERIFY_RAISES_ASSERT(cod.matrixQTZ()) VERIFY_RAISES_ASSERT(cod.solve(tmp)) VERIFY_RAISES_ASSERT(cod.transpose().solve(tmp)) @@ -323,50 +320,58 @@ template void cod_verify_assert() VERIFY_RAISES_ASSERT(cod.logAbsDeterminant()) } + + EIGEN_DECLARE_TEST(qr_colpivoting) { + #if defined(EIGEN_USE_LAPACKE) + typedef lapack_int PermutationIndex; + #else + typedef int PermutationIndex; + #endif + for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( qr() ); - CALL_SUBTEST_2( qr() ); - CALL_SUBTEST_3( qr() ); - CALL_SUBTEST_4(( qr_fixedsize, 4 >() )); - CALL_SUBTEST_5(( qr_fixedsize, 3 >() )); - CALL_SUBTEST_5(( qr_fixedsize, 1 >() )); + CALL_SUBTEST_1( (qr)() ); + CALL_SUBTEST_2( (qr)() ); + CALL_SUBTEST_3( (qr)() ); + CALL_SUBTEST_4(( (qr_fixedsize, PermutationIndex, 4>)() )); + CALL_SUBTEST_5(( (qr_fixedsize, PermutationIndex, 3>)() )); + CALL_SUBTEST_5(( (qr_fixedsize, PermutationIndex, 1>)() )); } for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( cod() ); - CALL_SUBTEST_2( cod() ); - CALL_SUBTEST_3( cod() ); - CALL_SUBTEST_4(( cod_fixedsize, 4 >() )); - CALL_SUBTEST_5(( cod_fixedsize, 3 >() )); - CALL_SUBTEST_5(( cod_fixedsize, 1 >() )); + CALL_SUBTEST_1( (cod)() ); + CALL_SUBTEST_2( (cod)() ); + CALL_SUBTEST_3( (cod)() ); + CALL_SUBTEST_4(( (cod_fixedsize, PermutationIndex, 4>)() )); + CALL_SUBTEST_5(( (cod_fixedsize, PermutationIndex, 3>)() )); + CALL_SUBTEST_5(( (cod_fixedsize, PermutationIndex, 1>)() )); } for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( qr_invertible() ); - CALL_SUBTEST_2( qr_invertible() ); - CALL_SUBTEST_6( qr_invertible() ); - CALL_SUBTEST_3( qr_invertible() ); + CALL_SUBTEST_1( (qr_invertible)() ); + CALL_SUBTEST_2( (qr_invertible)() ); + CALL_SUBTEST_6( (qr_invertible)() ); + CALL_SUBTEST_3( (qr_invertible)() ); } - CALL_SUBTEST_7(qr_verify_assert()); - CALL_SUBTEST_8(qr_verify_assert()); - CALL_SUBTEST_1(qr_verify_assert()); - CALL_SUBTEST_2(qr_verify_assert()); - CALL_SUBTEST_6(qr_verify_assert()); - CALL_SUBTEST_3(qr_verify_assert()); + CALL_SUBTEST_7( (qr_verify_assert) ()); + CALL_SUBTEST_8( (qr_verify_assert)()); + CALL_SUBTEST_1( (qr_verify_assert)()); + CALL_SUBTEST_2( (qr_verify_assert)()); + CALL_SUBTEST_6( (qr_verify_assert)()); + CALL_SUBTEST_3( (qr_verify_assert)()); - CALL_SUBTEST_7(cod_verify_assert()); - CALL_SUBTEST_8(cod_verify_assert()); - CALL_SUBTEST_1(cod_verify_assert()); - CALL_SUBTEST_2(cod_verify_assert()); - CALL_SUBTEST_6(cod_verify_assert()); - CALL_SUBTEST_3(cod_verify_assert()); + CALL_SUBTEST_7( (cod_verify_assert)()); + CALL_SUBTEST_8( (cod_verify_assert)()); + CALL_SUBTEST_1( (cod_verify_assert)()); + CALL_SUBTEST_2( (cod_verify_assert)()); + CALL_SUBTEST_6( (cod_verify_assert)()); + CALL_SUBTEST_3( (cod_verify_assert)()); // Test problem size constructors - CALL_SUBTEST_9(ColPivHouseholderQR(10, 20)); + CALL_SUBTEST_9((ColPivHouseholderQR(10, 20))); - CALL_SUBTEST_1( qr_kahan_matrix() ); - CALL_SUBTEST_2( qr_kahan_matrix() ); + CALL_SUBTEST_1( (qr_kahan_matrix)() ); + CALL_SUBTEST_2( (qr_kahan_matrix)() ); } diff --git a/test/qr_fullpivoting.cpp b/test/qr_fullpivoting.cpp index cca9a8c1e..c0f44ae2e 100644 --- a/test/qr_fullpivoting.cpp +++ b/test/qr_fullpivoting.cpp @@ -12,9 +12,8 @@ #include #include "solverbase.h" -template void qr() +template void qr() { - STATIC_CHECK(( internal::is_same::StorageIndex,int>::value )); static const int Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime; Index max_size = EIGEN_TEST_MAX_SIZE; @@ -28,7 +27,7 @@ template void qr() typedef Matrix MatrixQType; MatrixType m1; createRandomPIMatrixOfRank(rank,rows,cols,m1); - FullPivHouseholderQR qr(m1); + FullPivHouseholderQR qr(m1); VERIFY_IS_EQUAL(rank, qr.rank()); VERIFY_IS_EQUAL(cols - qr.rank(), qr.dimensionOfKernel()); VERIFY(!qr.isInjective()); @@ -67,7 +66,7 @@ template void qr() } } -template void qr_invertible() +template void qr_invertible() { using std::log; using std::abs; @@ -88,7 +87,7 @@ template void qr_invertible() m1 += a * a.adjoint(); } - FullPivHouseholderQR qr(m1); + FullPivHouseholderQR qr(m1); VERIFY(qr.isInjective()); VERIFY(qr.isInvertible()); VERIFY(qr.isSurjective()); @@ -108,11 +107,11 @@ template void qr_invertible() VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant()); } -template void qr_verify_assert() +template void qr_verify_assert() { MatrixType tmp; - FullPivHouseholderQR qr; + FullPivHouseholderQR qr; VERIFY_RAISES_ASSERT(qr.matrixQR()) VERIFY_RAISES_ASSERT(qr.solve(tmp)) VERIFY_RAISES_ASSERT(qr.transpose().solve(tmp)) @@ -130,33 +129,35 @@ template void qr_verify_assert() EIGEN_DECLARE_TEST(qr_fullpivoting) { + typedef int PermutationIndex; + for(int i = 0; i < 1; i++) { - CALL_SUBTEST_5( qr() ); - CALL_SUBTEST_6( qr() ); - CALL_SUBTEST_8( qr() ); - CALL_SUBTEST_1( qr() ); - CALL_SUBTEST_2( qr() ); - CALL_SUBTEST_3( qr() ); + CALL_SUBTEST_5( (qr()) ); + CALL_SUBTEST_6( (qr()) ); + CALL_SUBTEST_8( (qr()) ); + CALL_SUBTEST_1( (qr()) ); + CALL_SUBTEST_2( (qr()) ); + CALL_SUBTEST_3( (qr()) ); } for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1( qr_invertible() ); - CALL_SUBTEST_2( qr_invertible() ); - CALL_SUBTEST_4( qr_invertible() ); - CALL_SUBTEST_3( qr_invertible() ); + CALL_SUBTEST_1( (qr_invertible()) ); + CALL_SUBTEST_2( (qr_invertible()) ); + CALL_SUBTEST_4( (qr_invertible()) ); + CALL_SUBTEST_3( (qr_invertible()) ); } - CALL_SUBTEST_5(qr_verify_assert()); - CALL_SUBTEST_6(qr_verify_assert()); - CALL_SUBTEST_1(qr_verify_assert()); - CALL_SUBTEST_2(qr_verify_assert()); - CALL_SUBTEST_4(qr_verify_assert()); - CALL_SUBTEST_3(qr_verify_assert()); + CALL_SUBTEST_5( (qr_verify_assert()) ); + CALL_SUBTEST_6( (qr_verify_assert()) ); + CALL_SUBTEST_1( (qr_verify_assert()) ); + CALL_SUBTEST_2( (qr_verify_assert()) ); + CALL_SUBTEST_4( (qr_verify_assert()) ); + CALL_SUBTEST_3( (qr_verify_assert()) ); // Test problem size constructors - CALL_SUBTEST_7(FullPivHouseholderQR(10, 20)); - CALL_SUBTEST_7((FullPivHouseholderQR >(10,20))); - CALL_SUBTEST_7((FullPivHouseholderQR >(Matrix::Random()))); - CALL_SUBTEST_7((FullPivHouseholderQR >(20,10))); - CALL_SUBTEST_7((FullPivHouseholderQR >(Matrix::Random()))); + CALL_SUBTEST_7( (FullPivHouseholderQR(10, 20))); + CALL_SUBTEST_7( (FullPivHouseholderQR, PermutationIndex>(10, 20))); + CALL_SUBTEST_7( (FullPivHouseholderQR, PermutationIndex>(Matrix::Random()))); + CALL_SUBTEST_7( (FullPivHouseholderQR, PermutationIndex>(20, 10))); + CALL_SUBTEST_7( (FullPivHouseholderQR, PermutationIndex>(Matrix::Random()))); }