11 #ifndef EIGEN_SUITESPARSEQRSUPPORT_H
12 #define EIGEN_SUITESPARSEQRSUPPORT_H
19 template <
typename MatrixType>
21 template <
typename SPQRType>
22 struct SPQRMatrixQReturnType;
23 template <
typename SPQRType>
24 struct SPQRMatrixQTransposeReturnType;
25 template <
typename SPQRType,
typename Derived>
28 template <
typename SPQRType>
32 template <
typename SPQRType>
36 template <
typename SPQRType,
typename Derived>
66 template <
typename MatrixType_>
94 cholmod_l_start(&
m_cc);
110 cholmod_l_start(&
m_cc);
116 cholmod_l_finish(&
m_cc);
119 cholmod_l_free_sparse(&
m_H, &
m_cc);
120 cholmod_l_free_sparse(&
m_cR, &
m_cc);
145 m_rank = SuiteSparseQR<Scalar>(
m_ordering, pivotThreshold, internal::convert_index<StorageIndex>(
matrix.cols()), &
A,
167 template <
typename Rhs,
typename Dest>
170 eigen_assert(
b.cols() == 1 &&
"This method is for vectors only");
173 typename Dest::PlainObject
y, y2;
180 y.topRows(rk) = this->
matrixR().topLeftCorner(rk, rk).template triangularView<Upper>().solve(y2.topRows(rk));
199 m_R = viewAsEigen<Scalar, StorageIndex>(*
m_cR);
217 return m_cc.SPQR_istat[4];
248 mutable cholmod_sparse*
m_cR =
nullptr;
251 mutable cholmod_sparse*
m_H =
nullptr;
258 template <
typename,
typename>
262 template <
typename SPQRType,
typename Derived>
273 template <
typename ResType>
278 cholmod_common* cc =
m_spqr.cholmodCommon();
280 x_cd = SuiteSparseQR_qmult<Scalar>(method,
m_spqr.m_H,
m_spqr.m_HTau,
m_spqr.m_HPinv, &y_cd, cc);
282 reinterpret_cast<Scalar*
>(x_cd->x), x_cd->nrow, x_cd->ncol);
283 cholmod_l_free_dense(&x_cd, cc);
289 template <
typename SPQRType>
292 template <
typename Derived>
304 template <
typename SPQRType>
307 template <
typename Derived>
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::SparseMatrix< double > mat
Definition: EigenUnitTest.cpp:10
#define eigen_assert(x)
Definition: Macros.h:910
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
EIGEN_DEVICE_FUNC Derived & setZero()
Definition: CwiseNullaryOp.h:554
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:52
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
static ConstMapType Map(const Scalar *data)
Definition: PlainObjectBase.h:595
Definition: ReturnByValue.h:50
Sparse QR factorization based on SuiteSparseQR library.
Definition: SuiteSparseQRSupport.h:67
cholmod_dense * m_HTau
Definition: SuiteSparseQRSupport.h:253
bool m_factorizationIsOk
Definition: SuiteSparseQRSupport.h:242
void compute(const MatrixType_ &matrix)
Definition: SuiteSparseQRSupport.h:126
void setPivotThreshold(const RealScalar &tol)
Set the tolerance tol to treat columns with 2-norm < =tol as zero.
Definition: SuiteSparseQRSupport.h:222
StorageIndex * m_E
Definition: SuiteSparseQRSupport.h:250
void _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
Definition: SuiteSparseQRSupport.h:168
SparseMatrix< Scalar, ColMajor, StorageIndex > MatrixType
Definition: SuiteSparseQRSupport.h:76
SuiteSparse_long StorageIndex
Definition: SuiteSparseQRSupport.h:75
cholmod_sparse * m_cR
Definition: SuiteSparseQRSupport.h:248
SPQR(const MatrixType_ &matrix)
Definition: SuiteSparseQRSupport.h:97
Index rank() const
Definition: SuiteSparseQRSupport.h:215
~SPQR()
Definition: SuiteSparseQRSupport.h:114
bool m_isRUpToDate
Definition: SuiteSparseQRSupport.h:243
SPQR()
Definition: SuiteSparseQRSupport.h:81
cholmod_common * cholmodCommon() const
Definition: SuiteSparseQRSupport.h:228
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: SuiteSparseQRSupport.h:235
Index m_rows
Definition: SuiteSparseQRSupport.h:257
RealScalar m_tolerance
Definition: SuiteSparseQRSupport.h:247
Index rows() const
Definition: SuiteSparseQRSupport.h:160
MatrixType_::RealScalar RealScalar
Definition: SuiteSparseQRSupport.h:74
int m_ordering
Definition: SuiteSparseQRSupport.h:245
cholmod_sparse * m_H
Definition: SuiteSparseQRSupport.h:251
const MatrixType matrixR() const
Definition: SuiteSparseQRSupport.h:196
MatrixType_::Scalar Scalar
Definition: SuiteSparseQRSupport.h:73
Index m_rank
Definition: SuiteSparseQRSupport.h:254
bool m_useDefaultThreshold
Definition: SuiteSparseQRSupport.h:256
void SPQR_free()
Definition: SuiteSparseQRSupport.h:118
StorageIndex * m_HPinv
Definition: SuiteSparseQRSupport.h:252
int m_allow_tol
Definition: SuiteSparseQRSupport.h:246
ComputationInfo m_info
Definition: SuiteSparseQRSupport.h:244
Index cols() const
Definition: SuiteSparseQRSupport.h:165
Map< PermutationMatrix< Dynamic, Dynamic, StorageIndex > > PermutationType
Definition: SuiteSparseQRSupport.h:77
bool m_analysisIsOk
Definition: SuiteSparseQRSupport.h:241
MatrixType m_R
Definition: SuiteSparseQRSupport.h:249
SparseSolverBase< SPQR< MatrixType_ > > Base
Definition: SuiteSparseQRSupport.h:69
@ MaxColsAtCompileTime
Definition: SuiteSparseQRSupport.h:78
@ ColsAtCompileTime
Definition: SuiteSparseQRSupport.h:78
cholmod_common m_cc
Definition: SuiteSparseQRSupport.h:255
SPQRMatrixQReturnType< SPQR > matrixQ() const
Get an expression of the matrix Q.
Definition: SuiteSparseQRSupport.h:205
PermutationType colsPermutation() const
Get the permutation that was applied to columns of A.
Definition: SuiteSparseQRSupport.h:207
void setSPQROrdering(int ord)
Set the fill-reducing ordering method to be used.
Definition: SuiteSparseQRSupport.h:220
RealScalar norm() const
Definition: SparseDot.h:88
Index cols() const
Definition: SparseMatrix.h:161
Index rows() const
Definition: SparseMatrix.h:159
A base class for sparse solvers.
Definition: SparseSolverBase.h:67
bool m_isInitialized
Definition: SparseSolverBase.h:110
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85
#define max(a, b)
Definition: datatypes.h:23
ComputationInfo
Definition: Constants.h:438
@ NumericalIssue
Definition: Constants.h:442
@ Success
Definition: Constants.h:440
Scalar * y
Definition: level1_cplx_impl.h:128
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
Definition: MathFunctions.h:926
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X &x)
Definition: Meta.h:592
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
cholmod_sparse viewAsCholmod(Ref< SparseMatrix< Scalar_, Options_, StorageIndex_ > > mat)
Definition: CholmodSupport.h:64
const int Dynamic
Definition: Constants.h:25
void transpose()
Definition: skew_symmetric_matrix3.cpp:135
Definition: Eigen_Colamd.h:49
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: SuiteSparseQRSupport.h:290
SPQRMatrixQTransposeReturnType< SPQRType > adjoint() const
Definition: SuiteSparseQRSupport.h:296
SPQRMatrixQReturnType(const SPQRType &spqr)
Definition: SuiteSparseQRSupport.h:291
const SPQRType & m_spqr
Definition: SuiteSparseQRSupport.h:301
SPQRMatrixQTransposeReturnType< SPQRType > transpose() const
Definition: SuiteSparseQRSupport.h:298
SPQR_QProduct< SPQRType, Derived > operator*(const MatrixBase< Derived > &other)
Definition: SuiteSparseQRSupport.h:293
Definition: SuiteSparseQRSupport.h:305
SPQRMatrixQTransposeReturnType(const SPQRType &spqr)
Definition: SuiteSparseQRSupport.h:306
const SPQRType & m_spqr
Definition: SuiteSparseQRSupport.h:311
SPQR_QProduct< SPQRType, Derived > operator*(const MatrixBase< Derived > &other)
Definition: SuiteSparseQRSupport.h:308
Definition: SuiteSparseQRSupport.h:263
bool m_transpose
Definition: SuiteSparseQRSupport.h:287
SPQRType::Scalar Scalar
Definition: SuiteSparseQRSupport.h:264
SPQR_QProduct(const SPQRType &spqr, const Derived &other, bool transpose)
Definition: SuiteSparseQRSupport.h:267
void evalTo(ResType &res) const
Definition: SuiteSparseQRSupport.h:274
const SPQRType & m_spqr
Definition: SuiteSparseQRSupport.h:285
SPQRType::StorageIndex StorageIndex
Definition: SuiteSparseQRSupport.h:265
Index cols() const
Definition: SuiteSparseQRSupport.h:271
Index rows() const
Definition: SuiteSparseQRSupport.h:270
const Derived & m_other
Definition: SuiteSparseQRSupport.h:286
SPQRType::MatrixType ReturnType
Definition: SuiteSparseQRSupport.h:30
SPQRType::MatrixType ReturnType
Definition: SuiteSparseQRSupport.h:34
Derived::PlainObject ReturnType
Definition: SuiteSparseQRSupport.h:38
Definition: ForwardDeclarations.h:21
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2