Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Protected Member Functions | Protected Attributes | Related Functions | List of all members
Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node > Class Template Reference

A class for wrapping a CrsMatrix multiply in a Operator. More...

#include <Tpetra_CrsMatrixMultiplyOp.hpp>

Inheritance diagram for Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >:
Inheritance graph
[legend]

Public Types

using crs_matrix_type = CrsMatrix< MatScalar, LocalOrdinal, GlobalOrdinal, Node >
 The specialization of CrsMatrix which this class wraps. More...
 
using map_type = Map< LocalOrdinal, GlobalOrdinal, Node >
 The specialization of Map which this class uses. More...
 
Typedefs that give access to the template parameters.
typedef Scalar scalar_type
 The type of the entries of the input and output multivectors. More...
 
typedef LocalOrdinal local_ordinal_type
 The local index type. More...
 
typedef GlobalOrdinal global_ordinal_type
 The global index type. More...
 
typedef Node node_type
 The Kokkos Node type. More...
 

Public Member Functions

Constructor and destructor
 CrsMatrixMultiplyOp (const Teuchos::RCP< const crs_matrix_type > &A)
 Constructor. More...
 
 ~CrsMatrixMultiplyOp () override=default
 Destructor (virtual for memory safety of derived classes). More...
 
Methods implementing Operator
void apply (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const override
 Compute Y = beta*Y + alpha*Op(A)*X, where Op(A) is either A, $A^T$, or $A^H$. More...
 
bool hasTransposeApply () const override
 Whether this Operator's apply() method can apply the transpose or conjugate transpose. More...
 
Teuchos::RCP< const map_typegetDomainMap () const override
 The domain Map of this Operator. More...
 
Teuchos::RCP< const map_typegetRangeMap () const override
 The range Map of this Operator. More...
 
Pure virtual functions to be overridden by subclasses.
virtual bool hasDiagonal () const
 Whether this operator can return its diagonal. More...
 
virtual void getLocalDiagCopy (Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
 Get the diagonal of the operator. More...
 

Protected Member Functions

void applyTranspose (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X_in, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y_in, Teuchos::ETransp mode, Scalar alpha, Scalar beta) const
 Apply the transpose or conjugate transpose of the matrix to X_in, producing Y_in. More...
 
void applyNonTranspose (const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X_in, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y_in, Scalar alpha, Scalar beta) const
 Apply the matrix (not its transpose) to X_in, producing Y_in. More...
 

Protected Attributes

const Teuchos::RCP< const
crs_matrix_type
matrix_
 The underlying CrsMatrix object. More...
 
LocalCrsMatrixOperator< Scalar,
MatScalar, typename
crs_matrix_type::device_type
localMultiply_
 Implementation of local sparse matrix-vector multiply. More...
 
Teuchos::RCP< MultiVector
< Scalar, LocalOrdinal,
GlobalOrdinal, Node > > 
importMV_
 Column Map MultiVector used in apply(). More...
 
Teuchos::RCP< MultiVector
< Scalar, LocalOrdinal,
GlobalOrdinal, Node > > 
exportMV_
 Row Map MultiVector used in apply(). More...
 

Related Functions

(Note that these are not member functions.)

template<class OpScalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP
< CrsMatrixMultiplyOp
< OpScalar, MatScalar,
LocalOrdinal, GlobalOrdinal,
Node > > 
createCrsMatrixMultiplyOp (const Teuchos::RCP< const CrsMatrix< MatScalar, LocalOrdinal, GlobalOrdinal, Node > > &A)
 Non-member function to create a CrsMatrixMultiplyOp. More...
 

Detailed Description

template<class Scalar, class MatScalar, class LocalOrdinal, class GlobalOrdinal, class Node>
class Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >

A class for wrapping a CrsMatrix multiply in a Operator.

Note
Most Tpetra users do not need to use this class. It will be useful to Tpetra users who want to do mixed-precision sparse matrix-vector multiply, where the sparse matrix's entries have a different precision than that of the input and output vectors. If your sparse matrix and vectors have the same type of entries, then you don't need to use this class.

This class makes a CrsMatrix<MatScalar, ...> "look like" an Operator<Scalar, ...>, where MatScalar and Scalar may be different types. The resulting output (Multi)Vector will be computed at its own precision.

Template Parameters
ScalarThe type of the entries of the input and output MultiVector (see apply()). Same as the first template parameter of Operator.
MatScalarThe type of the entries of the CrsMatrix; the first template parameter of CrsMatrix.
LocalOrdinalThe type of the local indices of the CrsMatrix; the second template parameter of CrsMatrix and Operator.
GlobalOrdinalThe type of the global indices of the CrsMatrix; the third template parameter of CrsMatrix and Operator.
NodeThe fourth template parameter of CrsMatrix and Operator.

If you encounter link errors when Scalar != MatScalar, try including Tpetra_LocalCrsMatrixOperator_def.hpp after including this header file.

Definition at line 68 of file Tpetra_CrsMatrixMultiplyOp.hpp.

Member Typedef Documentation

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
using Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::crs_matrix_type = CrsMatrix<MatScalar, LocalOrdinal, GlobalOrdinal, Node>

The specialization of CrsMatrix which this class wraps.

Definition at line 74 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
using Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::map_type = Map<LocalOrdinal, GlobalOrdinal, Node>

The specialization of Map which this class uses.

Definition at line 76 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
typedef Scalar Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >::scalar_type
inherited

The type of the entries of the input and output multivectors.

Definition at line 61 of file Tpetra_Operator.hpp.

template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
typedef LocalOrdinal Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_ordinal_type
inherited

The local index type.

Definition at line 64 of file Tpetra_Operator.hpp.

template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
typedef GlobalOrdinal Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >::global_ordinal_type
inherited

The global index type.

Definition at line 67 of file Tpetra_Operator.hpp.

template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
typedef Node Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type
inherited

The Kokkos Node type.

Definition at line 70 of file Tpetra_Operator.hpp.

Constructor & Destructor Documentation

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::CrsMatrixMultiplyOp ( const Teuchos::RCP< const crs_matrix_type > &  A)
inline

Constructor.

Parameters
A[in] The CrsMatrix to wrap as an Operator<Scalar, ...>.

Definition at line 90 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::~CrsMatrixMultiplyOp ( )
overridedefault

Destructor (virtual for memory safety of derived classes).

Member Function Documentation

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::apply ( const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  X,
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  Y,
Teuchos::ETransp  mode = Teuchos::NO_TRANS,
Scalar  alpha = Teuchos::ScalarTraits<Scalar>::one (),
Scalar  beta = Teuchos::ScalarTraits<Scalar>::zero () 
) const
inlineoverridevirtual

Compute Y = beta*Y + alpha*Op(A)*X, where Op(A) is either A, $A^T$, or $A^H$.

Implements Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >.

Definition at line 106 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
bool Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::hasTransposeApply ( ) const
inlineoverridevirtual

Whether this Operator's apply() method can apply the transpose or conjugate transpose.

This is always true, since it is true for the CrsMatrix that this object wraps.

Reimplemented from Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >.

Definition at line 134 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP<const map_type> Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::getDomainMap ( ) const
inlineoverridevirtual
template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP<const map_type> Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::getRangeMap ( ) const
inlineoverridevirtual
template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::applyTranspose ( const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  X_in,
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  Y_in,
Teuchos::ETransp  mode,
Scalar  alpha,
Scalar  beta 
) const
inlineprotected

Apply the transpose or conjugate transpose of the matrix to X_in, producing Y_in.

Definition at line 191 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
void Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::applyNonTranspose ( const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  X_in,
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  Y_in,
Scalar  alpha,
Scalar  beta 
) const
inlineprotected

Apply the matrix (not its transpose) to X_in, producing Y_in.

Definition at line 302 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node >
bool Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >::hasDiagonal ( ) const
virtualinherited

Whether this operator can return its diagonal.

By default, this returns false. Subclasses must override this method if they can supply a diagonal.

Definition at line 124 of file Tpetra_Operator.hpp.

template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
void Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node >::getLocalDiagCopy ( Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &  diag) const
virtualinherited

Get the diagonal of the operator.

By default, this throws. Subclasses must override this method if they can supply a diagonal.

Reimplemented in Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >, Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >, and Tpetra::RowMatrix< Scalar, LO, GO, Node >.

Definition at line 129 of file Tpetra_Operator.hpp.

Friends And Related Function Documentation

template<class OpScalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP< CrsMatrixMultiplyOp< OpScalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node > > createCrsMatrixMultiplyOp ( const Teuchos::RCP< const CrsMatrix< MatScalar, LocalOrdinal, GlobalOrdinal, Node > > &  A)
related

Non-member function to create a CrsMatrixMultiplyOp.

The function has the same template parameters of CrsMatrixMultiplyOp.

Parameters
A[in] The CrsMatrix instance to wrap in an CrsMatrixMultiplyOp.
Returns
The CrsMatrixMultiplyOp wrapper for the given CrsMatrix.

Definition at line 615 of file Tpetra_CrsMatrixMultiplyOp.hpp.

Member Data Documentation

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
const Teuchos::RCP<const crs_matrix_type> Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::matrix_
protected

The underlying CrsMatrix object.

Definition at line 154 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
LocalCrsMatrixOperator<Scalar, MatScalar, typename crs_matrix_type::device_type> Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::localMultiply_
protected

Implementation of local sparse matrix-vector multiply.

Definition at line 158 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::importMV_
mutableprotected

Column Map MultiVector used in apply().

This is a column Map MultiVector. It is used as the target of the forward mode Import operation (if necessary) in applyNonTranspose(), and the source of the reverse mode Export operation (if necessary) in applyTranspose(). Both of these methods create this MultiVector on demand if needed, and reuse it (if possible) for subsequent calls.

This is declared mutable because the apply() method is const, yet the method needs to cache the MultiVector for later use.

Definition at line 172 of file Tpetra_CrsMatrixMultiplyOp.hpp.

template<class Scalar , class MatScalar , class LocalOrdinal , class GlobalOrdinal , class Node >
Teuchos::RCP<MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > Tpetra::CrsMatrixMultiplyOp< Scalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node >::exportMV_
mutableprotected

Row Map MultiVector used in apply().

This is a row Map MultiVector. It is uses as the source of the forward mode Export operation (if necessary) in applyNonTranspose(), and the target of the reverse mode Import operation (if necessary) in applyTranspose(). Both of these methods create this MultiVector on demand if needed, and reuse it (if possible) for subsequent calls.

This is declared mutable because the apply() method is const, yet the method needs to cache the MultiVector for later use.

Definition at line 186 of file Tpetra_CrsMatrixMultiplyOp.hpp.


The documentation for this class was generated from the following file: