32template <
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." );
125template <
class Derived>
152template <
class Derived>
159template <
class Derived>
170template <
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; }
231template <
class T,
int _Rows,
int _Cols,
int _Opt>
242template <
class T,
int _Rows,
int _Cols,
int _Opt>
253template <
class T,
int _Rows,
int _Cols,
int _Opt>
264template <
class T,
int _Rows,
int _Cols,
int _Opt>
278template <
class T,
int _Rows,
int _Cols,
int _Opt>
292template <
class T,
int _Rows,
int _Cols,
int _Opt>
305template <
typename T,
int _Opt,
typename _Index>
317template <
typename T,
int _Opt,
typename _Index>
330template <
typename T,
int _Opt,
typename _Index>
342template <
typename T,
int _Opt,
typename _Index>
356template <
typename T,
int _Opt,
typename _Index>
369template <
typename T,
int _Opt,
typename _Index>
Simple abstract class for discrete operators.
Definition gsLinearOperator.h:29
Simple adapter class to use a matrix (or matrix-like object) as a linear operator....
Definition gsMatrixOp.h:34
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
gsMatrixOp(const MatrixType &mat)
Constructor taking a reference.
Definition gsMatrixOp.h:52
const MatrixPtr m_mat
Shared pointer to matrix (if needed)
Definition gsMatrixOp.h:94
static uPtr make(const MatrixType &mat)
Make function returning a smart pointer.
Definition gsMatrixOp.h:67
gsMatrixOp(MatrixPtr mat)
Constructor taking a shared pointer.
Definition gsMatrixOp.h:59
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
NestedMatrix m_expr
Nested Eigen expression.
Definition gsMatrixOp.h:95
MatrixPtr matrixPtr() const
Returns a shared pinter to the matrix.
Definition gsMatrixOp.h:88
NestedMatrix matrix() const
Returns the matrix.
Definition gsMatrixOp.h:84
memory::unique_ptr< gsMatrixOp > uPtr
Unique pointer for gsMatrixOp.
Definition gsMatrixOp.h:45
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
static uPtr make(MatrixPtr mat)
Make function returning a smart pointer.
Definition gsMatrixOp.h:71
memory::shared_ptr< gsMatrixOp > Ptr
Shared pointer for gsMatrixOp.
Definition gsMatrixOp.h:42
index_t cols() const
Returns the number of columns of the operator.
Definition gsMatrixOp.h:80
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Simple adapter class to use an Eigen solver (having a compute() and a solve() method) as a linear ope...
Definition gsMatrixOp.h:172
const SolverType & solver() const
Access the solver class.
Definition gsMatrixOp.h:219
index_t rows() const
Returns the number of rows of the operator.
Definition gsMatrixOp.h:211
gsSolverOp< typenamegsSparseSolver< 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
gsSolverOp< typenamegsSparseSolver< 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< 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
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
static uPtr make(const MatrixType &mat)
Make function taking a matrix OR a shared pointer.
Definition gsMatrixOp.h:204
gsSolverOp(const memory::shared_ptr< MatrixType > &mat)
Constructor taking a shared pointer.
Definition gsMatrixOp.h:195
gsSolverOp< typenamegsSparseSolver< 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
gsSolverOp< typenamegsSparseSolver< 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
gsSolverOp< typenamegsSparseSolver< 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< typenamegsSparseSolver< 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(const MatrixType &mat)
Constructor taking a matrix.
Definition gsMatrixOp.h:186
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
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
index_t cols() const
Returns the number of columns of the operator.
Definition gsMatrixOp.h:213
SolverType & solver()
Access the solver class.
Definition gsMatrixOp.h:216
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
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
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
memory::shared_ptr< gsSolverOp > Ptr
Shared pointer for gsSolverOp.
Definition gsMatrixOp.h:179
memory::unique_ptr< gsSolverOp > uPtr
Unique pointer for gsSolverOp.
Definition gsMatrixOp.h:182
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
#define index_t
Definition gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
This is the main header file that collects wrappers of Eigen for linear algebra.
Simple abstract class for (discrete) linear operators.
unique_ptr< T > make_unique(T *x)
Definition gsMemory.h:198
The G+Smo namespace, containing all definitions for the library.
S give(S &x)
Definition gsMemory.h:266