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;
59 template<
typename _MatrixType>
66 typedef typename _MatrixType::Scalar
Scalar;
90 cholmod_l_start(&
m_cc);
93 explicit SPQR(
const _MatrixType& matrix)
107 cholmod_l_start(&
m_cc);
114 cholmod_l_finish(&
m_cc);
118 cholmod_l_free_sparse(&
m_H, &
m_cc);
119 cholmod_l_free_sparse(&
m_cR, &
m_cc);
171 template<
typename Rhs,
typename Dest>
175 eigen_assert(b.cols()==1 &&
"This method is for vectors only");
178 typename Dest::PlainObject
y, y2;
185 y.topRows(rk) = this->
matrixR().topLeftCorner(rk, rk).template triangularView<Upper>().solve(y2.topRows(rk));
190 for(
Index i = 0; i < rk; ++i) dest.row(
m_E[i]) =
y.row(i);
205 m_R = viewAsEigen<Scalar,ColMajor, typename MatrixType::StorageIndex>(*
m_cR);
228 return m_cc.SPQR_istat[4];
264 mutable cholmod_sparse *
m_H;
274 template <
typename SPQRType,
typename Derived>
277 typedef typename SPQRType::Scalar
Scalar;
285 template<
typename ResType>
291 cholmod_common *cc =
m_spqr.cholmodCommon();
293 x_cd = SuiteSparseQR_qmult<Scalar>(method,
m_spqr.m_H,
m_spqr.m_HTau,
m_spqr.m_HPinv, &y_cd, cc);
295 cholmod_l_free_dense(&x_cd, cc);
302 template<
typename SPQRType>
306 template<
typename Derived>
323 template<
typename SPQRType>
326 template<
typename Derived>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ColXpr col(Index i)
This is the const version of col().
Definition: BlockMethods.h:1097
#define eigen_assert(x)
Definition: Macros.h:1037
EIGEN_DEVICE_FUNC Derived & setZero()
Definition: CwiseNullaryOp.h:546
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
static ConstMapType Map(const Scalar *data)
Definition: PlainObjectBase.h:644
Definition: ReturnByValue.h:52
Sparse QR factorization based on SuiteSparseQR library.
Definition: SuiteSparseQRSupport.h:61
cholmod_sparse * m_H
Definition: SuiteSparseQRSupport.h:264
StorageIndex * m_HPinv
Definition: SuiteSparseQRSupport.h:265
MatrixType m_R
Definition: SuiteSparseQRSupport.h:262
cholmod_common m_cc
Definition: SuiteSparseQRSupport.h:268
bool m_analysisIsOk
Definition: SuiteSparseQRSupport.h:254
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: SuiteSparseQRSupport.h:248
StorageIndex * m_E
Definition: SuiteSparseQRSupport.h:263
Index m_rank
Definition: SuiteSparseQRSupport.h:267
SPQR(const _MatrixType &matrix)
Definition: SuiteSparseQRSupport.h:93
bool m_useDefaultThreshold
Definition: SuiteSparseQRSupport.h:269
Index rank() const
Definition: SuiteSparseQRSupport.h:225
cholmod_dense * m_HTau
Definition: SuiteSparseQRSupport.h:266
@ MaxColsAtCompileTime
Definition: SuiteSparseQRSupport.h:73
@ ColsAtCompileTime
Definition: SuiteSparseQRSupport.h:72
SuiteSparse_long StorageIndex
Definition: SuiteSparseQRSupport.h:68
SparseSolverBase< SPQR< _MatrixType > > Base
Definition: SuiteSparseQRSupport.h:63
Index rows() const
Definition: SuiteSparseQRSupport.h:164
void SPQR_free()
Definition: SuiteSparseQRSupport.h:116
_MatrixType::Scalar Scalar
Definition: SuiteSparseQRSupport.h:66
bool m_factorizationIsOk
Definition: SuiteSparseQRSupport.h:255
ComputationInfo m_info
Definition: SuiteSparseQRSupport.h:257
Index m_rows
Definition: SuiteSparseQRSupport.h:270
cholmod_common * cholmodCommon() const
Definition: SuiteSparseQRSupport.h:240
int m_allow_tol
Definition: SuiteSparseQRSupport.h:259
SPQRMatrixQReturnType< SPQR > matrixQ() const
Get an expression of the matrix Q.
Definition: SuiteSparseQRSupport.h:211
SPQR()
Definition: SuiteSparseQRSupport.h:76
void compute(const _MatrixType &matrix)
Definition: SuiteSparseQRSupport.h:125
Index cols() const
Definition: SuiteSparseQRSupport.h:169
_MatrixType::RealScalar RealScalar
Definition: SuiteSparseQRSupport.h:67
RealScalar m_tolerance
Definition: SuiteSparseQRSupport.h:260
Map< PermutationMatrix< Dynamic, Dynamic, StorageIndex > > PermutationType
Definition: SuiteSparseQRSupport.h:70
PermutationType colsPermutation() const
Get the permutation that was applied to columns of A.
Definition: SuiteSparseQRSupport.h:216
void setPivotThreshold(const RealScalar &tol)
Set the tolerance tol to treat columns with 2-norm < =tol as zero.
Definition: SuiteSparseQRSupport.h:233
int m_ordering
Definition: SuiteSparseQRSupport.h:258
SparseMatrix< Scalar, ColMajor, StorageIndex > MatrixType
Definition: SuiteSparseQRSupport.h:69
const MatrixType matrixR() const
Definition: SuiteSparseQRSupport.h:201
void _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
Definition: SuiteSparseQRSupport.h:172
cholmod_sparse * m_cR
Definition: SuiteSparseQRSupport.h:261
void setSPQROrdering(int ord)
Set the fill-reducing ordering method to be used.
Definition: SuiteSparseQRSupport.h:231
~SPQR()
Definition: SuiteSparseQRSupport.h:111
bool m_isRUpToDate
Definition: SuiteSparseQRSupport.h:256
RealScalar norm() const
Definition: SparseDot.h:84
Index rows() const
Definition: SparseMatrix.h:138
Index cols() const
Definition: SparseMatrix.h:140
A base class for sparse solvers.
Definition: SparseSolverBase.h:68
bool m_isInitialized
Definition: SparseSolverBase.h:119
ComputationInfo
Definition: Constants.h:440
@ NumericalIssue
Definition: Constants.h:444
@ Success
Definition: Constants.h:442
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16() max(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:576
const Scalar & y
Definition: MathFunctions.h:821
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
Definition: MathFunctions.h:1091
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)
Definition: CholmodSupport.h:58
const int Dynamic
Definition: Constants.h:22
Definition: document.h:416
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:233
Definition: SuiteSparseQRSupport.h:303
SPQRMatrixQTransposeReturnType< SPQRType > adjoint() const
Definition: SuiteSparseQRSupport.h:311
SPQRMatrixQReturnType(const SPQRType &spqr)
Definition: SuiteSparseQRSupport.h:305
const SPQRType & m_spqr
Definition: SuiteSparseQRSupport.h:320
SPQRMatrixQTransposeReturnType< SPQRType > transpose() const
Definition: SuiteSparseQRSupport.h:316
SPQR_QProduct< SPQRType, Derived > operator*(const MatrixBase< Derived > &other)
Definition: SuiteSparseQRSupport.h:307
Definition: SuiteSparseQRSupport.h:324
SPQRMatrixQTransposeReturnType(const SPQRType &spqr)
Definition: SuiteSparseQRSupport.h:325
const SPQRType & m_spqr
Definition: SuiteSparseQRSupport.h:331
SPQR_QProduct< SPQRType, Derived > operator*(const MatrixBase< Derived > &other)
Definition: SuiteSparseQRSupport.h:327
Definition: SuiteSparseQRSupport.h:276
bool m_transpose
Definition: SuiteSparseQRSupport.h:299
SPQRType::Scalar Scalar
Definition: SuiteSparseQRSupport.h:277
SPQR_QProduct(const SPQRType &spqr, const Derived &other, bool transpose)
Definition: SuiteSparseQRSupport.h:280
void evalTo(ResType &res) const
Definition: SuiteSparseQRSupport.h:286
const SPQRType & m_spqr
Definition: SuiteSparseQRSupport.h:297
SPQRType::StorageIndex StorageIndex
Definition: SuiteSparseQRSupport.h:278
Index cols() const
Definition: SuiteSparseQRSupport.h:283
Index rows() const
Definition: SuiteSparseQRSupport.h:282
const Derived & m_other
Definition: SuiteSparseQRSupport.h:298
SPQRType::MatrixType ReturnType
Definition: SuiteSparseQRSupport.h:23
SPQRType::MatrixType ReturnType
Definition: SuiteSparseQRSupport.h:27
Derived::PlainObject ReturnType
Definition: SuiteSparseQRSupport.h:31
Definition: ForwardDeclarations.h:17