49 #ifndef XPETRA_MATRIX_HPP
50 #define XPETRA_MATRIX_HPP
93 template <
class Scalar,
94 class LocalOrdinal = int,
95 class GlobalOrdinal = LocalOrdinal,
103 #ifdef HAVE_XPETRA_TPETRA
135 if(A->IsView(viewLabel)) {
141 rangeMap = (transposeA) ? nonConstA->getColMap() : nonConstA->getRowMap();
142 domainMap = (transposeA) ? nonConstA->getRowMap() : nonConstA->getColMap();
143 oldView = nonConstA->SwitchToView(oldView);
144 }
else rangeMap = (transposeA) ? A->getDomainMap() : A->getRangeMap();
146 if(B != Teuchos::null ) {
149 if(B->IsView(viewLabel)) {
153 domainMap = (transposeB) ? nonConstB->getRowMap() : nonConstB->getColMap();
154 oldView = nonConstB->SwitchToView(oldView);
155 }
else domainMap = (transposeB) ? B->getRangeMap() : B->getDomainMap();
172 out <<
"views associated with this operator" << std::endl;
173 for (
int i=0; i<viewLabels.
size(); ++i)
174 out << viewLabels[i] << std::endl;
253 virtual void scale(
const Scalar &alpha)= 0;
532 std::vector<size_t> stridingInfo;
533 stridingInfo.push_back(Teuchos::as<size_t>(blksize));
534 LocalOrdinal stridedBlockId = -1;
548 CreateView(
"stridedMaps", stridedRangeMap, stridedDomainMap);
554 if(
IsView(
"stridedMaps")==
true) {
558 TEUCHOS_TEST_FOR_EXCEPTION(domainMap == Teuchos::null,
Exceptions::BadCast,
"Xpetra::Matrix::GetFixedBlockSize(): domainMap is not of type StridedMap");
559 TEUCHOS_TEST_FOR_EXCEPTION(domainMap->getFixedBlockSize() != rangeMap->getFixedBlockSize(),
Exceptions::RuntimeError,
"Xpetra::Matrix::GetFixedBlockSize(): block size of rangeMap and domainMap are different.");
560 return Teuchos::as<LocalOrdinal>(domainMap->getFixedBlockSize());
590 #define XPETRA_MATRIX_SHORT
591 #endif //XPETRA_MATRIX_DECL_HPP
virtual global_size_t getGlobalNumCols() const =0
Returns the number of global columns in the matrix.
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
virtual void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const =0
Get a copy of the diagonal entries owned by this node, with local row idices.
const viewLabel_t SwitchToView(const viewLabel_t viewLabel)
virtual void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Replace matrix entries, using local IDs.
virtual void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Insert matrix entries, using global IDs.
virtual void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< ParameterList > ¶ms=null)=0
Signal that data entry is complete, specifying domain and range maps.
virtual bool isFillComplete() const =0
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
virtual global_size_t getGlobalNumDiags() const =0
Returns the number of global diagonal entries, based on global row/column index comparisons.
virtual bool isGloballyIndexed() const =0
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
virtual void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const =0
Extract a const, non-persisting view of global indices in a specified row of the matrix.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsGraph
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void RemoveView(const viewLabel_t viewLabel)
virtual size_t getNodeNumRows() const =0
Returns the number of matrix rows owned on the calling node.
virtual void removeEmptyProcessesInPlace(const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)=0
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsMatrix
virtual ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const =0
Get Frobenius norm of the matrix.
virtual void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const =0
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
Exception throws to report errors in the internal logical of the program.
virtual size_t getNodeMaxNumRowEntries() const =0
Returns the maximum number of entries across all rows/columns on this node.
Xpetra::MatrixView< Scalar, LocalOrdinal, GlobalOrdinal, Node > MatrixView
virtual const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const =0
virtual const RCP< const Map > & getRowMap(viewLabel_t viewLabel) const
Returns the Map that describes the row distribution in this matrix.
virtual const RCP< const Map > & getColMap(viewLabel_t viewLabel) const
Returns the Map that describes the column distribution in this matrix.
Exception indicating invalid cast attempted.
virtual void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Insert matrix entries, using local IDs.
const viewLabel_t SwitchToDefaultView()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
Implements DistObject interface.
virtual void doExport(const Matrix &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)=0
Export.
virtual global_size_t getGlobalNumRows() const =0
Returns the number of global rows in this matrix.
const viewLabel_t & GetCurrentViewLabel() const
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const =0
Print the object with some verbosity level to an FancyOStream object.
virtual void doImport(const Matrix &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)=0
Import.
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
static Teuchos::RCP< StridedMap< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, LocalGlobal lg=Xpetra::GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::Details::getNode< Node >())
Map constructor with Xpetra-defined contiguous uniform distribution.
virtual void SetMaxEigenvalueEstimate(Scalar const &sigma)
viewLabel_t currentViewLabel_
virtual const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const =0
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
virtual RCP< const CrsGraph > getCrsGraph() const =0
Returns the CrsGraph associated with this matrix.
Teuchos::Hashtable< viewLabel_t, RCP< MatrixView > > operatorViewTable_
virtual Scalar GetMaxEigenvalueEstimate() const
virtual std::string description() const =0
Return a simple one-line description of this object.
virtual global_size_t getGlobalNumEntries() const =0
Returns the global number of entries in this matrix.
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
int getOutputToRootOnly() const
virtual 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 =0
Computes the sparse matrix-multivector multiplication.
virtual size_t getNodeNumEntries() const =0
Returns the local number of entries in this matrix.
void PrintViews(Teuchos::FancyOStream &out) const
Print all of the views associated with the Matrix.
void CreateView(const viewLabel_t viewLabel, const RCP< const Matrix > &A, bool transposeA=false, const RCP< const Matrix > &B=Teuchos::null, bool transposeB=false)
size_t global_size_t
Global size_t object.
virtual size_t getGlobalMaxNumRowEntries() const =0
Returns the maximum number of entries across all rows/columns on all nodes.
static const EVerbosityLevel verbLevel_default
virtual void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const =0
Extract a const, non-persisting view of local indices in a specified row of the matrix.
virtual bool isLocallyIndexed() const =0
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
virtual const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
viewLabel_t defaultViewLabel_
LocalOrdinal GetFixedBlockSize() const
Xpetra::TpetraCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > TpetraCrsMatrix
void SetFixedBlockSize(LocalOrdinal blksize)
virtual void setAllToScalar(const Scalar &alpha)=0
Set all matrix entries equal to scalar.
CombineMode
Xpetra::Combine Mode enumerable type.
bool IsView(const viewLabel_t viewLabel) const
virtual void scale(const Scalar &alpha)=0
Scale the current values of a matrix, this = alpha*this.
virtual ~Matrix()
Destructor.
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0
Returns the current number of entries on this node in the specified local row.
virtual size_t getNodeNumDiags() const =0
Returns the number of local diagonal entries, based on global row/column index comparisons.
const viewLabel_t & GetDefaultViewLabel() const
virtual void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Replace matrix entries, using global IDs.
virtual void resumeFill(const RCP< ParameterList > ¶ms=null)=0
Xpetra-specific matrix class.
Class that stores a strided map.
Xpetra::CrsMatrixFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsMatrixFactory