CUSP
Loading...
Searching...
No Matches
cusp::linear_operator< ValueType, MemorySpace, IndexType > Class Template Reference

#include <linear_operator.h>

Inheritance diagram for cusp::linear_operator< ValueType, MemorySpace, IndexType >:
cusp::identity_operator< ValueType, MemorySpace, IndexType > cusp::precond::bridson_ainv< ValueType, MemorySpace > cusp::precond::diagonal< ValueType, MemorySpace > cusp::precond::nonsym_bridson_ainv< ValueType, MemorySpace > cusp::precond::scaled_bridson_ainv< ValueType, MemorySpace > cusp::relaxation::gauss_seidel< ValueType, MemorySpace > cusp::relaxation::jacobi< ValueType, MemorySpace > cusp::relaxation::polynomial< ValueType, MemorySpace > cusp::relaxation::sor< ValueType, MemorySpace >

Public Methods

 linear_operator (void)
 
 linear_operator (IndexType num_rows, IndexType num_cols)
 
 linear_operator (IndexType num_rows, IndexType num_cols, IndexType num_entries)
 

Detailed description

template<typename ValueType, typename MemorySpace, typename IndexType = int>
class cusp::linear_operator< ValueType, MemorySpace, IndexType >

Abstract representation of a linear operator.

Template Parameters
IndexTypeType used for operator indices (e.g. int).
ValueTypeType used for operator values (e.g. float).
MemorySpaceA memory space (e.g. cusp::host_memory or cusp::device_memory)
Overview
A linear operator is a abstract container that supports encapsulates abstract linear operators for use with other routines. All linear operators should provide a implementation of the operator()(x,y) for interoperability with the multiply routine.
Example
The following code snippet demonstrates how to create a custom linear operator.
// include linear_operator header file
#include <cusp/multiply.h>
#include <cusp/print.h>
template <typename MatrixType>
struct Dinv_A : public cusp::linear_operator<typename MatrixType::value_type, typename MatrixType::memory_space>
{
typedef typename MatrixType::value_type ValueType;
typedef typename MatrixType::memory_space MemorySpace;
const MatrixType& A;
Dinv_A(const MatrixType& A)
: A(A), Dinv(A),
cusp::linear_operator<ValueType,MemorySpace>(A.num_rows, A.num_cols, A.num_entries + A.num_rows)
{}
template <typename Array1, typename Array2>
void operator()(const Array1& x, Array2& y) const
{
cusp::multiply(Dinv,y,y);
}
};
int main(void)
{
CsrMatrix A;
// number of entries
const int N = 4;
// construct Poisson example matrix
// construct instance of custom operator perform D^{-1}A
Dinv_A<CsrMatrix> M(A);
// initialize x and y vectors
// call operator()(x,y) through multiply interface
// print the transformed vector
}
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
Definition array1d.h:99
Compressed sparse row (CSR) representation a sparse matrix.
Definition csr_matrix.h:108
Abstract representation of a linear operator.
Diagonal preconditioner (aka Jacobi preconditioner)
Definition diagonal.h:86
Compressed Sparse Row matrix format.
Diagonal preconditioner.
void print(const Printable &p)
print a textual representation of an object
void multiply(const LinearOperator &A, const MatrixOrVector1 &B, MatrixOrVector2 &C)
Implements matrix-matrix and matrix-vector multiplication.
Abstract interface for iterative solvers.
Matrix multiplication.
Poisson matrix generators.
Print textual representation of an object.

Definition at line 111 of file linear_operator.h.

Constructor & Destructor Documentation

◆ linear_operator() [1/3]

template<typename ValueType , typename MemorySpace , typename IndexType = int>
cusp::linear_operator< ValueType, MemorySpace, IndexType >::linear_operator ( void  )
inline

Construct an empty linear_operator.

Definition at line 121 of file linear_operator.h.

◆ linear_operator() [2/3]

template<typename ValueType , typename MemorySpace , typename IndexType = int>
cusp::linear_operator< ValueType, MemorySpace, IndexType >::linear_operator ( IndexType  num_rows,
IndexType  num_cols 
)
inline

Construct a linear_operator with a specific shape.

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.

Definition at line 129 of file linear_operator.h.

◆ linear_operator() [3/3]

template<typename ValueType , typename MemorySpace , typename IndexType = int>
cusp::linear_operator< ValueType, MemorySpace, IndexType >::linear_operator ( IndexType  num_rows,
IndexType  num_cols,
IndexType  num_entries 
)
inline

Construct a linear_operator with a specific shape and number of nonzero entries.

Parameters
num_rowsNumber of rows.
num_colsNumber of columns.
num_entriesNumber of nonzero entries.

Definition at line 139 of file linear_operator.h.