49 #ifndef XPETRA_CRSMATRIXWRAP_HPP 50 #define XPETRA_CRSMATRIXWRAP_HPP 65 #include <Teuchos_SerialDenseMatrix.hpp> 66 #include <Teuchos_Hashtable.hpp> 80 template <
class Scalar,
81 class LocalOrdinal = int,
82 class GlobalOrdinal = LocalOrdinal,
85 class CrsMatrixWrap :
public Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node,LocalMatOps> {
91 #ifdef HAVE_XPETRA_TPETRA 177 void insertGlobalValues(GlobalOrdinal globalRow,
const ArrayView<const GlobalOrdinal> &cols,
const ArrayView<const Scalar> &vals) {
178 matrixData_->insertGlobalValues(globalRow, cols, vals);
189 void insertLocalValues(LocalOrdinal localRow,
const ArrayView<const LocalOrdinal> &cols,
const ArrayView<const Scalar> &vals) {
190 matrixData_->insertLocalValues(localRow, cols, vals);
200 const ArrayView<const GlobalOrdinal> &cols,
201 const ArrayView<const Scalar> &vals) {
matrixData_->replaceGlobalValues(globalRow, cols, vals); }
208 const ArrayView<const LocalOrdinal> &cols,
209 const ArrayView<const Scalar> &vals) {
matrixData_->replaceLocalValues(localRow, cols, vals); }
247 void fillComplete(
const RCP<const Map> &domainMap,
const RCP<const Map> &rangeMap,
const RCP<Teuchos::ParameterList> ¶ms = null) {
248 matrixData_->fillComplete(domainMap, rangeMap, params);
309 return matrixData_->getNumEntriesInLocalRow(localRow);
369 const ArrayView<LocalOrdinal> &Indices,
370 const ArrayView<Scalar> &Values,
373 matrixData_->getLocalRowCopy(LocalRow, Indices, Values, NumEntries);
386 void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &indices, ArrayView<const Scalar> &values)
const {
387 matrixData_->getGlobalRowView(GlobalRow, indices, values);
400 void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal> &indices, ArrayView<const Scalar> &values)
const {
401 matrixData_->getLocalRowView(LocalRow, indices, values);
446 Teuchos::ETransp mode = Teuchos::NO_TRANS,
447 Scalar alpha = ScalarTraits<Scalar>::one(),
448 Scalar beta = ScalarTraits<Scalar>::zero())
const {
455 const RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
getDomainMap()
const {
461 const RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
getRangeMap()
const {
470 const RCP<const Map> &
getColMap(viewLabel_t viewLabel)
const {
488 const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const {
496 matrixData_->doImport(*sourceWrp.getCrsMatrix(), importer, CM);
503 matrixData_->doExport(*destWrp.getCrsMatrix(), importer, CM);
510 matrixData_->doImport(*sourceWrp.getCrsMatrix(), exporter, CM);
517 matrixData_->doExport(*destWrp.getCrsMatrix(), exporter, CM);
527 return "Xpetra::CrsMatrixWrap";
531 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const {
591 #define XPETRA_CRSMATRIXWRAP_SHORT 592 #endif //XPETRA_CRSMATRIXWRAP_DECL_HPP void doImport(const Matrix &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
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.
const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsMatrix
CrsMatrixWrap(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row.
Exception throws to report errors in the internal logical of the program.
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 insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsGraph
global_size_t getGlobalNumCols() const
Returns the number of global columns in the matrix.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
void doExport(const Matrix &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
Xpetra::MatrixView< LocalOrdinal, GlobalOrdinal, Node > MatrixView
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
Xpetra::CrsMatrixFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsMatrixFactory
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
const RCP< const Map > & getColMap(viewLabel_t viewLabel) const
Returns the Map that describes the column distribution in this matrix.
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > Matrix
const 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...
RCP< CrsMatrix > getCrsMatrix() const
RCP< CrsMatrix > matrixData_
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 resumeFill(const RCP< ParameterList > ¶ms=null)
const viewLabel_t & GetCurrentViewLabel() const
RCP< const CrsGraph > getCrsGraph() const
Returns the CrsGraph associated with this 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.
viewLabel_t currentViewLabel_
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Get Frobenius norm of the matrix.
global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
Teuchos::Hashtable< viewLabel_t, RCP< MatrixView > > operatorViewTable_
Xpetra::TpetraCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > TpetraCrsMatrix
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
size_t global_size_t
Global size_t object.
virtual void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalar.
const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
CrsMatrixWrap(RCP< CrsMatrix > matrix)
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.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
viewLabel_t defaultViewLabel_
Concrete implementation of Xpetra::Matrix.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
void doExport(const Matrix &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
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.
CombineMode
Xpetra::Combine Mode enumerable type.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
virtual ~CrsMatrixWrap()
Destructor.
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > > 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 isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
const viewLabel_t & GetDefaultViewLabel() const
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map > &newMap)
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 doImport(const Matrix &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void updateDefaultView() const
const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
std::string description() const
Return a simple one-line description of this object.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, 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.
Xpetra-specific matrix class.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row idices.
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.
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.