52 : mtx_(Teuchos::
rcp(new Epetra_CrsMatrix(
Copy,
toEpetra(rowMap), maxNumEntriesPerRow,
toEpetra(pftype)))), isFillResumed_(false) { }
55 : isFillResumed_(false)
65 : isFillResumed_(false)
72 : mtx_(Teuchos::
rcp(new Epetra_CrsMatrix(
Copy,
toEpetra(graph)))), isFillResumed_(false) { }
74 #ifdef HAVE_XPETRA_EXPERIMENTAL
76 : mtx_(Teuchos::
rcp(new Epetra_CrsMatrix(*(matrix.mtx_)))), isFillResumed_(false) { }
87 XPETRA_DYNAMIC_CAST(
const EpetraCrsMatrix, *sourceMatrix, tSourceMatrix,
"Xpetra::EpetraCrsMatrix constructor only accepts Xpetra::EpetraCrsMatrix as an input argument.");
88 XPETRA_DYNAMIC_CAST(
const EpetraImport, importer, tImporter,
"Xpetra::EpetraCrsMatrix constructor only accepts Xpetra::EpetraImport as an input argument.");
90 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &
toEpetra(domainMap): 0;
91 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &
toEpetra(rangeMap) : 0;
94 bool restrictComm=
false;
95 if(!params.
is_null()) restrictComm = params->
get(
"Restrict Communicator",restrictComm);
96 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),myDomainMap,myRangeMap,restrictComm));
97 if(restrictComm &&
mtx_->NumMyRows()==0)
106 isFillResumed_(false)
108 XPETRA_DYNAMIC_CAST(
const EpetraCrsMatrix, *sourceMatrix, tSourceMatrix,
"Xpetra::EpetraCrsMatrix constructor only accepts Xpetra::EpetraCrsMatrix as an input argument.");
109 XPETRA_DYNAMIC_CAST(
const EpetraExport, exporter, tExporter,
"Xpetra::EpetraCrsMatrix constructor only accepts Xpetra::EpetraExport as an input argument.");
111 const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &
toEpetra(domainMap): 0;
112 const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &
toEpetra(rangeMap) : 0;
115 bool restrictComm=
false;
116 if(!params.
is_null()) restrictComm = params->
get(
"Restrict Communicator",restrictComm);
118 mtx_ =
Teuchos::rcp(
new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),myDomainMap,myRangeMap,restrictComm));
137 const std::string tfecfFuncName(
"replaceGlobalValues");
139 ": Fill must be active in order to call this method. If you have already "
140 "called fillComplete(), you need to call resumeFill() before you can "
144 std::runtime_error,
": values.size() must equal indices.size().");
155 const std::string tfecfFuncName(
"replaceGlobalValues");
157 ": Fill must be active in order to call this method. If you have already "
158 "called fillComplete(), you need to call resumeFill() before you can "
162 std::runtime_error,
": values.size() must equal indices.size().");
175 Epetra_IntSerialDenseVector& myColind =
mtx_->ExpertExtractIndices();
176 double *& myValues =
mtx_->ExpertExtractValues();
179 myColind.Resize(numNonZeros);
180 delete [] myValues; myValues =
new double[numNonZeros];
184 colind = Teuchos::arcp(myColind.Values(),0,numNonZeros,
false);
185 values = Teuchos::arcp(myValues,0,numNonZeros,
false);
198 Epetra_IntSerialDenseVector& myRowptr =
mtx_->ExpertExtractIndexOffset();
201 myRowptr.Resize(N+1);
202 for(
size_t i=0; i<N+1; i++)
203 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
226 NumEntries = numEntries;
237 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
251 if (numEntries == 0) { eValues = NULL; eIndices = NULL; }
286 std::ostringstream oss;
289 oss <<
"{status = fill complete"
296 oss <<
"{status = fill not complete"
319 const int myImageID = comm->getRank(),
320 numImages = comm->getSize();
325 width = std::max<size_t>(width,11) + 2;
335 if (myImageID == 0) out << this->
description() << std::endl;
343 if (myImageID == 0) out <<
"\nRow map: " << std::endl;
348 if (myImageID == 0) out <<
"\nColumn map is row map.";
351 if (myImageID == 0) out <<
"\nColumn map: " << std::endl;
357 if (myImageID == 0) out <<
"\nDomain map is row map.";
360 if (myImageID == 0) out <<
"\nDomain map is row map.";
363 if (myImageID == 0) out <<
"\nDomain map: " << std::endl;
369 if (myImageID == 0) out <<
"\nRange map is domain map." << std::endl;
372 if (myImageID == 0) out <<
"\nRange map is row map." << std::endl;
375 if (myImageID == 0) out <<
"\nRange map: " << std::endl;
379 if (myImageID == 0) out << std::endl;
383 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
384 if (myImageID == imageCtr) {
385 out <<
"Node ID = " << imageCtr << std::endl;
400 out <<
"Node number of diagonals = " <<
getNodeNumDiags() << std::endl;
411 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
412 if (myImageID == imageCtr) {
413 out << std::setw(width) <<
"Node ID"
414 << std::setw(width) <<
"Global Row"
415 << std::setw(width) <<
"Num Entries";
417 out << std::setw(width) <<
"(Index,Value)";
423 out << std::setw(width) << myImageID
424 << std::setw(width) << gid
425 << std::setw(width) << nE;
431 for (
size_t j=0; j < nE; ++j) {
432 out <<
" (" << rowinds[j]
433 <<
", " << rowvals[j]
441 for (
size_t j=0; j < nE; ++j) {
442 out <<
" (" <<
getColMap()->getGlobalElement(rowinds[j])
443 <<
", " << rowvals[j]
466 XPETRA_DYNAMIC_CAST(
const EpetraImport, importer, tImporter,
"Xpetra::EpetraCrsMatrix::doImport only accept Xpetra::EpetraImport as input arguments.");
469 int err =
mtx_->Import(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
474 const Import<int, int>& importer,
CombineMode CM) {
478 XPETRA_DYNAMIC_CAST(
const EpetraImport, importer, tImporter,
"Xpetra::EpetraCrsMatrix::doImport only accept Xpetra::EpetraImport as input arguments.");
480 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
481 int err =
mtx_->Export(*v, *tImporter.getEpetra_Import(),
toEpetra(CM));
486 const Export<int, int>& exporter,
CombineMode CM) {
490 XPETRA_DYNAMIC_CAST(
const EpetraExport, exporter, tExporter,
"Xpetra::EpetraCrsMatrix::doImport only accept Xpetra::EpetraImport as input arguments.");
492 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
493 int err =
mtx_->Import(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
499 const Export<int, int>& exporter,
CombineMode CM) {
503 XPETRA_DYNAMIC_CAST(
const EpetraExport, exporter, tExporter,
"Xpetra::EpetraCrsMatrix::doImport only accept Xpetra::EpetraImport as input arguments.");
505 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
506 int err =
mtx_->Export(*v, *tExporter.getEpetra_Export(),
toEpetra(CM));
518 bool doOptimizeStorage =
true;
519 if (params != null && params->
get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
529 bool doOptimizeStorage =
true;
530 if (params != null && params->
get(
"Optimize Storage",
true) ==
false) doOptimizeStorage =
false;
531 mtx_->FillComplete(doOptimizeStorage);
537 XPETRA_DYNAMIC_CAST(
const EpetraImport, *newImporter, eImporter,
"Xpetra::EpetraCrsMatrix::replaceDomainMapAndImporter only accepts Xpetra::EpetraImport.");
541 if(myImport==Teuchos::null)
542 rv=
mtx_->ReplaceDomainMapAndImporter(
toEpetra(newDomainMap),0);
544 rv=
mtx_->ReplaceDomainMapAndImporter(
toEpetra(newDomainMap),&*myImport);
556 const Epetra_Import * myimport =0;
557 const Epetra_Export * myexport =0;
559 if(!importer.is_null()) {
561 myimport = eImporter.getEpetra_Import().getRawPtr();
563 if(!exporter.is_null()) {
565 myexport = eExporter.getEpetra_Export().getRawPtr();
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
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.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this 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.
const RCP< const Comm< int > > getComm() const
Returns the communicator.
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
void resumeFill(const RCP< ParameterList > ¶ms=null)
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
EpetraCrsMatrix(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying fixed number of entries for each row.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
Exception throws to report errors in the internal logical of the program.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the matrix's structure from the Crs arrays.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, int > > &graph)
void resize(const size_type n, const T &val=T())
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define XPETRA_ERR_CHECK(arg)
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const 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.
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
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...
Exception throws when you call an unimplemented method of Xpetra.
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
bool isFillActive() const
Returns true if the matrix is in edit mode.
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)
Replaces the current domainMap and importer with the user-specified objects.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map associated with the range of this operator, which must be compatible with Y...
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
void expertStaticFillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const RCP< ParameterList > ¶ms=Teuchos::null)
Expert static fill complete.
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
Allocates and returns ArrayRCPs of the Crs arrays — This is an Xpetra-only routine.
CombineMode
Xpetra::Combine Mode enumerable type.
#define XPETRA_MONITOR(funcName)
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete, specifying domain and range maps.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
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.
RCP< Epetra_CrsMatrix > mtx_
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
std::string description() const
A simple one-line description of this object.