10 #ifndef XPETRA_TPETRACRSMATRIX_DEF_HPP
11 #define XPETRA_TPETRACRSMATRIX_DEF_HPP
13 #include <Xpetra_MultiVectorFactory.hpp>
15 #include "Tpetra_Details_residual.hpp"
19 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
21 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
toTpetra(rowMap), maxNumEntriesPerRow, params))) {}
23 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
25 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
toTpetra(rowMap), NumEntriesPerRowToAlloc(), params))) {}
27 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
28 TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::TpetraCrsMatrix(
const Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap,
const Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap,
size_t maxNumEntriesPerRow,
const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
29 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
toTpetra(rowMap),
toTpetra(colMap), maxNumEntriesPerRow, params))) {}
31 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
32 TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::TpetraCrsMatrix(
const Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap,
const Teuchos::RCP<
const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap,
const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc,
const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
33 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
toTpetra(rowMap),
toTpetra(colMap), NumEntriesPerRowToAlloc(), params))) {}
35 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
37 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
toTpetra(graph), params))) {}
39 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
40 TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::TpetraCrsMatrix(
const Teuchos::RCP<
const CrsGraph<LocalOrdinal, GlobalOrdinal, Node>> &graph,
typename Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::local_matrix_type::values_type &values,
const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
41 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
toTpetra(graph), values, params))) {}
43 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
48 const Teuchos::RCP<Teuchos::ParameterList> ¶ms) {
49 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> MyTpetraCrsMatrix;
51 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> v = tSourceMatrix.getTpetra_CrsMatrix();
53 RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> myDomainMap = domainMap != Teuchos::null ?
toTpetra(domainMap) : Teuchos::null;
54 RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> myRangeMap = rangeMap != Teuchos::null ?
toTpetra(rangeMap) : Teuchos::null;
55 mtx_ = Tpetra::importAndFillCompleteCrsMatrix<MyTpetraCrsMatrix>(tSourceMatrix.getTpetra_CrsMatrix(),
toTpetra(importer), myDomainMap, myRangeMap, params);
56 bool restrictComm =
false;
57 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
58 if (restrictComm && mtx_->getRowMap().is_null()) mtx_ = Teuchos::null;
61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 const Teuchos::RCP<Teuchos::ParameterList> ¶ms) {
67 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> MyTpetraCrsMatrix;
69 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> v = tSourceMatrix.getTpetra_CrsMatrix();
71 RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> myDomainMap = domainMap != Teuchos::null ?
toTpetra(domainMap) : Teuchos::null;
72 RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> myRangeMap = rangeMap != Teuchos::null ?
toTpetra(rangeMap) : Teuchos::null;
73 mtx_ = Tpetra::exportAndFillCompleteCrsMatrix<MyTpetraCrsMatrix>(tSourceMatrix.getTpetra_CrsMatrix(),
toTpetra(exporter), myDomainMap, myRangeMap, params);
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
82 const Teuchos::RCP<Teuchos::ParameterList> ¶ms) {
83 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> MyTpetraCrsMatrix;
85 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> v = tSourceMatrix.getTpetra_CrsMatrix();
87 RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> myDomainMap = domainMap != Teuchos::null ?
toTpetra(domainMap) : Teuchos::null;
88 RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> myRangeMap = rangeMap != Teuchos::null ?
toTpetra(rangeMap) : Teuchos::null;
90 mtx_ = Tpetra::importAndFillCompleteCrsMatrix<MyTpetraCrsMatrix>(tSourceMatrix.getTpetra_CrsMatrix(),
toTpetra(RowImporter),
toTpetra(*DomainImporter), myDomainMap, myRangeMap, params);
91 bool restrictComm =
false;
92 if (!params.is_null()) restrictComm = params->get(
"Restrict Communicator", restrictComm);
93 if (restrictComm && mtx_->getRowMap().is_null()) mtx_ = Teuchos::null;
96 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
102 const Teuchos::RCP<Teuchos::ParameterList> ¶ms) {
103 typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> MyTpetraCrsMatrix;
105 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> v = tSourceMatrix.getTpetra_CrsMatrix();
107 RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> myDomainMap = domainMap != Teuchos::null ?
toTpetra(domainMap) : Teuchos::null;
108 RCP<const Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> myRangeMap = rangeMap != Teuchos::null ?
toTpetra(rangeMap) : Teuchos::null;
110 mtx_ = Tpetra::exportAndFillCompleteCrsMatrix<MyTpetraCrsMatrix>(tSourceMatrix.getTpetra_CrsMatrix(),
toTpetra(RowExporter),
toTpetra(*DomainExporter), myDomainMap, myRangeMap, params);
115 #ifdef HAVE_XPETRA_TPETRA
116 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
120 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
121 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
toTpetra(rowMap),
toTpetra(colMap), lclMatrix, params))) {}
123 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
133 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142 const Teuchos::RCP<Teuchos::ParameterList> ¶ms)
143 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(lclMatrix,
toTpetra(rowMap),
toTpetra(colMap),
toTpetra(domainMap),
toTpetra(rangeMap),
toTpetra(importer),
toTpetra(exporter), params))) {}
146 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
149 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
152 mtx_->insertGlobalValues(globalRow, cols, vals);
155 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
158 mtx_->insertLocalValues(localRow, cols, vals);
161 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
164 mtx_->replaceGlobalValues(globalRow, cols, vals);
167 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
169 const ArrayView<const LocalOrdinal> &cols,
170 const ArrayView<const Scalar> &vals) {
172 typedef typename ArrayView<const LocalOrdinal>::size_type size_type;
173 const LocalOrdinal numValid =
174 mtx_->replaceLocalValues(localRow, cols, vals);
175 TEUCHOS_TEST_FOR_EXCEPTION(
176 static_cast<size_type>(numValid) != cols.size(), std::runtime_error,
177 "replaceLocalValues returned " << numValid <<
" != cols.size() = " << cols.size() <<
".");
180 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
183 mtx_->setAllToScalar(alpha);
186 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
192 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
195 rowptr.resize(getLocalNumRows() + 1);
196 colind.resize(numNonZeros);
197 values.resize(numNonZeros);
200 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
203 mtx_->setAllValues(rowptr, colind, values);
206 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
212 rowptr = Kokkos::Compat::persistingView(mtx_->getLocalRowPtrsHost());
213 colind = Kokkos::Compat::persistingView(mtx_->getLocalIndicesHost());
214 values = Teuchos::arcp_reinterpret_cast<
const Scalar>(
215 Kokkos::Compat::persistingView(mtx_->getLocalValuesHost(
219 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
224 values = Teuchos::arcp_reinterpret_cast<Scalar>(
225 Kokkos::Compat::persistingView(mtx_->getLocalValuesDevice(
229 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
232 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
235 mtx_->resumeFill(params);
238 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
244 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
247 mtx_->fillComplete(params);
250 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
254 RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node>> myImport = tImporter.getTpetra_Import();
255 mtx_->replaceDomainMapAndImporter(
toTpetra(newDomainMap), myImport);
258 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
263 const RCP<ParameterList> ¶ms) {
265 RCP<const Tpetra::Import<LocalOrdinal, GlobalOrdinal, Node>> myImport;
266 RCP<const Tpetra::Export<LocalOrdinal, GlobalOrdinal, Node>> myExport;
268 if (importer != Teuchos::null) {
270 myImport = tImporter.getTpetra_Import();
272 if (exporter != Teuchos::null) {
274 myExport = tExporter.getTpetra_Export();
277 mtx_->expertStaticFillComplete(
toTpetra(domainMap),
toTpetra(rangeMap), myImport, myExport, params);
280 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
286 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
292 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
295 return toXpetra(mtx_->getCrsGraph());
298 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
301 return mtx_->getGlobalNumRows();
304 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
307 return mtx_->getGlobalNumCols();
310 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
313 return mtx_->getLocalNumRows();
316 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
319 return mtx_->getLocalNumCols();
322 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
325 return mtx_->getGlobalNumEntries();
328 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
331 return mtx_->getLocalNumEntries();
334 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
337 return mtx_->getNumEntriesInLocalRow(localRow);
340 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
343 return mtx_->getNumEntriesInGlobalRow(globalRow);
346 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
349 return mtx_->getGlobalMaxNumRowEntries();
352 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
355 return mtx_->getLocalMaxNumRowEntries();
358 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
361 return mtx_->isLocallyIndexed();
364 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
367 return mtx_->isGloballyIndexed();
370 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
373 return mtx_->isFillComplete();
376 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
379 return mtx_->isFillActive();
382 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
385 return mtx_->getFrobeniusNorm();
388 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
391 return mtx_->supportsRowViews();
394 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
397 typename Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node>::nonconst_local_inds_host_view_type indices(
"indices", Indices.size());
398 typename Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::nonconst_values_host_view_type values(
"values", Values.size());
400 mtx_->getLocalRowCopy(LocalRow, indices, values, NumEntries);
401 for (
size_t i = 0; i < NumEntries; ++i) {
402 Indices[i] = indices(i);
403 Values[i] = values(i);
407 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
410 typename Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node>::nonconst_global_inds_host_view_type indices(
"indices", Indices.size());
411 typename Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::nonconst_values_host_view_type values(
"values", Values.size());
413 mtx_->getGlobalRowCopy(GlobalRow, indices, values, NumEntries);
414 for (
size_t i = 0; i < NumEntries; ++i) {
415 Indices[i] = indices(i);
416 Values[i] = values(i);
420 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
423 typename Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node>::global_inds_host_view_type indices;
424 typename Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::values_host_view_type values;
426 mtx_->getGlobalRowView(GlobalRow, indices, values);
427 Indices = ArrayView<const GlobalOrdinal>(indices.data(), indices.extent(0));
428 Values = ArrayView<const Scalar>(
reinterpret_cast<const Scalar *
>(values.data()), values.extent(0));
431 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
434 typename Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node>::local_inds_host_view_type indices;
435 typename Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::values_host_view_type values;
437 mtx_->getLocalRowView(LocalRow, indices, values);
438 Indices = ArrayView<const LocalOrdinal>(indices.data(), indices.extent(0));
439 Values = ArrayView<const Scalar>(
reinterpret_cast<const Scalar *
>(values.data()), values.extent(0));
442 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
448 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
449 void TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::apply(
const MultiVector &X,
MultiVector &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta,
bool sumInterfaceValues,
const RCP<
Import<LocalOrdinal, GlobalOrdinal, Node>> ®ionInterfaceImporter,
const Teuchos::ArrayRCP<LocalOrdinal> ®ionInterfaceLIDs)
const {
451 RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> regionInterfaceMap = regionInterfaceImporter->getTargetMap();
453 if (sumInterfaceValues) {
457 matvecInterfaceTmp->doImport(Y, *regionInterfaceImporter,
INSERT);
462 ArrayRCP<Scalar> interfaceData = matvecInterfaceTmp->getDataNonConst(0);
463 for (LocalOrdinal interfaceIdx = 0; interfaceIdx < static_cast<LocalOrdinal>(interfaceData.size()); ++interfaceIdx) {
464 YData[regionInterfaceLIDs[interfaceIdx]] += interfaceData[interfaceIdx];
469 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
472 return toXpetra(mtx_->getDomainMap());
475 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
478 return toXpetra(mtx_->getRangeMap());
481 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
484 return mtx_->description();
487 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
490 mtx_->describe(out, verbLevel);
493 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
496 Teuchos::LabeledObject::setObjectLabel(objectLabel);
497 mtx_->setObjectLabel(objectLabel);
500 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
502 : mtx_(Teuchos::rcp(new Tpetra::
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>(*(matrix.mtx_), Teuchos::Copy))) {}
504 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
508 mtx_->getLocalDiagCopy(*tDiag.getTpetra_Vector());
511 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
514 mtx_->getLocalDiagOffsets(offsets);
517 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
520 mtx_->getLocalDiagCopy(*(
toTpetra(diag)), offsets);
523 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
526 mtx_->getLocalDiagCopy(*(
toTpetra(diag)), offsets);
529 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
532 Tpetra::replaceDiagonalCrsMatrix(*mtx_, *(
toTpetra(diag)));
535 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
541 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
547 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
553 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
559 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> v = tSource.getTpetra_CrsMatrix();
565 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
571 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> v = tDest.getTpetra_CrsMatrix();
575 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
581 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> v = tSource.getTpetra_CrsMatrix();
585 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
591 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> v = tDest.getTpetra_CrsMatrix();
595 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
598 mtx_->removeEmptyProcessesInPlace(
toTpetra(newMap));
601 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
603 return !mtx_.is_null();
606 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
610 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
614 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
618 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
633 #endif // XPETRA_TPETRACRSMATRIX_DEF_HPP
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
void replaceDiag(const Vector &diag)
Replace the diagonal entries of the matrix.
std::string description() const
A simple one-line description of this object.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
void leftScale(const Vector &x)
Left scale operator with given vector values.
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...
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.
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.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
constexpr struct ReadOnlyStruct ReadOnly
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the (locally owned) global row.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
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.
void resumeFill(const RCP< ParameterList > ¶ms=null)
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
void setObjectLabel(const std::string &objectLabel)
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &newMap)
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
void getLocalDiagCopy(Vector &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
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 getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph.
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void residual(const MultiVector &X, const MultiVector &B, MultiVector &R) const
Compute a residual R = B - (*this) * X.
TpetraCrsMatrix(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying fixed number of entries for each row.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
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 doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
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 Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
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.
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.
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)=0
View of the local values in a particular vector of this multivector.
size_t global_size_t
Global size_t object.
virtual ~TpetraCrsMatrix()
Destructor.
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...
RCP< const Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_CrsMatrix() const
Get the underlying Tpetra matrix.
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.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_CrsMatrixNonConst() const
Get the underlying Tpetra matrix.
bool hasMatrix() const
Does this have an underlying matrix.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
CombineMode
Xpetra::Combine Mode enumerable type.
constexpr struct ReadWriteStruct ReadWrite
#define XPETRA_MONITOR(funcName)
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
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.
KokkosSparse::CrsMatrix< impl_scalar_type, LocalOrdinal, execution_space, void, typename local_graph_type::size_type > local_matrix_type
The specialization of Kokkos::CrsMatrix that represents the part of the sparse matrix on each MPI pro...
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &indices, const ArrayView< Scalar > &values, size_t &numEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
bool isFillActive() const
Returns true if the matrix is in edit mode.
void rightScale(const Vector &x)
Right scale operator with given vector values.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)