mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-12 14:25:16 +08:00
Add assertion and warning on the requirements of SparseQR and COLAMDOrdering
(grafted from 98ef44fe55
)
This commit is contained in:
parent
0c4fc69d62
commit
caf4936661
@ -109,7 +109,7 @@ class NaturalOrdering
|
|||||||
* \class COLAMDOrdering
|
* \class COLAMDOrdering
|
||||||
*
|
*
|
||||||
* Functor computing the \em column \em approximate \em minimum \em degree ordering
|
* Functor computing the \em column \em approximate \em minimum \em degree ordering
|
||||||
* The matrix should be in column-major format
|
* The matrix should be in column-major and \b compressed format (see SparseMatrix::makeCompressed()).
|
||||||
*/
|
*/
|
||||||
template<typename Index>
|
template<typename Index>
|
||||||
class COLAMDOrdering
|
class COLAMDOrdering
|
||||||
@ -118,10 +118,14 @@ class COLAMDOrdering
|
|||||||
typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType;
|
typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType;
|
||||||
typedef Matrix<Index, Dynamic, 1> IndexVector;
|
typedef Matrix<Index, Dynamic, 1> IndexVector;
|
||||||
|
|
||||||
/** Compute the permutation vector form a sparse matrix */
|
/** Compute the permutation vector \a perm form the sparse matrix \a mat
|
||||||
|
* \warning The input sparse matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
|
||||||
|
*/
|
||||||
template <typename MatrixType>
|
template <typename MatrixType>
|
||||||
void operator() (const MatrixType& mat, PermutationType& perm)
|
void operator() (const MatrixType& mat, PermutationType& perm)
|
||||||
{
|
{
|
||||||
|
eigen_assert(mat.isCompressed() && "COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to COLAMDOrdering");
|
||||||
|
|
||||||
Index m = mat.rows();
|
Index m = mat.rows();
|
||||||
Index n = mat.cols();
|
Index n = mat.cols();
|
||||||
Index nnz = mat.nonZeros();
|
Index nnz = mat.nonZeros();
|
||||||
|
@ -58,6 +58,7 @@ namespace internal {
|
|||||||
* \tparam _OrderingType The fill-reducing ordering method. See the \link OrderingMethods_Module
|
* \tparam _OrderingType The fill-reducing ordering method. See the \link OrderingMethods_Module
|
||||||
* OrderingMethods \endlink module for the list of built-in and external ordering methods.
|
* OrderingMethods \endlink module for the list of built-in and external ordering methods.
|
||||||
*
|
*
|
||||||
|
* \warning The input sparse matrix A must be in compressed mode (see SparseMatrix::makeCompressed()).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template<typename _MatrixType, typename _OrderingType>
|
template<typename _MatrixType, typename _OrderingType>
|
||||||
@ -77,10 +78,23 @@ class SparseQR
|
|||||||
SparseQR () : m_isInitialized(false), m_analysisIsok(false), m_lastError(""), m_useDefaultThreshold(true),m_isQSorted(false)
|
SparseQR () : m_isInitialized(false), m_analysisIsok(false), m_lastError(""), m_useDefaultThreshold(true),m_isQSorted(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
/** Construct a QR factorization of the matrix \a mat.
|
||||||
|
*
|
||||||
|
* \warning The matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
|
||||||
|
*
|
||||||
|
* \sa compute()
|
||||||
|
*/
|
||||||
SparseQR(const MatrixType& mat) : m_isInitialized(false), m_analysisIsok(false), m_lastError(""), m_useDefaultThreshold(true),m_isQSorted(false)
|
SparseQR(const MatrixType& mat) : m_isInitialized(false), m_analysisIsok(false), m_lastError(""), m_useDefaultThreshold(true),m_isQSorted(false)
|
||||||
{
|
{
|
||||||
compute(mat);
|
compute(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Computes the QR factorization of the sparse matrix \a mat.
|
||||||
|
*
|
||||||
|
* \warning The matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
|
||||||
|
*
|
||||||
|
* \sa analyzePattern(), factorize()
|
||||||
|
*/
|
||||||
void compute(const MatrixType& mat)
|
void compute(const MatrixType& mat)
|
||||||
{
|
{
|
||||||
analyzePattern(mat);
|
analyzePattern(mat);
|
||||||
@ -255,6 +269,8 @@ class SparseQR
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Preprocessing step of a QR factorization
|
/** \brief Preprocessing step of a QR factorization
|
||||||
|
*
|
||||||
|
* \warning The matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
|
||||||
*
|
*
|
||||||
* In this step, the fill-reducing permutation is computed and applied to the columns of A
|
* In this step, the fill-reducing permutation is computed and applied to the columns of A
|
||||||
* and the column elimination tree is computed as well. Only the sparcity pattern of \a mat is exploited.
|
* and the column elimination tree is computed as well. Only the sparcity pattern of \a mat is exploited.
|
||||||
@ -264,6 +280,7 @@ class SparseQR
|
|||||||
template <typename MatrixType, typename OrderingType>
|
template <typename MatrixType, typename OrderingType>
|
||||||
void SparseQR<MatrixType,OrderingType>::analyzePattern(const MatrixType& mat)
|
void SparseQR<MatrixType,OrderingType>::analyzePattern(const MatrixType& mat)
|
||||||
{
|
{
|
||||||
|
eigen_assert(mat.isCompressed() && "SparseQR requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to SparseQR");
|
||||||
// Compute the column fill reducing ordering
|
// Compute the column fill reducing ordering
|
||||||
OrderingType ord;
|
OrderingType ord;
|
||||||
ord(mat, m_perm_c);
|
ord(mat, m_perm_c);
|
||||||
|
Loading…
Reference in New Issue
Block a user