G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
< gsMatrixOp
Ptr
 Shared pointer for gsMatrixOp.
 
typedef memory::unique_ptr
< gsMatrixOp
uPtr
 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 More...
 
index_t cols () const
 Returns the number of columns of the operator.
 
 gsMatrixOp (const MatrixType &mat)
 Constructor taking a reference. More...
 
 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. More...
 
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 Functions

(Note that these are not member functions.)

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. More...
 
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. More...
 

Constructor & Destructor Documentation

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

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 >.

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 Function Documentation

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:

gsMatrix<> M;
M.setRandom(10,10);
gsLinearOperator<>::Ptr op = makeMatrixOp(M);
gsLinearOperator<>::Ptr opT = makeMatrixOp(M.transpose());
gsLinearOperator<>::Ptr opB = makeMatrixOp(M.block(0,0,5,5) );

Note that

gsLinearOperator<>::Ptr opInv = makeMatrixOp(M.inverse());

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.
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:

gsMatrix<>::Ptr M(new gsMatrix<>);
M->setRandom(10,10);
gsLinearOperator<>::Ptr op = makeMatrixOp(M);

Alternatively:

gsMatrix<> M;
M.setRandom(10,10);
gsLinearOperator<>::Ptr op = makeMatrixOp(M.moveToPtr());