Tpetra Matrix/Vector Services  Version of the Day
Namespaces | Functions
TpetraExt_MatrixMatrix_def.hpp File Reference
#include "TpetraExt_MatrixMatrix_decl.hpp"
#include "Teuchos_VerboseObject.hpp"
#include "Teuchos_Array.hpp"
#include "Tpetra_Util.hpp"
#include "Tpetra_ConfigDefs.hpp"
#include "Tpetra_CrsMatrix.hpp"
#include "TpetraExt_MMHelpers_def.hpp"
#include "Tpetra_RowMatrixTransposer.hpp"
#include "Tpetra_Map.hpp"
#include <algorithm>
#include "Teuchos_FancyOStream.hpp"

Go to the source code of this file.

Namespaces

 Tpetra
 Namespace Tpetra contains the class and methods constituting the Tpetra library.
 

Functions

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node , class SpMatOps >
void Tpetra::MatrixMatrix::Multiply (const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &A, bool transposeA, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &B, bool transposeB, CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &C, bool call_FillComplete_on_result=true)
 Sparse matrix-matrix multiply. More...
 
template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node , class SpMatOps >
void Tpetra::MatrixMatrix::Add (const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &A, bool transposeA, Scalar scalarA, CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &B, Scalar scalarB)
 
template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node , class SpMatOps >
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > > Tpetra::MatrixMatrix::add (const Scalar &alpha, const bool transposeA, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &A, const Scalar &beta, const bool transposeB, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &B, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
 Compute the sparse matrix sum C = scalarA * Op(A) + scalarB * Op(B), where Op(X) is either X or its transpose. More...
 
template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node , class SpMatOps >
void Tpetra::MatrixMatrix::Add (const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &A, bool transposeA, Scalar scalarA, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &B, bool transposeB, Scalar scalarB, RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > > C)
 Compute the sparse matrix sum C = scalarA * Op(A) + scalarB * Op(B), where Op(X) is either X or its transpose. More...
 

Detailed Description

The implementations for the members of class Tpetra::MatrixMatrixMultiply and related non-member constructors.

Definition in file TpetraExt_MatrixMatrix_def.hpp.

Function Documentation

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node , class SpMatOps >
void Tpetra::MatrixMatrix::Multiply ( const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  A,
bool  transposeA,
const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  B,
bool  transposeB,
CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  C,
bool  call_FillComplete_on_result = true 
)

Sparse matrix-matrix multiply.

Given CrsMatrix instances A and B, compute the product C = A*B, overwriting an existing CrsMatrix instance C with the result.

Precondition
All three matrices A, B, and C must have uniquely owned row Maps.
On input, C must have the same row Map as A.
A and B must be fill complete.
If C has a range Map on input, then A and C must have the same range Maps.
If C has a domain Map on input, then B and C must have the same domain Maps.

For the latter two preconditions, recall that a matrix does not have a domain or range Map unless fillComplete has been called on it at least once.

Parameters
A[in] fill-complete sparse matrix.
transposeA[in] Whether to use transpose of matrix A.
B[in] fill-complete sparse matrix.
transposeB[in] Whether to use transpose of matrix B.
C[in/out] On entry to this method, if C is fill complete, then C's graph must have the correct structure, that is, its structure must equal the structure of A*B. On exit, C will be fill complete, unless the last argument to this function is false.
call_FillComplete_on_result[in] Optional argument; defaults to true. If false, C will not be fill complete on output.

Definition at line 74 of file TpetraExt_MatrixMatrix_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node , class SpMatOps >
void Tpetra::MatrixMatrix::Add ( const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  A,
bool  transposeA,
Scalar  scalarA,
CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  B,
Scalar  scalarB 
)

Given CrsMatrix objects A and B, form the sum B = a*A + b*B Currently not functional.

Parameters
AInput, must already have had 'FillComplete()' called.
transposeAInput, whether to use transpose of matrix A.
scalarAInput, scalar multiplier for matrix A.
BResult. On entry to this method, it doesn't matter whether FillComplete() has already been called on B or not. If it has, then B's graph must already contain all nonzero locations that will be produced when forming the sum.
scalarBInput, scalar multiplier for matrix B.

Definition at line 234 of file TpetraExt_MatrixMatrix_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node , class SpMatOps >
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > > Tpetra::MatrixMatrix::add ( const Scalar &  alpha,
const bool  transposeA,
const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  A,
const Scalar &  beta,
const bool  transposeB,
const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  B,
const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &  domainMap = Teuchos::null,
const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &  rangeMap = Teuchos::null,
const Teuchos::RCP< Teuchos::ParameterList > &  params = Teuchos::null 
)

Compute the sparse matrix sum C = scalarA * Op(A) + scalarB * Op(B), where Op(X) is either X or its transpose.

This version of sparse matrix-matrix add returns a new CrsMatrix instance, rather than using an existing instance for the result. The returned matrix is fill complete, with the given domain and range Maps. It is correct (though less efficient) for A and B to have different row Maps; the returned matrix will have the same row Map as the row Map of B.

Precondition
If A and B are both fill complete, then they must have the same domain and range Maps.
Parameters
scalarA[in] Scalar multiplier for A in the sum.
transposeA[in] If true, use the transpose of A.
A[in] The first input matrix.
scalarB[in] Scalar multiplier for B in the sum.
transposeB[in] If true, use the transpose of B.
B[in] The second input matrix.
domainMap[in] Domain Map of C (on output). If null or not provided, this defaults to the row Map of B.
rangeMap[in] Range Map of C (on output). If null or not provided, this defaults to the row Map of B.
params[in/out] Same as the parameters of RowMatrix::add.

See the documentation of RowMatrix::add for a more detailed discussion of the optional parameters.

Definition at line 304 of file TpetraExt_MatrixMatrix_def.hpp.

template<class Scalar , class LocalOrdinal , class GlobalOrdinal , class Node , class SpMatOps >
void Tpetra::MatrixMatrix::Add ( const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  A,
bool  transposeA,
Scalar  scalarA,
const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > &  B,
bool  transposeB,
Scalar  scalarB,
RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, SpMatOps > >  C 
)

Compute the sparse matrix sum C = scalarA * Op(A) + scalarB * Op(B), where Op(X) is either X or its transpose.

Precondition
Both input matrices A and B must be fill complete. That is, their fillComplete() method must have been called at least once, without an intervening call to resumeFill().
Parameters
A[in] The first input matrix.
transposeA[in] If true, use the transpose of A.
scalarA[in] Scalar multiplier for A in the sum.
B[in] The second input matrix.
transposeB[in] If true, use the transpose of B.
scalarB[in] Scalar multiplier for B in the sum.
C[in/out] On entry, C may be either null or a valid matrix. If C is null on input, this function will allocate a new CrsMatrix to contain the sum. If C is not null and is fill complete, then this function assumes that the sparsity pattern of the sum is fixed and compatible with the sparsity pattern of A + B. If C is not null and is not fill complete, then this function returns without calling fillComplete on C.
Warning
The case where C == null on input does not actually work. In order for it to work, we would need to change the interface of this function (for example, to pass in C as a (pointer or nonconst reference) to a Teuchos::RCP). Please use add() (which see) if you want matrix-matrix add to return a new instance of CrsMatrix.

Definition at line 399 of file TpetraExt_MatrixMatrix_def.hpp.