diff options
author | David Tellenbach <david.tellenbach@me.com> | 2021-03-05 13:16:43 +0100 |
---|---|---|
committer | David Tellenbach <david.tellenbach@me.com> | 2021-03-05 13:16:43 +0100 |
commit | 5f0b4a4010af4cbf6161a0d1a03a747addc44a5d (patch) | |
tree | 23356aec10fb951fb51adf970a810e7ae18cf940 /Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h | |
parent | 6cbb3038ac48cb5fe17eba4dfbf26e3e798041f1 (diff) |
Revert "Adds EIGEN_CONSTEXPR and EIGEN_NOEXCEPT to rows(), cols(), innerStride(), outerStride(), and size()"
This reverts commit 6cbb3038ac48cb5fe17eba4dfbf26e3e798041f1 because it
breaks clang-10 builds on x86 and aarch64 when C++11 is enabled.
Diffstat (limited to 'Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h')
-rw-r--r-- | Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h b/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h index 7803fd817..e5d0308ec 100644 --- a/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +++ b/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h @@ -14,8 +14,8 @@ #include <vector> #include <list> -namespace Eigen { -/** +namespace Eigen { +/** * \brief Modified Incomplete Cholesky with dual threshold * * References : C-J. Lin and J. J. Moré, Incomplete Cholesky Factorizations with @@ -48,15 +48,15 @@ class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_Up typedef SparseSolverBase<IncompleteCholesky<Scalar,_UpLo,_OrderingType> > Base; using Base::m_isInitialized; public: - typedef typename NumTraits<Scalar>::Real RealScalar; + typedef typename NumTraits<Scalar>::Real RealScalar; typedef _OrderingType OrderingType; typedef typename OrderingType::PermutationType PermutationType; - typedef typename PermutationType::StorageIndex StorageIndex; + typedef typename PermutationType::StorageIndex StorageIndex; typedef SparseMatrix<Scalar,ColMajor,StorageIndex> FactorType; typedef Matrix<Scalar,Dynamic,1> VectorSx; typedef Matrix<RealScalar,Dynamic,1> VectorRx; typedef Matrix<StorageIndex,Dynamic, 1> VectorIx; - typedef std::vector<std::list<StorageIndex> > VectorList; + typedef std::vector<std::list<StorageIndex> > VectorList; enum { UpLo = _UpLo }; enum { ColsAtCompileTime = Dynamic, @@ -71,7 +71,7 @@ class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_Up * \sa IncompleteCholesky(const MatrixType&) */ IncompleteCholesky() : m_initialShift(1e-3),m_analysisIsOk(false),m_factorizationIsOk(false) {} - + /** Constructor computing the incomplete factorization for the given matrix \a matrix. */ template<typename MatrixType> @@ -79,13 +79,13 @@ class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_Up { compute(matrix); } - + /** \returns number of rows of the factored matrix */ - EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_L.rows(); } - + Index rows() const { return m_L.rows(); } + /** \returns number of columns of the factored matrix */ - EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_L.cols(); } - + Index cols() const { return m_L.cols(); } + /** \brief Reports whether previous computation was successful. * @@ -100,19 +100,19 @@ class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_Up eigen_assert(m_isInitialized && "IncompleteCholesky is not initialized."); return m_info; } - + /** \brief Set the initial shift parameter \f$ \sigma \f$. */ void setInitialShift(RealScalar shift) { m_initialShift = shift; } - + /** \brief Computes the fill reducing permutation vector using the sparsity pattern of \a mat */ template<typename MatrixType> void analyzePattern(const MatrixType& mat) { - OrderingType ord; + OrderingType ord; PermutationType pinv; - ord(mat.template selfadjointView<UpLo>(), pinv); + ord(mat.template selfadjointView<UpLo>(), pinv); if(pinv.size()>0) m_perm = pinv.inverse(); else m_perm.resize(0); m_L.resize(mat.rows(), mat.cols()); @@ -120,7 +120,7 @@ class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_Up m_isInitialized = true; m_info = Success; } - + /** \brief Performs the numerical factorization of the input matrix \a mat * * The method analyzePattern() or compute() must have been called beforehand @@ -130,7 +130,7 @@ class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_Up */ template<typename MatrixType> void factorize(const MatrixType& mat); - + /** Computes or re-computes the incomplete Cholesky factorization of the input matrix \a mat * * It is a shortcut for a sequential call to the analyzePattern() and factorize() methods. @@ -143,7 +143,7 @@ class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_Up analyzePattern(mat); factorize(mat); } - + // internal template<typename Rhs, typename Dest> void _solve_impl(const Rhs& b, Dest& x) const @@ -170,16 +170,16 @@ class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky<Scalar,_Up protected: FactorType m_L; // The lower part stored in CSC - VectorRx m_scale; // The vector for scaling the matrix + VectorRx m_scale; // The vector for scaling the matrix RealScalar m_initialShift; // The initial shift parameter - bool m_analysisIsOk; - bool m_factorizationIsOk; + bool m_analysisIsOk; + bool m_factorizationIsOk; ComputationInfo m_info; - PermutationType m_perm; + PermutationType m_perm; private: - inline void updateList(Ref<const VectorIx> colPtr, Ref<VectorIx> rowIdx, Ref<VectorSx> vals, const Index& col, const Index& jk, VectorIx& firstElt, VectorList& listCol); -}; + inline void updateList(Ref<const VectorIx> colPtr, Ref<VectorIx> rowIdx, Ref<VectorSx> vals, const Index& col, const Index& jk, VectorIx& firstElt, VectorList& listCol); +}; // Based on the following paper: // C-J. Lin and J. J. Moré, Incomplete Cholesky Factorizations with @@ -190,10 +190,10 @@ template<typename _MatrixType> void IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType& mat) { using std::sqrt; - eigen_assert(m_analysisIsOk && "analyzePattern() should be called first"); - + eigen_assert(m_analysisIsOk && "analyzePattern() should be called first"); + // Dropping strategy : Keep only the p largest elements per column, where p is the number of elements in the column of the original matrix. Other strategies will be added - + // Apply the fill-reducing permutation computed in analyzePattern() if (m_perm.rows() == mat.rows() ) // To detect the null permutation { @@ -206,8 +206,8 @@ void IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType { m_L.template selfadjointView<Lower>() = mat.template selfadjointView<_UpLo>(); } - - Index n = m_L.cols(); + + Index n = m_L.cols(); Index nnz = m_L.nonZeros(); Map<VectorSx> vals(m_L.valuePtr(), nnz); //values Map<VectorIx> rowIdx(m_L.innerIndexPtr(), nnz); //Row indices @@ -219,9 +219,9 @@ void IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType VectorIx col_pattern(n); col_pattern.fill(-1); StorageIndex col_nnz; - - - // Computes the scaling factors + + + // Computes the scaling factors m_scale.resize(n); m_scale.setZero(); for (Index j = 0; j < n; j++) @@ -231,7 +231,7 @@ void IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType if(rowIdx[k]!=j) m_scale(rowIdx[k]) += numext::abs2(vals(k)); } - + m_scale = m_scale.cwiseSqrt().cwiseSqrt(); for (Index j = 0; j < n; ++j) @@ -241,8 +241,8 @@ void IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType m_scale(j) = 1; // TODO disable scaling if not needed, i.e., if it is roughly uniform? (this will make solve() faster) - - // Scale and compute the shift for the matrix + + // Scale and compute the shift for the matrix RealScalar mindiag = NumTraits<RealScalar>::highest(); for (Index j = 0; j < n; j++) { @@ -253,7 +253,7 @@ void IncompleteCholesky<Scalar,_UpLo, OrderingType>::factorize(const _MatrixType } FactorType L_save = m_L; - + RealScalar shift = 0; if(mindiag <= RealScalar(0.)) shift = m_initialShift - mindiag; @@ -375,7 +375,7 @@ inline void IncompleteCholesky<Scalar,_UpLo, OrderingType>::updateList(Ref<const if (jk < colPtr(col+1) ) { Index p = colPtr(col+1) - jk; - Index minpos; + Index minpos; rowIdx.segment(jk,p).minCoeff(&minpos); minpos += jk; if (rowIdx(minpos) != rowIdx(jk)) @@ -389,6 +389,6 @@ inline void IncompleteCholesky<Scalar,_UpLo, OrderingType>::updateList(Ref<const } } -} // end namespace Eigen +} // end namespace Eigen #endif |