11#ifndef EIGEN_SUITESPARSEQRSUPPORT_H
12#define EIGEN_SUITESPARSEQRSUPPORT_H
16 template<
typename MatrixType>
class SPQR;
17 template<
typename SPQRType>
struct SPQRMatrixQReturnType;
18 template<
typename SPQRType>
struct SPQRMatrixQTransposeReturnType;
19 template <
typename SPQRType,
typename Derived>
struct SPQR_QProduct;
23 typedef typename SPQRType::MatrixType ReturnType;
27 typedef typename SPQRType::MatrixType ReturnType;
31 typedef typename Derived::PlainObject ReturnType;
59template<
typename _MatrixType>
64 using Base::m_isInitialized;
66 typedef typename _MatrixType::Scalar Scalar;
67 typedef typename _MatrixType::RealScalar RealScalar;
72 ColsAtCompileTime = Dynamic,
73 MaxColsAtCompileTime = Dynamic
82 explicit SPQR(
const _MatrixType& matrix)
103 void compute(
const _MatrixType& matrix)
105 if(m_isInitialized) SPQR_free();
114 if(m_useDefaultThreshold)
124 A = viewAsCholmod(
mat);
125 Index col = matrix.cols();
127 &m_cR, &m_E, &m_H, &m_HPinv, &m_HTau, &m_cc);
132 m_isInitialized =
false;
136 m_isInitialized =
true;
137 m_isRUpToDate =
false;
142 inline Index
rows()
const {
return m_cR->nrow; }
147 inline Index
cols()
const {
return m_cR->ncol; }
149 template<
typename Rhs,
typename Dest>
152 eigen_assert(m_isInitialized &&
" The QR factorization should be computed first, call compute()");
153 eigen_assert(b.cols()==1 &&
"This method is for vectors only");
156 typename Dest::PlainObject y,
y2;
162 y.resize((std::max)(
cols(),Index(y.rows())),y.cols());
168 for(Index i = 0; i <
rk; ++i) dest.row(m_E[i]) = y.row(i);
169 for(Index i =
rk; i <
cols(); ++i) dest.row(m_E[i]).setZero();
181 eigen_assert(m_isInitialized &&
" The QR factorization should be computed first, call compute()");
184 m_isRUpToDate =
true;
196 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
205 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
206 return m_cc.SPQR_istat[4];
213 m_useDefaultThreshold =
false;
228 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
233 bool m_factorizationIsOk;
234 mutable bool m_isRUpToDate;
238 RealScalar m_tolerance;
240 mutable MatrixType m_R;
241 mutable StorageIndex *m_E;
243 mutable StorageIndex *m_HPinv;
245 mutable Index m_rank;
247 bool m_useDefaultThreshold;
251template <
typename SPQRType,
typename Derived>
254 typedef typename SPQRType::Scalar Scalar;
255 typedef typename SPQRType::StorageIndex StorageIndex;
259 inline Index rows()
const {
return m_transpose ? m_spqr.rows() : m_spqr.cols(); }
260 inline Index cols()
const {
return m_other.cols(); }
262 template<
typename ResType>
263 void evalTo(
ResType& res)
const
269 y_cd = viewAsCholmod(m_other.const_cast_derived());
275 const Derived& m_other;
279template<
typename SPQRType>
283 template<
typename Derived>
300template<
typename SPQRType>
303 template<
typename Derived>
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
Definition ReturnByValue.h:53
Sparse QR factorization based on SuiteSparseQR library.
Definition SuiteSparseQRSupport.h:61
ComputationInfo info() const
Reports whether previous computation was successful.
Definition SuiteSparseQRSupport.h:226
Index rank() const
Gets the rank of the matrix.
Definition SuiteSparseQRSupport.h:203
Index rows() const
Get the number of rows of the input matrix and the Q matrix.
Definition SuiteSparseQRSupport.h:142
Index cols() const
Get the number of columns of the input matrix.
Definition SuiteSparseQRSupport.h:147
PermutationType colsPermutation() const
Get the permutation that was applied to columns of A.
Definition SuiteSparseQRSupport.h:194
SPQRMatrixQReturnType< SPQR > matrixQ() const
Get an expression of the matrix Q.
Definition SuiteSparseQRSupport.h:189
void setPivotThreshold(const RealScalar &tol)
Set the tolerance tol to treat columns with 2-norm < =tol as zero.
Definition SuiteSparseQRSupport.h:211
cholmod_common * cholmodCommon() const
Definition SuiteSparseQRSupport.h:218
const MatrixType matrixR() const
Definition SuiteSparseQRSupport.h:179
void setSPQROrdering(int ord)
Set the fill-reducing ordering method to be used.
Definition SuiteSparseQRSupport.h:209
Pseudo expression representing a solving operation.
Definition Solve.h:63
A base class for sparse solvers.
Definition SparseSolverBase.h:54
ComputationInfo
Enum for reporting the status of a computation.
Definition Constants.h:430
@ NumericalIssue
The provided data did not satisfy the prerequisites.
Definition Constants.h:434
@ Success
Computation was successful.
Definition Constants.h:432
Holds information about the various numeric (i.e.
Definition NumTraits.h:108
Definition SuiteSparseQRSupport.h:280
Definition SuiteSparseQRSupport.h:301
Definition SuiteSparseQRSupport.h:253
Definition ForwardDeclarations.h:17