10#ifndef TPETRA_CRSMATRIXMULTIPLYOP_HPP 
   11#define TPETRA_CRSMATRIXMULTIPLYOP_HPP 
   19#include "Tpetra_CrsMatrix.hpp" 
   23#include "Tpetra_LocalCrsMatrixOperator.hpp" 
   63template <
class Scalar,
 
   77  using local_matrix_device_type =
 
   78      typename crs_matrix_type::local_matrix_device_type;
 
  103        Teuchos::ETransp 
mode = Teuchos::NO_TRANS,
 
  104        Scalar alpha          = Teuchos::ScalarTraits<Scalar>::one(),
 
  105        Scalar beta           = Teuchos::ScalarTraits<Scalar>::zero())
 const override {
 
  107                               Teuchos::typeName(*
this) << 
"::apply(): underlying matrix is not fill-complete.");
 
  109                               Teuchos::typeName(*
this) << 
"::apply(X,Y): X and Y must have the same number of vectors.");
 
  111                               Teuchos::typeName(*
this) << 
"::apply() does not currently support transposed multiplications for complex scalar types.");
 
  112    if (
mode == Teuchos::NO_TRANS) {
 
 
  130    return matrix_->getDomainMap();
 
 
  143  using local_matrix_op_t =
 
  145                             typename crs_matrix_type::device_type>;
 
  148  const Teuchos::RCP<const crs_matrix_type> 
matrix_;
 
  162  mutable Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > 
importMV_;
 
  176  mutable Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > 
exportMV_;
 
  183                 Teuchos::ETransp 
mode,
 
  191    using STS         = Teuchos::ScalarTraits<Scalar>;
 
  214      X = Teuchos::rcp(
new MV(
X_in, Teuchos::Copy));
 
  217      X = Teuchos::rcpFromRef(
X_in);
 
  244    auto X_lcl = 
X->getLocalViewDevice(Access::ReadOnly);
 
  256        Y_in.putScalar(STS::zero());
 
  265      if (!
Y_in.isConstantStride() || 
X.getRawPtr() == &
Y_in) {
 
  270          Y_lcl = 
Y.getLocalViewDevice(Access::OverwriteAll);
 
  272          Y_lcl = 
Y.getLocalViewDevice(Access::ReadWrite);
 
  279          Y_lcl = 
Y_in.getLocalViewDevice(Access::OverwriteAll);
 
  281          Y_lcl = 
Y_in.getLocalViewDevice(Access::ReadWrite);
 
 
  298    using Teuchos::NO_TRANS;
 
  301    using Teuchos::rcp_const_cast;
 
  302    using Teuchos::rcpFromRef;
 
  306    typedef Teuchos::ScalarTraits<Scalar> STS;
 
  309    if (
alpha == STS::zero()) {
 
  310      if (
beta == STS::zero()) {
 
  311        Y_in.putScalar(STS::zero());
 
  312      } 
else if (
beta != STS::one()) {
 
  338        (!
Y_in.isDistributed() && 
matrix_->getComm()->getSize() != 1);
 
  356      if (!
X_in.isConstantStride()) {
 
  372      ProfilingRegion 
regionImport(
"Tpetra::CrsMatrixMultiplyOp::apply: Import");
 
  400      auto Y_lcl = 
Y_rowMap->getLocalViewDevice(Access::OverwriteAll);
 
  405        ProfilingRegion 
regionExport(
"Tpetra::CrsMatrixMultiplyOp::apply: Export");
 
  412          Y_in.putScalar(STS::zero());
 
  440        if (
beta != STS::zero()) {
 
  454          Y_lcl = 
Y_in.getLocalViewDevice(Access::OverwriteAll);
 
  456          Y_lcl = 
Y_in.getLocalViewDevice(Access::ReadWrite);
 
  467      ProfilingRegion 
regionReduce(
"Tpetra::CrsMatrixMultiplyOp::apply: Reduce Y");
 
 
  494                          const bool force = 
false)
 const {
 
  555  getRowMapMultiVector(
const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Y_rangeMap,
 
  556                       const bool force = 
false)
 const {
 
  560    typedef Export<LocalOrdinal, GlobalOrdinal, Node> export_type;
 
  562    const size_t numVecs            = Y_rangeMap.getNumVectors();
 
  563    RCP<const export_type> exporter = 
matrix_->getGraph()->getExporter();
 
  564    RCP<const map_type> rowMap      = 
matrix_->getRowMap();
 
  576    if (!exporter.is_null() || force) {
 
  578        Y_rowMap  = rcp(
new MV(rowMap, numVecs));
 
 
  595template <
class OpScalar,
 
  601    CrsMatrixMultiplyOp<OpScalar, MatScalar, LocalOrdinal, GlobalOrdinal, Node> >
 
  607  return Teuchos::rcp(
new op_type(
A));
 
 
Forward declaration of Tpetra::CrsMatrixMultiplyOp.
 
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
 
Declaration of Tpetra::Details::Profiling, a scope guard for Kokkos Profiling.
 
Stand-alone utility functions and macros.
 
A class for wrapping a CrsMatrix multiply in a Operator.
 
bool hasTransposeApply() const override
Whether this Operator's apply() method can apply the transpose or conjugate transpose.
 
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.
 
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > exportMV_
Row Map MultiVector used in apply().
 
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, , or .
 
Teuchos::RCP< const map_type > getRangeMap() const override
The range Map of this Operator.
 
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.
 
CrsMatrixMultiplyOp(const Teuchos::RCP< const crs_matrix_type > &A)
Constructor.
 
~CrsMatrixMultiplyOp() override=default
Destructor (virtual for memory safety of derived classes).
 
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.
 
const Teuchos::RCP< const crs_matrix_type > matrix_
The underlying CrsMatrix object.
 
Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > importMV_
Column Map MultiVector used in apply().
 
Teuchos::RCP< const map_type > getDomainMap() const override
The domain Map of this Operator.
 
Struct that holds views of the contents of a CrsMatrix.
 
Abstract interface for local operators (e.g., matrices and preconditioners).
 
One or more distributed dense vectors.
 
Abstract interface for operators (e.g., matrices and preconditioners).
 
Namespace Tpetra contains the class and methods constituting the Tpetra library.
 
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
Copy the contents of the MultiVector src into dst.
 
@ ADD_ASSIGN
Accumulate new values into existing values (may not be supported in all classes)
 
@ INSERT
Insert new values that don't currently exist.