Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Public Methods | List of all members
cusp::linear_operator< ValueType, MemorySpace, IndexType > Class Template Reference

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
}
Examples:
stencil.cu.

Definition at line 111 of file linear_operator.h.

#include <linear_operator.h>

Inheritance diagram for cusp::linear_operator< ValueType, MemorySpace, IndexType >:
cusp::identity_operator< ValueType, MemorySpace, IndexType >

Public Methods

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

Constructor & Destructor Documentation

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.

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.

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.