32 template <
class MatrixType>
35 typedef memory::shared_ptr<MatrixType> MatrixPtr;
36 typedef typename MatrixType::Nested NestedMatrix;
39 typedef typename MatrixType::Scalar T;
42 typedef memory::shared_ptr<gsMatrixOp>
Ptr;
45 typedef memory::unique_ptr<gsMatrixOp>
uPtr;
75 { x.noalias() =
m_expr * input; }
89 GISMO_ENSURE(
m_mat,
"A shared pointer is only available if it was provided to gsMatrixOp." );
125 template <
class Derived>
152 template <
class Derived>
159 template <
class Derived>
170 template <
class SolverType>
174 typedef typename SolverType::Scalar T;
176 typedef typename SolverType::MatrixType MatrixType;
179 typedef memory::shared_ptr<gsSolverOp>
Ptr;
182 typedef memory::unique_ptr<gsSolverOp>
uPtr;
188 GISMO_ASSERT(mat.rows() == mat.cols(),
"Need square matrix");
191 m_solver.compute(mat);
197 GISMO_ASSERT(mat->rows() == mat->cols(),
"Need square matrix");
198 m_size = mat->rows();
200 m_solver.compute(*mat);
208 x = m_solver.solve(input);
216 SolverType&
solver() {
return m_solver; }
219 const SolverType&
solver()
const {
return m_solver; }
231 template <
class T,
int _Rows,
int _Cols,
int _Opt>
242 template <
class T,
int _Rows,
int _Cols,
int _Opt>
253 template <
class T,
int _Rows,
int _Cols,
int _Opt>
264 template <
class T,
int _Rows,
int _Cols,
int _Opt>
278 template <
class T,
int _Rows,
int _Cols,
int _Opt>
292 template <
class T,
int _Rows,
int _Cols,
int _Opt>
305 template <
typename T,
int _Opt,
typename _Index>
317 template <
typename T,
int _Opt,
typename _Index>
330 template <
typename T,
int _Opt,
typename _Index>
342 template <
typename T,
int _Opt,
typename _Index>
356 template <
typename T,
int _Opt,
typename _Index>
369 template <
typename T,
int _Opt,
typename _Index>
gsSolverOp< typename gsSparseSolver< T >::LU >::uPtr makeSparseLUSolver(const gsSparseMatrix< T, _Opt, _Index > &mat)
Convenience function to create a sparse LU solver as a gsLinearOperator.
Definition: gsMatrixOp.h:306
memory::shared_ptr< gsMatrixOp > Ptr
Shared pointer for gsMatrixOp.
Definition: gsMatrixOp.h:42
MatrixPtr matrixPtr() const
Returns a shared pinter to the matrix.
Definition: gsMatrixOp.h:88
unique_ptr< T > make_unique(T *x)
Definition: gsMemory.h:198
const SolverType & solver() const
Access the solver class.
Definition: gsMatrixOp.h:219
SolverType & solver()
Access the solver class.
Definition: gsMatrixOp.h:216
memory::unique_ptr< gsMatrixOp > uPtr
Unique pointer for gsMatrixOp.
Definition: gsMatrixOp.h:45
static uPtr make(const MatrixType &mat)
Make function returning a smart pointer.
Definition: gsMatrixOp.h:67
gsSolverOp< gsEigen::PartialPivLU< gsEigen::Matrix< T, _Rows, _Cols, _Opt > > >::uPtr makePartialPivLUSolver(const memory::shared_ptr< gsMatrix< T, _Rows, _Cols, _Opt > > &mat)
Convenience function to create an LU solver with partial pivoting (for dense matrices) as a gsLinearO...
Definition: gsMatrixOp.h:243
Simple adapter class to use a matrix (or matrix-like object) as a linear operator. Needed for the iterative method classes.
Definition: gsMatrixOp.h:33
NestedMatrix matrix() const
Returns the matrix.
Definition: gsMatrixOp.h:84
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
apply the operator on the input vector and store the result in x
Definition: gsMatrixOp.h:206
memory::shared_ptr< gsSolverOp > Ptr
Shared pointer for gsSolverOp.
Definition: gsMatrixOp.h:179
S give(S &x)
Definition: gsMemory.h:266
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
gsSolverOp< gsEigen::FullPivLU< gsEigen::Matrix< T, _Rows, _Cols, _Opt > > >::uPtr makeFullPivLUSolver(const memory::shared_ptr< gsMatrix< T, _Rows, _Cols, _Opt > > &mat)
Convenience function to create an LU solver with full pivoting (for dense matrices) as a gsLinearOper...
Definition: gsMatrixOp.h:265
gsSolverOp< typename gsSparseSolver< T >::QR >::uPtr makeSparseQRSolver(const memory::shared_ptr< gsSparseMatrix< T, _Opt, _Index > > &mat)
Convenience function to create a sparse QR solver as a gsLinearOperator taking a shared pointer...
Definition: gsMatrixOp.h:343
gsSolverOp< gsEigen::FullPivLU< gsEigen::Matrix< T, _Rows, _Cols, _Opt > > >::uPtr makeFullPivLUSolver(const gsMatrix< T, _Rows, _Cols, _Opt > &mat)
Convenience function to create an LU solver with full pivoting (for dense matrices) as a gsLinearOper...
Definition: gsMatrixOp.h:254
index_t cols() const
Returns the number of columns of the operator.
Definition: gsMatrixOp.h:80
gsSolverOp< gsEigen::LDLT< gsEigen::Matrix< T, _Rows, _Cols, _Opt > > >::uPtr makeCholeskySolver(const gsMatrix< T, _Rows, _Cols, _Opt > &mat)
Convenience function to create a Cholesky (LDL^T) solver (for dense matrices) as a gsLinearOperator...
Definition: gsMatrixOp.h:279
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition: gsSparseMatrix.h:140
gsSolverOp< typename gsSparseSolver< T >::SimplicialLDLT >::uPtr makeSparseCholeskySolver(const memory::shared_ptr< gsSparseMatrix< T, _Opt, _Index > > &mat)
Convenience function to create a sparse Cholesky (simplicial LDL^T) solver as a gsLinearOperator.
Definition: gsMatrixOp.h:370
gsSolverOp(const MatrixType &mat)
Constructor taking a matrix.
Definition: gsMatrixOp.h:186
Simple adapter class to use an Eigen solver (having a compute() and a solve() method) as a linear ope...
Definition: gsMatrixOp.h:171
gsSolverOp< typename gsSparseSolver< T >::QR >::uPtr makeSparseQRSolver(const gsSparseMatrix< T, _Opt, _Index > &mat)
Convenience function to create a sparse QR solver as a gsLinearOperator.
Definition: gsMatrixOp.h:331
gsSolverOp< gsEigen::LDLT< gsEigen::Matrix< T, _Rows, _Cols, _Opt > > >::uPtr makeCholeskySolver(const memory::shared_ptr< gsMatrix< T, _Rows, _Cols, _Opt > > &mat)
Convenience function to create a Cholesky (LDL^T) solver (for dense matrices) as a gsLinearOperator t...
Definition: gsMatrixOp.h:293
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
apply the operator on the input vector and store the result in x
Definition: gsMatrixOp.h:74
index_t cols() const
Returns the number of columns of the operator.
Definition: gsMatrixOp.h:213
gsSolverOp(const memory::shared_ptr< MatrixType > &mat)
Constructor taking a shared pointer.
Definition: gsMatrixOp.h:195
index_t rows() const
Returns the number of rows of the operator.
Definition: gsMatrixOp.h:211
static uPtr make(MatrixPtr mat)
Make function returning a smart pointer.
Definition: gsMatrixOp.h:71
index_t rows() const
Returns the number of rows of the operator.
Definition: gsMatrixOp.h:77
gsMatrixOp< Derived >::uPtr makeMatrixOp(const gsEigen::EigenBase< Derived > &mat)
This essentially just calls the gsMatrixOp constructor, but the use of a template functions allows us...
Definition: gsMatrixOp.h:126
gsSolverOp< typename gsSparseSolver< T >::SimplicialLDLT >::uPtr makeSparseCholeskySolver(const gsSparseMatrix< T, _Opt, _Index > &mat)
Convenience function to create a sparse Cholesky (simplicial LDL^T) solver as a gsLinearOperator.
Definition: gsMatrixOp.h:357
Simple abstract class for discrete operators.
Definition: gsLinearOperator.h:28
This is the main header file that collects wrappers of Eigen for linear algebra.
gsMatrixOp(const MatrixType &mat)
Constructor taking a reference.
Definition: gsMatrixOp.h:52
NestedMatrix m_expr
Nested Eigen expression.
Definition: gsMatrixOp.h:95
gsMatrixOp< Derived >::uPtr makeMatrixOp(memory::shared_ptr< Derived > mat)
This essentially just calls the gsMatrixOp constructor, but the use of a template functions allows us...
Definition: gsMatrixOp.h:153
gsMatrixOp(MatrixPtr mat)
Constructor taking a shared pointer.
Definition: gsMatrixOp.h:59
static uPtr make(const MatrixType &mat)
Make function taking a matrix OR a shared pointer.
Definition: gsMatrixOp.h:204
const MatrixPtr m_mat
Shared pointer to matrix (if needed)
Definition: gsMatrixOp.h:94
gsSolverOp< gsEigen::PartialPivLU< gsEigen::Matrix< T, _Rows, _Cols, _Opt > > >::uPtr makePartialPivLUSolver(const gsMatrix< T, _Rows, _Cols, _Opt > &mat)
Convenience function to create an LU solver with partial pivoting (for dense matrices) as a gsLinearO...
Definition: gsMatrixOp.h:232
memory::unique_ptr< gsSolverOp > uPtr
Unique pointer for gsSolverOp.
Definition: gsMatrixOp.h:182
gsSolverOp< typename gsSparseSolver< T >::LU >::uPtr makeSparseLUSolver(const memory::shared_ptr< gsSparseMatrix< T, _Opt, _Index > > &mat)
Convenience function to create a sparse LU solver as a gsLinearOperator taking a shared pointer...
Definition: gsMatrixOp.h:318
Simple abstract class for (discrete) linear operators.