49 #ifndef XPETRA_CRSMATRIXWRAP_HPP
50 #define XPETRA_CRSMATRIXWRAP_HPP
79 template <class Scalar = Matrix<>::scalar_type,
80 class LocalOrdinal =
typename Matrix<Scalar>::local_ordinal_type,
82 typename Matrix<Scalar, LocalOrdinal>::global_ordinal_type,
84 typename Matrix<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
86 public Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>
92 #ifdef HAVE_XPETRA_TPETRA
97 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
98 #ifdef HAVE_XPETRA_TPETRA
99 typedef typename CrsMatrix::local_matrix_type local_matrix_type;
109 size_t maxNumEntriesPerRow,
149 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
150 #ifdef HAVE_XPETRA_TPETRA
162 CrsMatrixWrap(
const local_matrix_type& lclMatrix,
const RCP<const Map> &rowMap,
const RCP<const Map>& colMap,
163 const RCP<const Map>& domainMap = Teuchos::null,
const RCP<const Map>& rangeMap = Teuchos::null,
175 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
222 matrixData_->insertGlobalValues(globalRow, cols, vals);
234 matrixData_->insertLocalValues(localRow, cols, vals);
292 matrixData_->fillComplete(domainMap, rangeMap, params);
353 return matrixData_->getNumEntriesInLocalRow(localRow);
403 matrixData_->getLocalRowCopy(LocalRow, Indices, Values, NumEntries);
417 matrixData_->getGlobalRowView(GlobalRow, indices, values);
431 matrixData_->getLocalRowView(LocalRow, indices, values);
552 matrixData_->doImport(*sourceWrp.getCrsMatrix(), importer, CM);
559 matrixData_->doExport(*destWrp.getCrsMatrix(), importer, CM);
566 matrixData_->doImport(*sourceWrp.getCrsMatrix(), exporter, CM);
573 matrixData_->doExport(*destWrp.getCrsMatrix(), exporter, CM);
583 return "Xpetra::CrsMatrixWrap";
604 Teuchos::LabeledObject::setObjectLabel(objectLabel);
612 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
613 #ifdef HAVE_XPETRA_TPETRA
614 local_matrix_type getLocalMatrix ()
const {
620 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
635 #ifdef XPETRA_ENABLE_DEPRECATED_CODE
636 template<
class Node2>
638 #ifdef HAVE_XPETRA_TPETRA
641 if (tMatrix == Teuchos::null)
647 return Teuchos::null;
688 #define XPETRA_CRSMATRIXWRAP_SHORT
689 #endif //XPETRA_CRSMATRIXWRAP_DECL_HPP
void setObjectLabel(const std::string &objectLabel)
RCP< Map< LocalOrdinal, GlobalOrdinal, Node2 > > clone(const Map< LocalOrdinal, GlobalOrdinal, Node1 > &map, const RCP< Node2 > &node2)
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Right scale matrix using the given vector entries.
virtual void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalar.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
Xpetra::TpetraCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraCrsMatrix
virtual ~CrsMatrixWrap()
Destructor.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
CrsMatrixWrap(const RCP< const Map > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying (possibly different) number of entries in each row.
RCP< CrsMatrix > getCrsMatrix() const
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
void doExport(const Matrix &dest, const Xpetra::Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
virtual void apply(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
bool hasCrsGraph() const
Supports the getCrsGraph() call.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
CrsMatrixWrap(RCP< CrsMatrix > matrix)
void getLocalDiagCopy(Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
Exception throws to report errors in the internal logical of the program.
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map > &newMap)
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Get Frobenius norm of the matrix.
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
CrsMatrixWrap(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row.
RCP< const CrsGraph > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void doExport(const Matrix &dest, const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
Teuchos::Hashtable< viewLabel_t, RCP< MatrixView > > operatorViewTable_
const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
void updateDefaultView() const
Xpetra::MatrixView< LocalOrdinal, GlobalOrdinal, Node > MatrixView
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
void doImport(const Matrix &source, const Xpetra::Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void doImport(const Matrix &source, const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
CrsMatrixWrap(const RCP< const Map > &rowMap, const RCP< const Map > &colMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row and column map.
std::string description() const
Return a simple one-line description of this object.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
viewLabel_t defaultViewLabel_
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > CrsGraph
const viewLabel_t & GetCurrentViewLabel() const
void getLocalDiagCopy(Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row idices.
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
viewLabel_t currentViewLabel_
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
size_t global_size_t
Global size_t object.
static const EVerbosityLevel verbLevel_default
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
CrsMatrixWrap(const RCP< const Map > &rowMap, const RCP< const Map > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row and column map.
void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< Teuchos::ParameterList > ¶ms=null)
Signal that data entry is complete, specifying domain and range maps.
RCP< CrsMatrix > matrixData_
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void resumeFill(const RCP< ParameterList > ¶ms=null)
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
CrsMatrixWrap(const RCP< const CrsGraph > &graph, const RCP< ParameterList > ¶mList=Teuchos::null)
Concrete implementation of Xpetra::Matrix.
global_size_t getGlobalNumCols() const
Returns the number of global columns in the matrix.
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
CombineMode
Xpetra::Combine Mode enumerable type.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Left scale matrix using the given vector entries.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > CrsMatrix
const viewLabel_t & GetDefaultViewLabel() const
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > Matrix
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
Xpetra::CrsMatrixFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > CrsMatrixFactory
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
Xpetra-specific matrix class.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
const RCP< const Map > & getColMap(viewLabel_t viewLabel) const
Returns the Map that describes the column distribution in this matrix.