49 #ifndef XPETRA_CRSMATRIXWRAP_HPP 50 #define XPETRA_CRSMATRIXWRAP_HPP 64 #include <Teuchos_SerialDenseMatrix.hpp> 65 #include <Teuchos_Hashtable.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,
119 const ArrayRCP<const size_t>& NumEntriesPerRowToAlloc,
149 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 150 #ifdef HAVE_XPETRA_TPETRA 151 CrsMatrixWrap(
const RCP<const Map> &rowMap,
const RCP<const Map>& colMap,
const local_matrix_type& lclMatrix,
const Teuchos::RCP<Teuchos::ParameterList>& params = null)
163 #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." 178 CrsMatrixWrap(
const RCP<const CrsGraph>& graph,
const RCP<ParameterList>& paramList = Teuchos::null)
209 void insertGlobalValues(GlobalOrdinal globalRow,
const ArrayView<const GlobalOrdinal> &cols,
const ArrayView<const Scalar> &vals) {
210 matrixData_->insertGlobalValues(globalRow, cols, vals);
221 void insertLocalValues(LocalOrdinal localRow,
const ArrayView<const LocalOrdinal> &cols,
const ArrayView<const Scalar> &vals) {
222 matrixData_->insertLocalValues(localRow, cols, vals);
232 const ArrayView<const GlobalOrdinal> &cols,
233 const ArrayView<const Scalar> &vals) {
matrixData_->replaceGlobalValues(globalRow, cols, vals); }
240 const ArrayView<const LocalOrdinal> &cols,
241 const ArrayView<const Scalar> &vals) {
matrixData_->replaceLocalValues(localRow, cols, vals); }
279 void fillComplete(
const RCP<const Map> &domainMap,
const RCP<const Map> &rangeMap,
const RCP<Teuchos::ParameterList> ¶ms = null) {
280 matrixData_->fillComplete(domainMap, rangeMap, params);
341 return matrixData_->getNumEntriesInLocalRow(localRow);
401 const ArrayView<LocalOrdinal> &Indices,
402 const ArrayView<Scalar> &Values,
405 matrixData_->getLocalRowCopy(LocalRow, Indices, Values, NumEntries);
418 void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &indices, ArrayView<const Scalar> &values)
const {
419 matrixData_->getGlobalRowView(GlobalRow, indices, values);
432 void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal> &indices, ArrayView<const Scalar> &values)
const {
433 matrixData_->getLocalRowView(LocalRow, indices, values);
499 Teuchos::ETransp mode = Teuchos::NO_TRANS,
500 Scalar alpha = ScalarTraits<Scalar>::one(),
501 Scalar beta = ScalarTraits<Scalar>::zero())
const {
508 RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
getDomainMap()
const {
514 RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
getRangeMap()
const {
541 const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const {
549 matrixData_->doImport(*sourceWrp.getCrsMatrix(), importer, CM);
556 matrixData_->doExport(*destWrp.getCrsMatrix(), importer, CM);
563 matrixData_->doImport(*sourceWrp.getCrsMatrix(), exporter, CM);
570 matrixData_->doExport(*destWrp.getCrsMatrix(), exporter, CM);
580 return "Xpetra::CrsMatrixWrap";
584 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const {
598 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 599 #ifdef HAVE_XPETRA_TPETRA 600 local_matrix_type getLocalMatrix ()
const {
606 #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." 620 template<
class Node2>
621 RCP<Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node2> >
clone(
const RCP<Node2> &node2)
const {
622 #ifdef HAVE_XPETRA_TPETRA 623 RCP<const Xpetra::TpetraCrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > tMatrix =
625 if (tMatrix == Teuchos::null)
631 return Teuchos::null;
671 #define XPETRA_CRSMATRIXWRAP_SHORT 672 #endif //XPETRA_CRSMATRIXWRAP_DECL_HPP
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Right scale matrix using the given vector entries.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
virtual void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalar.
Xpetra::TpetraCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraCrsMatrix
virtual ~CrsMatrixWrap()
Destructor.
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.
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).
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.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
LocalOrdinal local_ordinal_type
CrsMatrixWrap(RCP< CrsMatrix > matrix)
Exception throws to report errors in the internal logical of the program.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map > &newMap)
global_size_t getGlobalNumCols() const
Returns the number of global columns in the matrix.
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...
CrsMatrixWrap(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row.
void doExport(const Matrix &dest, const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
Teuchos::Hashtable< viewLabel_t, RCP< MatrixView > > operatorViewTable_
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Get Frobenius norm of the matrix.
const RCP< const Map > & getColMap(viewLabel_t viewLabel) const
Returns the Map that describes the column distribution in this matrix.
Xpetra::MatrixView< LocalOrdinal, GlobalOrdinal, Node > MatrixView
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
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.
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
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.
viewLabel_t defaultViewLabel_
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > CrsGraph
const viewLabel_t & GetDefaultViewLabel() const
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.
const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
viewLabel_t currentViewLabel_
RCP< CrsMatrix > getCrsMatrix() const
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.
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.
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
RCP< const CrsGraph > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
size_t global_size_t
Global size_t object.
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_
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 updateDefaultView() const
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void resumeFill(const RCP< ParameterList > ¶ms=null)
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 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.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
CrsMatrixWrap(const RCP< const CrsGraph > &graph, const RCP< ParameterList > ¶mList=Teuchos::null)
Concrete implementation of Xpetra::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.
global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
CombineMode
Xpetra::Combine Mode enumerable type.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Left scale matrix using the given vector entries.
std::string description() const
Return a simple one-line description of this object.
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...
RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > clone(const RCP< Node2 > &node2) const
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 fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > 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.
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
Xpetra-specific matrix class.
GlobalOrdinal global_ordinal_type