Go to the documentation of this file.
49 #ifndef XPETRA_CRSMATRIXWRAP_HPP
50 #define XPETRA_CRSMATRIXWRAP_HPP
79 template <class Scalar = Matrix<>::scalar_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);
551 const CrsMatrixWrap & sourceWrp = dynamic_cast<const CrsMatrixWrap &>(source);
552 matrixData_->doImport(*sourceWrp.getCrsMatrix(), importer, CM);
558 const CrsMatrixWrap & destWrp = dynamic_cast<const CrsMatrixWrap &>(dest);
559 matrixData_->doExport(*destWrp.getCrsMatrix(), importer, CM);
565 const CrsMatrixWrap & sourceWrp = dynamic_cast<const CrsMatrixWrap &>(source);
566 matrixData_->doImport(*sourceWrp.getCrsMatrix(), exporter, CM);
572 const CrsMatrixWrap & destWrp = dynamic_cast<const CrsMatrixWrap &>(dest);
573 matrixData_->doExport(*destWrp.getCrsMatrix(), exporter, CM);
583 return "Xpetra::CrsMatrixWrap";
601 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
602 #ifdef HAVE_XPETRA_TPETRA
603 local_matrix_type getLocalMatrix ()
const {
609 #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."
625 template<
class Node2>
627 #ifdef HAVE_XPETRA_TPETRA
630 if (tMatrix == Teuchos::null)
636 return Teuchos::null;
676 #define XPETRA_CRSMATRIXWRAP_SHORT
677 #endif //XPETRA_CRSMATRIXWRAP_DECL_HPP
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > CrsMatrix
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
viewLabel_t currentViewLabel_
virtual void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalar.
viewLabel_t defaultViewLabel_
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
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.
virtual ~CrsMatrixWrap()
Destructor.
size_t global_size_t
Global size_t object.
CrsMatrixWrap(RCP< CrsMatrix > matrix)
CrsMatrixWrap(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
const viewLabel_t & GetDefaultViewLabel() const
void doExport(const Matrix &dest, const Xpetra::Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Right scale matrix using the given vector entries.
Xpetra::MatrixView< LocalOrdinal, GlobalOrdinal, Node > MatrixView
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.
const viewLabel_t & GetCurrentViewLabel() const
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.
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...
void doExport(const Matrix &dest, const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
void doImport(const Matrix &source, const Xpetra::Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
CombineMode
Xpetra::Combine Mode enumerable type.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Get Frobenius norm of the matrix.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > CrsGraph
RCP< CrsMatrix > getCrsMatrix() const
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map > &newMap)
global_size_t getGlobalNumCols() const
Returns the number of global columns in the matrix.
Xpetra-specific matrix class.
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 getNodeNumEntries() const
Returns the local number of entries in this matrix.
Teuchos::Hashtable< viewLabel_t, RCP< MatrixView > > operatorViewTable_
Exception throws to report errors in the internal logical of the program.
const RCP< const Map > & getColMap(viewLabel_t viewLabel) const
Returns the Map that describes the column distribution in this matrix.
RCP< CrsMatrix > matrixData_
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
void doImport(const Matrix &source, const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
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.
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.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
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 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 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.
void updateDefaultView() const
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
Concrete implementation of Xpetra::Matrix.
const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
RCP< const CrsGraph > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
std::string description() const
Return a simple one-line description of this object.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > clone(const RCP< Node2 > &node2) const
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > Matrix
bool hasCrsGraph() const
Supports the getCrsGraph() call.
Xpetra::CrsMatrixFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > CrsMatrixFactory
LocalOrdinal local_ordinal_type
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
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.
GlobalOrdinal global_ordinal_type
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.
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...
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
CrsMatrixWrap(const RCP< const CrsGraph > &graph, const RCP< ParameterList > ¶mList=Teuchos::null)
global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void resumeFill(const RCP< ParameterList > ¶ms=null)
Xpetra::TpetraCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraCrsMatrix
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Left scale matrix using the given vector entries.
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode.
static const EVerbosityLevel verbLevel_default
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.