46 #ifndef XPETRA_BLOCKEDCRSMATRIX_HPP
47 #define XPETRA_BLOCKEDCRSMATRIX_HPP
57 #include "Xpetra_MapFactory.hpp"
59 #include "Xpetra_BlockedMultiVector.hpp"
60 #include "Xpetra_MultiVectorFactory.hpp"
61 #include "Xpetra_BlockedVector.hpp"
66 #include "Xpetra_MapExtractor.hpp"
70 #include "Xpetra_CrsMatrixWrap.hpp"
72 #ifdef HAVE_XPETRA_THYRA
73 #include <Thyra_ProductVectorSpaceBase.hpp>
74 #include <Thyra_VectorSpaceBase.hpp>
75 #include <Thyra_LinearOpBase.hpp>
76 #include <Thyra_BlockedLinearOpBase.hpp>
77 #include <Thyra_PhysicallyBlockedLinearOpBase.hpp>
92 template <
class Scalar,
97 public Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
105 #undef XPETRA_BLOCKEDCRSMATRIX_SHORT
132 for (
size_t r = 0; r <
Rows(); ++r)
133 for (
size_t c = 0; c <
Cols(); ++c)
160 for (
size_t r = 0; r <
Rows(); ++r)
161 for (
size_t c = 0; c <
Cols(); ++c)
168 #ifdef HAVE_XPETRA_THYRA
183 int numRangeBlocks = productRangeSpace->numBlocks();
184 int numDomainBlocks = productDomainSpace->numBlocks();
187 std::vector<Teuchos::RCP<const Map> > subRangeMaps(numRangeBlocks);
188 for (
size_t r=0; r<Teuchos::as<size_t>(numRangeBlocks); ++r) {
189 for (
size_t c=0; c<Teuchos::as<size_t>(numDomainBlocks); ++c) {
190 if (thyraOp->blockExists(r,c)) {
195 subRangeMaps[r] = xop->getRangeMap();
205 bool bRangeUseThyraStyleNumbering =
false;
206 size_t numAllElements = 0;
207 for(
size_t v = 0; v < subRangeMaps.size(); ++v) {
208 numAllElements += subRangeMaps[v]->getGlobalNumElements();
210 if ( fullRangeMap->getGlobalNumElements() != numAllElements) bRangeUseThyraStyleNumbering =
true;
214 std::vector<Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > > subDomainMaps(numDomainBlocks);
215 for (
size_t c=0; c<Teuchos::as<size_t>(numDomainBlocks); ++c) {
216 for (
size_t r=0; r<Teuchos::as<size_t>(numRangeBlocks); ++r) {
217 if (thyraOp->blockExists(r,c)) {
222 subDomainMaps[c] = xop->getDomainMap();
229 bool bDomainUseThyraStyleNumbering =
false;
231 for(
size_t v = 0; v < subDomainMaps.size(); ++v) {
232 numAllElements += subDomainMaps[v]->getGlobalNumElements();
234 if (fullDomainMap->getGlobalNumElements() != numAllElements) bDomainUseThyraStyleNumbering =
true;
243 for (
size_t r = 0; r <
Rows(); ++r) {
244 for (
size_t c = 0; c <
Cols(); ++c) {
245 if(thyraOp->blockExists(r,c)) {
277 std::vector<GlobalOrdinal> gids;
278 for(
size_t tt = 0; tt<subMaps.size(); ++tt) {
282 gids.insert(gids.end(), subMapGids.
begin(), subMapGids.
end());
284 size_t myNumElements = subMap->getNodeNumElements();
285 for(LocalOrdinal l = 0; l < Teuchos::as<LocalOrdinal>(myNumElements); ++l) {
286 GlobalOrdinal gid = subMap->getGlobalElement(l);
297 std::sort(gids.begin(), gids.end());
298 gids.erase(std::unique(gids.begin(), gids.end()), gids.end());
345 getMatrix(0,0)->insertGlobalValues(globalRow, cols, vals);
365 getMatrix(0,0)->insertLocalValues(localRow, cols, vals);
372 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::removeEmptyProcessesInPlace");
374 getMatrix(0,0)->removeEmptyProcessesInPlace(newMap);
394 getMatrix(0,0)->replaceGlobalValues(globalRow,cols,vals);
410 getMatrix(0,0)->replaceLocalValues(localRow,cols,vals);
419 for (
size_t row = 0; row <
Rows(); row++) {
420 for (
size_t col = 0; col <
Cols(); col++) {
422 getMatrix(row,col)->setAllToScalar(alpha);
431 for (
size_t row = 0; row <
Rows(); row++) {
432 for (
size_t col = 0; col <
Cols(); col++) {
454 for (
size_t row = 0; row <
Rows(); row++) {
455 for (
size_t col = 0; col <
Cols(); col++) {
471 getMatrix(0,0)->fillComplete(domainMap, rangeMap, params);
495 for (
size_t r = 0; r <
Rows(); ++r)
496 for (
size_t c = 0; c <
Cols(); ++c) {
500 if (Ablock != Teuchos::null && !Ablock->isFillComplete())
508 fullrowmap_ =
MapFactory::Build(rangeMap()->lib(), rangeMap()->getGlobalNumElements(), rangeMap()->getNodeElementList(), rangeMap()->getIndexBase(), rangeMap()->getComm());
511 fullcolmap_ = Teuchos::null;
513 std::vector<GO> colmapentries;
514 for (
size_t c = 0; c <
Cols(); ++c) {
517 for (
size_t r = 0; r <
Rows(); ++r) {
520 if (Ablock != Teuchos::null) {
523 copy(colElements.
getRawPtr(), colElements.
getRawPtr() + colElements.
size(), inserter(colset, colset.begin()));
528 colmapentries.reserve(colmapentries.size() + colset.size());
529 copy(colset.begin(), colset.end(), back_inserter(colmapentries));
530 sort(colmapentries.begin(), colmapentries.end());
531 typename std::vector<GO>::iterator gendLocation;
532 gendLocation = std::unique(colmapentries.begin(), colmapentries.end());
533 colmapentries.erase(gendLocation,colmapentries.end());
537 size_t numGlobalElements = 0;
555 for (
size_t row = 0; row <
Rows(); row++)
556 for (
size_t col = 0; col <
Cols(); col++)
558 globalNumRows +=
getMatrix(row,col)->getGlobalNumRows();
562 return globalNumRows;
572 for (
size_t col = 0; col <
Cols(); col++)
573 for (
size_t row = 0; row <
Rows(); row++)
575 globalNumCols +=
getMatrix(row,col)->getGlobalNumCols();
579 return globalNumCols;
587 for (
size_t row = 0; row <
Rows(); ++row)
588 for (
size_t col = 0; col <
Cols(); col++)
590 nodeNumRows +=
getMatrix(row,col)->getNodeNumRows();
602 for (
size_t row = 0; row <
Rows(); ++row)
603 for (
size_t col = 0; col <
Cols(); ++col)
605 globalNumEntries +=
getMatrix(row,col)->getGlobalNumEntries();
607 return globalNumEntries;
615 for (
size_t row = 0; row <
Rows(); ++row)
616 for (
size_t col = 0; col <
Cols(); ++col)
618 nodeNumEntries +=
getMatrix(row,col)->getNodeNumEntries();
620 return nodeNumEntries;
626 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::getNumEntriesInLocalRow");
628 return getMatrix(0,0)->getNumEntriesInLocalRow(localRow);
631 GlobalOrdinal gid = this->
getRowMap()->getGlobalElement(localRow);
641 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::getNumEntriesInGlobalRow");
643 return getMatrix(0,0)->getNumEntriesInGlobalRow(globalRow);
652 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::getGlobalMaxNumRowEntries");
655 for (
size_t row = 0; row <
Rows(); row++) {
657 for (
size_t col = 0; col <
Cols(); col++) {
659 globalMaxEntriesBlockRows +=
getMatrix(row,col)->getGlobalMaxNumRowEntries();
662 if(globalMaxEntriesBlockRows > globalMaxEntries)
663 globalMaxEntries = globalMaxEntriesBlockRows;
665 return globalMaxEntries;
672 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::getNodeMaxNumRowEntries");
673 size_t localMaxEntries = 0;
675 for (
size_t row = 0; row <
Rows(); row++) {
676 size_t localMaxEntriesBlockRows = 0;
677 for (
size_t col = 0; col <
Cols(); col++) {
679 localMaxEntriesBlockRows +=
getMatrix(row,col)->getNodeMaxNumRowEntries();
682 if(localMaxEntriesBlockRows > localMaxEntries)
683 localMaxEntries = localMaxEntriesBlockRows;
685 return localMaxEntries;
694 for (
size_t i = 0; i <
blocks_.size(); ++i)
706 for (
size_t i = 0; i <
blocks_.size(); i++)
715 for (
size_t i = 0; i <
blocks_.size(); i++)
739 size_t &NumEntries)
const {
742 getMatrix(0,0)->getLocalRowCopy(LocalRow, Indices, Values, NumEntries);
761 getMatrix(0,0)->getGlobalRowView(GlobalRow, indices, values);
780 getMatrix(0,0)->getLocalRowView(LocalRow, indices, values);
785 GlobalOrdinal gid = this->
getRowMap()->getGlobalElement(LocalRow);
810 rm->getLocalDiagCopy(diag);
817 "BlockedCrsMatrix::getLocalDiagCopy(): the number of blocks in diag differ from the number of blocks in this operator." );
821 for (
size_t row = 0; row <
Rows(); row++) {
825 rm->getLocalDiagCopy(*rv);
826 bdiag->setMultiVector(row,rv,bdiag->getBlockedMap()->getThyraMode());
844 for (
size_t col = 0; col <
Cols(); ++col) {
854 "BlockedCrsMatrix::leftScale(): the number of blocks in diag differ from the number of blocks in this operator." );
856 for (
size_t row = 0; row <
Rows(); row++) {
860 for (
size_t col = 0; col <
Cols(); ++col) {
863 rm->leftScale(*rscale);
882 for (
size_t row = 0; row <
Rows(); ++row) {
892 "BlockedCrsMatrix::rightScale(): the number of blocks in diag differ from the number of blocks in this operator." );
894 for (
size_t col = 0; col <
Cols(); ++col) {
898 for (
size_t row = 0; row <
Rows(); row++) {
901 rm->rightScale(*rscale);
912 for (
size_t col = 0; col <
Cols(); ++col) {
913 for (
size_t row = 0; row <
Rows(); ++row) {
971 "apply() only supports the following modes: NO_TRANS and TRANS." );
980 bool bBlockedX = (refbX != Teuchos::null) ?
true :
false;
992 for (
size_t row = 0; row <
Rows(); row++) {
994 for (
size_t col = 0; col <
Cols(); col++) {
1004 bool bBlockedSubMatrix = Teuchos::rcp_dynamic_cast<
BlockedCrsMatrix>(Ablock) == Teuchos::null ?
false :
true;
1016 Ablock->apply(*Xblock, *tmpYblock);
1018 Yblock->
update(one, *tmpYblock, one);
1025 for (
size_t col = 0; col <
Cols(); col++) {
1028 for (
size_t row = 0; row<
Rows(); row++) {
1036 bool bBlockedSubMatrix = Teuchos::rcp_dynamic_cast<
BlockedCrsMatrix>(Ablock) == Teuchos::null ?
false :
true;
1046 Yblock->
update(one, *tmpYblock, one);
1051 Y.
update(alpha, *tmpY, beta);
1116 "apply() only supports the following modes: NO_TRANS and TRANS." );
1124 bool bBlockedX = (refbX != Teuchos::null) ?
true :
false;
1134 for (
size_t col = 0; col <
Cols(); col++) {
1144 bool bBlockedSubMatrix = Teuchos::rcp_dynamic_cast<
BlockedCrsMatrix>(Ablock) == Teuchos::null ?
false :
true;
1156 Ablock->apply(*Xblock, *tmpYblock);
1158 Yblock->
update(one, *tmpYblock, one);
1164 Y.
update(alpha, *tmpY, beta);
1187 getMatrix(0,0)->doImport(source, importer, CM);
1197 getMatrix(0,0)->doExport(dest, importer, CM);
1207 getMatrix(0,0)->doImport(source, exporter, CM);
1217 getMatrix(0,0)->doExport(dest, exporter, CM);
1229 std::string
description()
const {
return "Xpetra_BlockedCrsMatrix.description()"; }
1233 out <<
"Xpetra::BlockedCrsMatrix: " <<
Rows() <<
" x " <<
Cols() << std::endl;
1236 out <<
"BlockMatrix is fillComplete" << std::endl;
1249 out <<
"BlockMatrix is NOT fillComplete" << std::endl;
1252 for (
size_t r = 0; r <
Rows(); ++r)
1253 for (
size_t c = 0; c <
Cols(); ++c) {
1255 out <<
"Block(" << r <<
"," << c <<
")" << std::endl;
1256 getMatrix(r,c)->describe(out,verbLevel);
1257 }
else out <<
"Block(" << r <<
"," << c <<
") = null" << std::endl;
1265 for (
size_t r = 0; r <
Rows(); ++r)
1266 for (
size_t c = 0; c <
Cols(); ++c) {
1268 std::ostringstream oss; oss<< objectLabel <<
"(" << r <<
"," << c <<
")";
1269 getMatrix(r,c)->setObjectLabel(oss.str());
1278 if (
Rows() == 1 &&
Cols () == 1)
return true;
1312 if (bmat == Teuchos::null)
return mat;
1313 return bmat->getCrsMatrix();
1319 size_t row =
Rows()+1, col =
Cols()+1;
1320 for (
size_t r = 0; r <
Rows(); ++r)
1321 for(
size_t c = 0; c <
Cols(); ++c)
1330 if (bmat == Teuchos::null)
return mm;
1331 return bmat->getInnermostCrsMatrix();
1366 using Teuchos::rcp_dynamic_cast;
1370 "BlockedCrsMatrix::Merge: only implemented for Xpetra-style or Thyra-style numbering. No mixup allowed!" );
1373 "BlockedCrsMatrix::Merge: BlockMatrix must be fill-completed." );
1379 for (
size_t i = 0; i <
Rows(); i++) {
1380 for (
size_t j = 0; j <
Cols(); j++) {
1386 if (bMat != Teuchos::null) mat = bMat->Merge();
1390 "BlockedCrsMatrix::Merge: Merging of blocked sub-operators failed?!" );
1393 if(mat->getNodeNumEntries() == 0)
continue;
1395 this->
Add(*mat, one, *sparse, one);
1401 for (
size_t i = 0; i <
Rows(); i++) {
1402 for (
size_t j = 0; j <
Cols(); j++) {
1407 if (bMat != Teuchos::null) mat = bMat->Merge();
1411 "BlockedCrsMatrix::Merge: Merging of blocked sub-operators failed?!" );
1435 if(mat->getNodeNumEntries() == 0)
continue;
1437 size_t maxNumEntries = mat->getNodeMaxNumRowEntries();
1445 for (
size_t k = 0; k < mat->getNodeNumRows(); k++) {
1447 crsMat->getCrsMatrix()->getGlobalRowCopy(rowTGID, inds(), vals(), numEntries);
1450 for (
size_t l = 0; l < numEntries; ++l) {
1456 sparse->insertGlobalValues(
1457 rowXGID, inds2(0, numEntries),
1458 vals(0, numEntries));
1468 "BlockedCrsMatrix::Merge: Local number of entries of merged matrix does not coincide with local number of entries of blocked operator." );
1471 "BlockedCrsMatrix::Merge: Global number of entries of merged matrix does not coincide with global number of entries of blocked operator." );
1477 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1478 typedef typename CrsMatrix::local_matrix_type local_matrix_type;
1481 local_matrix_type getLocalMatrix ()
const {
1483 return getMatrix(0,0)->getLocalMatrix();
1489 #ifdef HAVE_XPETRA_THYRA
1492 Xpetra::ThyraUtils<Scalar,LO,GO,Node>::toThyra(Teuchos::rcpFromRef(*
this));
1496 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<Scalar> >(thOp);
1521 "Matrix A is not completed");
1530 if (scalarA == zero)
1536 "BlockedCrsMatrix::Add: matrix A must be of type CrsMatrixWrap.");
1550 GO row = rowGIDs[i];
1554 for (
size_t j = 0; j < numEntries; ++j)
1583 #ifdef HAVE_XPETRA_THYRA
1593 #define XPETRA_BLOCKEDCRSMATRIX_SHORT
virtual 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...
RCP< const Map > getDomainMap(size_t i, bool bThyraMode) const
Returns the Map associated with the i'th block domain of this operator.
virtual size_t getNodeMaxNumRowEntries() const =0
Returns the maximum number of entries across all rows/columns on this node.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const =0
Get this Map's Comm object.
RCP< const Map > getFullDomainMap() const
Returns the Map associated with the full domain of this operator.
static Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &map, size_t NumVectors, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
virtual const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const =0
Returns the Map that describes the column distribution in this matrix.
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
virtual void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalar.
bool is_null(const std::shared_ptr< T > &p)
RCP< const Map > getRangeMap() const
Returns the Map associated with the range of this operator.
RCP< const Map > getRangeMap(size_t i, bool bThyraMode) const
Returns the Map associated with the i'th block range of this operator.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< const MapExtractor > rangemaps_
virtual const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const =0
Returns the Map that describes the row distribution in this matrix.
void doImport(const Matrix &source, const Import &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.
virtual void bgs_apply(const MultiVector &X, MultiVector &Y, size_t row, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Special multiplication routine (for BGS/Jacobi smoother)
Exception throws to report errors in the internal logical of the program.
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
virtual LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const =0
The local index corresponding to the given global index.
virtual ~BlockedCrsMatrix()
Destructor.
RCP< const Map > getRangeMap(size_t i) const
Returns the Map associated with the i'th block range of this operator.
Teuchos::RCP< Matrix > getCrsMatrix() const
return unwrap 1x1 blocked operators
void doExport(const Matrix &dest, const Import &importer, CombineMode CM)
Export.
LocalOrdinal local_ordinal_type
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void Add(const Matrix &A, const Scalar scalarA, Matrix &B, const Scalar scalarB) const
Add a Xpetra::CrsMatrix to another: B = B*scalarB + A*scalarA.
void resumeFill(const RCP< ParameterList > ¶ms=null)
BlockedCrsMatrix(const Teuchos::RCP< const BlockedMap > &rangeMaps, const Teuchos::RCP< const BlockedMap > &domainMaps, size_t npr, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor.
global_size_t getGlobalNumCols() const
Returns the number of global columns in the matrix.
virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)=0
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
void rightScale(const Vector &x)
Right scale matrix using the given vector entries.
virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &indices, const ArrayView< Scalar > &values, size_t &numEntries) const =0
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
RCP< const CrsGraph > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
Exception indicating invalid cast attempted.
virtual bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
void getLocalDiagCopy(Vector &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
viewLabel_t defaultViewLabel_
virtual void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Insert matrix entries, using global IDs.
GlobalOrdinal global_ordinal_type
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void doExport(const Matrix &dest, const Export &exporter, CombineMode CM)
Export (using an Importer).
void leftScale(const Vector &x)
Left scale matrix using the given vector entries.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int >> &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
void setObjectLabel(const std::string &objectLabel)
RCP< const BlockedMap > getBlockedDomainMap() const
Returns the BlockedMap associated with the domain of this operator.
Teuchos::RCP< Matrix > getInnermostCrsMatrix()
helper routine recursively returns the first inner-most non-null matrix block from a (nested) blocked...
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
Teuchos::RCP< Matrix > getMatrix(size_t r, size_t c) const
return block (r,c)
virtual bool isFillComplete() const =0
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
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.
virtual size_t Cols() const
number of column blocks
static Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > transformThyra2XpetraGIDs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &input, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlInput, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlReferenceInput)
replace set of global ids by new global ids
RCP< const Map > getFullRangeMap() const
Returns the Map associated with the full range of this operator.
const Teuchos::RCP< const Map > getMap() const
Implements DistObject interface.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
The Map describing the parallel distribution of this object.
viewLabel_t currentViewLabel_
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
void doImport(const Matrix &source, const Export &exporter, CombineMode CM)
Import (using an Exporter).
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.
virtual GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const =0
The global index corresponding to the given local index.
Exception throws when you call an unimplemented method of Xpetra.
bool hasCrsGraph() const
Supports the getCrsGraph() call.
size_t global_size_t
Global size_t object.
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
static const EVerbosityLevel verbLevel_default
std::vector< Teuchos::RCP< Matrix > > blocks_
Teuchos::RCP< Matrix > Merge() const
merge BlockedCrsMatrix blocks in a CrsMatrix
static magnitudeType magnitude(T a)
RCP< const MapExtractor > getDomainMapExtractor() const
Returns map extractor for domain map.
global_size_t getGlobalNumRows() const
Returns the number of global rows.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
#define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the specified (locally owned) global row.
virtual bool isDiagonal() const
void setMatrix(size_t r, size_t c, Teuchos::RCP< Matrix > mat)
set matrix block
std::string description() const
Return a simple one-line description of this object.
bool bDomainThyraMode_
boolean flag, which is true, if BlockedCrsMatrix has been created using Thyra-style numbering for sub...
BlockedCrsMatrix(Teuchos::RCP< const MapExtractor > &rangeMaps, Teuchos::RCP< const MapExtractor > &domainMaps, size_t npr, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
Exception throws to report incompatible objects (like maps).
RCP< const Map > getDomainMap() const
Returns the Map associated with the domain of this operator.
Concrete implementation of Xpetra::Matrix.
virtual size_t Rows() const
number of row blocks
CombineMode
Xpetra::Combine Mode enumerable type.
#define XPETRA_MONITOR(funcName)
static RCP< Matrix > Build(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying the number of non-zeros for all rows.
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
virtual void scale(const Scalar &alpha)=0
Scale the current values of a matrix, this = alpha*this.
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
#define TEUCHOS_ASSERT(assertion_test)
const viewLabel_t & GetDefaultViewLabel() const
RCP< const BlockedMap > getBlockedRangeMap() const
Returns the BlockedMap associated with the range of this operator.
RCP< const Map > getDomainMap(size_t i) const
Returns the Map associated with the i'th block domain of this operator.
virtual size_t getNumVectors() const =0
Number of columns in the multivector.
virtual size_t getNodeNumRows() const =0
Returns the number of matrix rows owned on the calling node.
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
virtual UnderlyingLib lib() const =0
Get the library used by this object (Tpetra or Epetra?)
virtual ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Get Frobenius norm of the matrix.
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map > &newMap)
virtual Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const =0
Return a Vector which is a const view of column j.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
bool isLocallyIndexed() const
If matrix indices of all matrix blocks are in the local range, this function returns true...
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
Xpetra-specific matrix class.
Teuchos::RCP< const MapExtractor > domainmaps_
virtual void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
bool bRangeThyraMode_
boolean flag, which is true, if BlockedCrsMatrix has been created using Thyra-style numbering for sub...
RCP< const MapExtractor > getRangeMapExtractor() const
Returns map extractor class for range map.