G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsMatrixOp< MatrixType > Class Template Reference

Detailed Description

template<class MatrixType>
class gismo::gsMatrixOp< MatrixType >

Simple adapter class to use a matrix (or matrix-like object) as a linear operator. Needed for the iterative method classes.

+ Inheritance diagram for gsMatrixOp< MatrixType >:
+ Collaboration diagram for gsMatrixOp< MatrixType >:

Public Types

typedef memory::shared_ptr< gsMatrixOpPtr
 Shared pointer for gsMatrixOp.
 
typedef memory::unique_ptr< gsMatrixOpuPtr
 Unique pointer for gsMatrixOp.
 

Public Member Functions

void apply (const gsMatrix< T > &input, gsMatrix< T > &x) const
 apply the operator on the input vector and store the result in x
 
index_t cols () const
 Returns the number of columns of the operator.
 
 gsMatrixOp (const MatrixType &mat)
 Constructor taking a reference.
 
 gsMatrixOp (MatrixPtr mat)
 Constructor taking a shared pointer.
 
NestedMatrix matrix () const
 Returns the matrix.
 
MatrixPtr matrixPtr () const
 Returns a shared pinter to the matrix.
 
index_t rows () const
 Returns the number of rows of the operator.
 
virtual void setOptions (const gsOptionList &)
 Set options based on a gsOptionList object.
 

Static Public Member Functions

static gsOptionList defaultOptions ()
 Get the default options as gsOptionList object.
 
static gsIdentityOp< MatrixType::Scalar > Identity (const index_t dim)
 Identity operator.
 
static uPtr make (const MatrixType &mat)
 Make function returning a smart pointer.
 
static uPtr make (MatrixPtr mat)
 Make function returning a smart pointer.
 

Private Attributes

NestedMatrix m_expr
 Nested Eigen expression.
 
const MatrixPtr m_mat
 Shared pointer to matrix (if needed)
 

Related Symbols

(Note that these are not member symbols.)

template<class Derived >
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 to let the compiler do type inference, so we don't need to type out the matrix type explicitly.
 
template<class Derived >
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 to let the compiler do type inference, so we don't need to type out the matrix type explicitly.
 

Constructor & Destructor Documentation

◆ gsMatrixOp()

template<class MatrixType >
gsMatrixOp ( const MatrixType &  mat)
inline

Constructor taking a reference.

Note
This does not copy the matrix. Make sure that the matrix is not deleted too early (alternatively use constructor by shared pointer)

Member Function Documentation

◆ apply()

template<class MatrixType >
void apply ( const gsMatrix< T > &  input,
gsMatrix< T > &  x 
) const
inlinevirtual

apply the operator on the input vector and store the result in x

Parameters
inputInput vector
xresult vector

Implements gsLinearOperator< MatrixType::Scalar >.

◆ make()

template<class MatrixType >
static uPtr make ( const MatrixType &  mat)
inlinestatic

Make function returning a smart pointer.

Note
This does not copy the matrix. Make sure that the matrix is not deleted too early or provide a shared pointer.

Friends And Related Symbol Documentation

◆ makeMatrixOp() [1/2]

template<class Derived >
gsMatrixOp< Derived >::uPtr makeMatrixOp ( const gsEigen::EigenBase< Derived > &  mat)
related

This essentially just calls the gsMatrixOp constructor, but the use of a template functions allows us to let the compiler do type inference, so we don't need to type out the matrix type explicitly.

Examples:

M.setRandom(10,10);
gsLinearOperator<>::Ptr opB = makeMatrixOp(M.block(0,0,5,5) );
memory::shared_ptr< gsLinearOperator > Ptr
Shared pointer for gsLinearOperator.
Definition gsLinearOperator.h:33
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
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41

Note that

will re-compute the inverse of the matrix every time the operator opInv is applied, so this is not advised.

Note
If a matrix is provided, only a reference is stored. Make sure that the matrix is not deleted too early or provide a shared pointer.

◆ makeMatrixOp() [2/2]

template<class Derived >
gsMatrixOp< Derived >::uPtr makeMatrixOp ( memory::shared_ptr< Derived >  mat)
related

This essentially just calls the gsMatrixOp constructor, but the use of a template functions allows us to let the compiler do type inference, so we don't need to type out the matrix type explicitly.

Example:

M->setRandom(10,10);
memory::shared_ptr< gsMatrix > Ptr
Shared pointer for gsMatrix.
Definition gsMatrix.h:102

Alternatively:

M.setRandom(10,10);