10 #ifndef EIGEN_SUITESPARSEQRSUPPORT_H    11 #define EIGEN_SUITESPARSEQRSUPPORT_H    15   template<
typename MatrixType> 
class SPQR; 
    56 template<
typename _MatrixType>
    60     typedef typename _MatrixType::Scalar 
Scalar;
    67     : m_ordering(SPQR_ORDERING_DEFAULT),
    68       m_allow_tol(SPQR_DEFAULT_TOL),
    71       cholmod_l_start(&m_cc);
    74     SPQR(
const _MatrixType& matrix) 
    75     : m_ordering(SPQR_ORDERING_DEFAULT),
    76       m_allow_tol(SPQR_DEFAULT_TOL),
    79       cholmod_l_start(&m_cc);
    86       cholmod_l_free_sparse(&m_H, &m_cc);
    87       cholmod_l_free_sparse(&m_cR, &m_cc);
    88       cholmod_l_free_dense(&m_HTau, &m_cc);
    91       cholmod_l_finish(&m_cc);
    95       MatrixType mat(matrix);
    98       Index 
col = matrix.cols();
    99       m_rank = SuiteSparseQR<Scalar>(m_ordering, m_tolerance, 
col, &A, 
   100                              &m_cR, &m_E, &m_H, &m_HPinv, &m_HTau, &m_cc);
   105         m_isInitialized = 
false;
   109       m_isInitialized = 
true;
   110       m_isRUpToDate = 
false;
   115     inline Index 
rows()
 const {
return m_H->nrow; }
   120     inline Index 
cols()
 const { 
return m_cR->ncol; }
   126     template<
typename Rhs>
   129       eigen_assert(m_isInitialized && 
" The QR factorization should be computed first, call compute()");
   131                     && 
"SPQR::solve(): invalid number of rows of the right hand side matrix B");
   135     template<
typename Rhs, 
typename Dest>
   138       eigen_assert(m_isInitialized && 
" The QR factorization should be computed first, call compute()");
   139       eigen_assert(b.cols()==1 && 
"This method is for vectors only");
   143       y = matrixQ().transpose() * b;
   145       Index rk = this->rank();
   146       y.topRows(rk) = this->matrixR().topLeftCorner(rk, rk).template triangularView<Upper>().solve(y.topRows(rk));
   147       y.bottomRows(cols()-rk).setZero();
   149       dest.
topRows(cols()) = colsPermutation() * y.topRows(cols());
   158       eigen_assert(m_isInitialized && 
" The QR factorization should be computed first, call compute()");
   160         m_R = viewAsEigen<Scalar,ColMajor, typename MatrixType::Index>(*m_cR);
   161         m_isRUpToDate = 
true;
   173       eigen_assert(m_isInitialized && 
"Decomposition is not initialized.");
   174       Index n = m_cR->ncol;
   175       PermutationType colsPerm(n);
   176       for(Index j = 0; j <n; j++) colsPerm.
indices()(j) = m_E[j];
   186       eigen_assert(m_isInitialized && 
"Decomposition is not initialized.");
   187       return m_cc.SPQR_istat[4];
   205       eigen_assert(m_isInitialized && 
"Decomposition is not initialized.");
   220     mutable cholmod_sparse *
m_H;  
   228 template <
typename SPQRType, 
typename Derived>
   231   typedef typename SPQRType::Scalar 
Scalar;
   232   typedef typename SPQRType::Index 
Index;
   234   SPQR_QProduct(
const SPQRType& spqr, 
const Derived& other, 
bool transpose) : m_spqr(spqr),m_other(other),m_transpose(transpose) {}
   236   inline Index 
rows()
 const { 
return m_transpose ? m_spqr.rows() : m_spqr.cols(); }
   237   inline Index 
cols()
 const { 
return m_other.cols(); }
   239   template<
typename ResType>
   244     int method = m_transpose ? SPQR_QTX : SPQR_QX; 
   245     cholmod_common *cc = m_spqr.cholmodCommon();
   247     x_cd = SuiteSparseQR_qmult<Scalar>(method, m_spqr.m_H, m_spqr.m_HTau, m_spqr.m_HPinv, &y_cd, cc);
   249     cholmod_l_free_dense(&x_cd, cc);
   256 template<
typename SPQRType>
   260   template<
typename Derived>
   277 template<
typename SPQRType>
   280   template<
typename Derived>
   290 template<
typename _MatrixType, 
typename Rhs>
   297   template<typename Dest> 
void evalTo(Dest& dst)
 const   299     dec()._solve(rhs(),dst);
 SPQR_QProduct< SPQRType, Derived > operator*(const MatrixBase< Derived > &other)
cholmod_common * cholmodCommon() const 
SparseMatrix< Scalar, ColMajor, Index > MatrixType
PermutationMatrix< Dynamic, Dynamic > PermutationType
SPQRMatrixQTransposeReturnType< SPQRType > transpose() const 
void _solve(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const 
RowsBlockXpr topRows(Index n)
SPQR(const _MatrixType &matrix)
SPQRMatrixQReturnType(const SPQRType &spqr)
SPQR_QProduct< SPQRType, Derived > operator*(const MatrixBase< Derived > &other)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
_MatrixType::Scalar Scalar
SPQRType::MatrixType ReturnType
const internal::solve_retval< SPQR, Rhs > solve(const MatrixBase< Rhs > &B) const 
void setPivotThreshold(const RealScalar &tol)
Set the tolerance tol to treat columns with 2-norm < =tol as zero. 
SPQRType::MatrixType ReturnType
cholmod_sparse viewAsCholmod(SparseMatrix< _Scalar, _Options, _Index > &mat)
PermutationType colsPermutation() const 
Get the permutation that was applied to columns of A. 
Derived::PlainObject ReturnType
ComputationInfo info() const 
Reports whether previous computation was successful. 
SPQR_QProduct(const SPQRType &spqr, const Derived &other, bool transpose)
void compute(const _MatrixType &matrix)
const MatrixType matrixR() const 
void setSPQROrdering(int ord)
Set the fill-reducing ordering method to be used. 
const IndicesType & indices() const 
SPQRMatrixQReturnType< SPQR > matrixQ() const 
Get an expression of the matrix Q. 
static ConstMapType Map(const Scalar *data)
SPQRMatrixQTransposeReturnType(const SPQRType &spqr)
Sparse QR factorization based on SuiteSparseQR library. 
void evalTo(ResType &res) const 
#define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType, Rhs)
SPQRMatrixQTransposeReturnType< SPQRType > adjoint() const 
Base class for all dense matrices, vectors, and expressions. 
_MatrixType::RealScalar RealScalar