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;
77 : m_analysisIsOk(
false),
78 m_factorizationIsOk(
false),
88 m_useDefaultThreshold(
true)
93 explicit SPQR(
const _MatrixType& matrix)
94 : m_analysisIsOk(
false),
95 m_factorizationIsOk(
false),
105 m_useDefaultThreshold(
true)
125 void compute(
const _MatrixType& matrix)
127 if(m_isInitialized) SPQR_free();
136 if(m_useDefaultThreshold)
146 m_rows = matrix.rows();
147 Index col = matrix.cols();
149 &m_cR, &m_E, &m_H, &m_HPinv, &m_HTau, &m_cc);
154 m_isInitialized =
false;
158 m_isInitialized =
true;
159 m_isRUpToDate =
false;
171 template<
typename Rhs,
typename Dest>
174 eigen_assert(m_isInitialized &&
" The QR factorization should be computed first, call compute()");
175 eigen_assert(b.cols()==1 &&
"This method is for vectors only");
178 typename Dest::PlainObject y,
y2;
190 for(
Index i = 0; i <
rk; ++i) dest.row(m_E[i]) = y.row(i);
191 for(
Index i =
rk; i <
cols(); ++i) dest.row(m_E[i]).setZero();
203 eigen_assert(m_isInitialized &&
" The QR factorization should be computed first, call compute()");
206 m_isRUpToDate =
true;
218 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
227 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
228 return m_cc.SPQR_istat[4];
235 m_useDefaultThreshold =
false;
250 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
255 bool m_factorizationIsOk;
256 mutable bool m_isRUpToDate;
260 RealScalar m_tolerance;
262 mutable MatrixType m_R;
263 mutable StorageIndex *m_E =
nullptr;
265 mutable StorageIndex *m_HPinv =
nullptr;
267 mutable Index m_rank;
269 bool m_useDefaultThreshold;
274template <
typename SPQRType,
typename Derived>
277 typedef typename SPQRType::Scalar Scalar;
278 typedef typename SPQRType::StorageIndex StorageIndex;
282 inline Index rows()
const {
return m_transpose ? m_spqr.rows() : m_spqr.cols(); }
283 inline Index cols()
const {
return m_other.cols(); }
285 template<
typename ResType>
286 void evalTo(
ResType& res)
const
298 const Derived& m_other;
302template<
typename SPQRType>
306 template<
typename Derived>
323template<
typename SPQRType>
326 template<
typename Derived>
EIGEN_DEVICE_FUNC void resize(Index newSize)
Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods...
Definition DenseBase.h:246
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Definition Transpose.h:182
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC RealScalar norm() const
Definition Dot.h:103
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
Definition ReturnByValue.h:52
Sparse QR factorization based on SuiteSparseQR library.
Definition SuiteSparseQRSupport.h:61
ComputationInfo info() const
Reports whether previous computation was successful.
Definition SuiteSparseQRSupport.h:248
Index rank() const
Gets the rank of the matrix.
Definition SuiteSparseQRSupport.h:225
Index rows() const
Get the number of rows of the input matrix and the Q matrix.
Definition SuiteSparseQRSupport.h:164
Index cols() const
Get the number of columns of the input matrix.
Definition SuiteSparseQRSupport.h:169
PermutationType colsPermutation() const
Get the permutation that was applied to columns of A.
Definition SuiteSparseQRSupport.h:216
SPQRMatrixQReturnType< SPQR > matrixQ() const
Get an expression of the matrix Q.
Definition SuiteSparseQRSupport.h:211
void setPivotThreshold(const RealScalar &tol)
Set the tolerance tol to treat columns with 2-norm < =tol as zero.
Definition SuiteSparseQRSupport.h:233
cholmod_common * cholmodCommon() const
Definition SuiteSparseQRSupport.h:240
const MatrixType matrixR() const
Definition SuiteSparseQRSupport.h:201
void setSPQROrdering(int ord)
Set the fill-reducing ordering method to be used.
Definition SuiteSparseQRSupport.h:231
A base class for sparse solvers.
Definition SparseSolverBase.h:68
ComputationInfo
Enum for reporting the status of a computation.
Definition Constants.h:440
@ NumericalIssue
The provided data did not satisfy the prerequisites.
Definition Constants.h:444
@ Success
Computation was successful.
Definition Constants.h:442
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
cholmod_sparse viewAsCholmod(Ref< SparseMatrix< _Scalar, _Options, _StorageIndex > > mat)
Wraps the Eigen sparse matrix mat into a Cholmod sparse matrix object.
Definition CholmodSupport.h:58
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition Constants.h:22
Holds information about the various numeric (i.e.
Definition NumTraits.h:236
Definition SuiteSparseQRSupport.h:303
Definition SuiteSparseQRSupport.h:324
Definition SuiteSparseQRSupport.h:276
Definition ForwardDeclarations.h:17