Xpetra Version of the Day
Loading...
Searching...
No Matches
Xpetra_EpetraCrsMatrix.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Xpetra: A linear algebra interface package
4//
5// Copyright 2012 NTESS and the Xpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef XPETRA_EPETRACRSMATRIX_HPP
11#define XPETRA_EPETRACRSMATRIX_HPP
12
13/* this file is automatically generated - do not edit (see script/epetra.py) */
14
15#ifdef HAVE_XPETRA_TPETRA
16#include <Kokkos_Core.hpp>
17#endif
18
20
21#include "Xpetra_CrsMatrix.hpp"
22
23#include <Epetra_CrsMatrix.h>
24#include <Epetra_Map.h>
25
26#include "Xpetra_EpetraMap.hpp"
30
31#include "Xpetra_MapFactory.hpp"
32
33#include "Xpetra_Utils.hpp"
34#include "Xpetra_Exceptions.hpp"
35
36#if defined(XPETRA_ENABLE_DEPRECATED_CODE)
37#ifdef __GNUC__
38#if defined(Xpetra_SHOW_DEPRECATED_WARNINGS)
39#warning "The header file Trilinos/packages/xpetra/src/CrsMatrix/Xpetra_EpetraCrsMatrix.hpp is deprecated."
40#endif
41#endif
42#else
43#error "The header file Trilinos/packages/xpetra/src/CrsMatrix/Xpetra_EpetraCrsMatrix.hpp is deprecated."
44#endif
45
46namespace Xpetra {
47
48// general implementation: empty stub
49template <class EpetraGlobalOrdinal, class Node>
50class XPETRA_DEPRECATED EpetraCrsMatrixT
51 : public CrsMatrix<double, int, EpetraGlobalOrdinal, Node> {
52 typedef EpetraGlobalOrdinal GlobalOrdinal;
55
56#ifdef HAVE_XPETRA_TPETRA
57 public:
62
63 private:
64#endif
65
66#if KOKKOS_VERSION >= 40799
67 using ATS = KokkosKernels::ArithTraits<Scalar>;
68#else
69 using ATS = Kokkos::ArithTraits<Scalar>;
70#endif
71 using impl_scalar_type = typename ATS::val_type;
72
73 public:
74 EpetraCrsMatrixT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null) {
76 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
77 }
78 EpetraCrsMatrixT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rowMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc, const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null) {
80 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
81 }
82 EpetraCrsMatrixT(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> &params = Teuchos::null) { TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with Node=Tpetra::KokkosCompat::KokkosSerialWrapperNode."); }
83 EpetraCrsMatrixT(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> &params = Teuchos::null) { TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with Node=Tpetra::KokkosCompat::KokkosSerialWrapperNode."); }
84 EpetraCrsMatrixT(const Teuchos::RCP<const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > &graph, const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null) { TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with Node=Tpetra::KokkosCompat::KokkosSerialWrapperNode."); }
87 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
88 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
89 const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null) {
91 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
92 }
95 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
96 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
97 const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null) {
99 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
100 }
103 const Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> > DomainImporter,
108 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
109 }
112 const Teuchos::RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> > DomainExporter,
117 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
118 }
119#ifdef HAVE_XPETRA_TPETRA
122 const local_matrix_type &lclMatrix,
123 const Teuchos::RCP<Teuchos::ParameterList> &params = null) {
125 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
126 }
128 const local_matrix_type &lclMatrix,
131 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
132 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
133 const Teuchos::RCP<Teuchos::ParameterList> &params = null) {
135 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
136 }
137#endif
138 virtual ~EpetraCrsMatrixT() {}
139
144 void setAllToScalar(const Scalar &alpha) {}
145 void scale(const Scalar &alpha) {}
146 void allocateAllValues(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {}
147 void setAllValues(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind, const ArrayRCP<Scalar> &values) {}
150 bool haveGlobalConstants() const { return true; }
152 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap,
153 const RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> > &importer = Teuchos::null,
154 const RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> > &exporter = Teuchos::null,
155 const RCP<ParameterList> &params = Teuchos::null) {}
156
157 void resumeFill(const RCP<ParameterList> &params = null) {}
158 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap, const RCP<ParameterList> &params = null) {}
159 void fillComplete(const RCP<ParameterList> &params = null) {}
161 const RCP<const Comm<int> > getComm() const { return Teuchos::null; }
162 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getRowMap() const { return Teuchos::null; }
163 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getColMap() const { return Teuchos::null; }
165 global_size_t getGlobalNumRows() const { return 0; }
166 global_size_t getGlobalNumCols() const { return 0; }
167 size_t getLocalNumRows() const { return 0; }
168 size_t getLocalNumCols() const { return 0; }
169 global_size_t getGlobalNumEntries() const { return 0; }
170 size_t getLocalNumEntries() const { return 0; }
171 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const { return 0; }
172 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const { return 0; }
173 size_t getGlobalMaxNumRowEntries() const { return 0; }
174 size_t getLocalMaxNumRowEntries() const { return 0; }
175 bool isLocallyIndexed() const { return false; }
176 bool isGloballyIndexed() const { return false; }
177 bool isFillComplete() const { return false; }
178 bool isFillActive() const { return false; }
180 bool supportsRowViews() const { return false; }
181 void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView<LocalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {}
182 void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView<GlobalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {}
188 void getLocalDiagCopy(Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &diag, const Kokkos::View<const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {}
192
195 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getDomainMap() const { return Teuchos::null; }
196 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getRangeMap() const { return Teuchos::null; }
197
198 std::string description() const { return std::string(""); }
200 void setObjectLabel(const std::string &objectLabel) {}
201
204 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
205 }
206
213
214 bool hasMatrix() const { return false; }
217 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
218 }
219 RCP<const Epetra_CrsMatrix> getEpetra_CrsMatrix() const { return Teuchos::null; }
220 RCP<Epetra_CrsMatrix> getEpetra_CrsMatrixNonConst() const { return Teuchos::null; } // TODO: remove
221#ifdef HAVE_XPETRA_TPETRA
224 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
225 }
226#if KOKKOS_VERSION >= 40799
227 typename local_matrix_type::host_mirror_type getLocalMatrixHost() const {
228#else
229 typename local_matrix_type::HostMirror getLocalMatrixHost() const {
230#endif
232 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
233}
234
235void
236setAllValues(const typename local_matrix_type::row_map_type &ptr,
237 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
238 const typename local_matrix_type::values_type &val) {
240 "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
241}
242
244
245#else
246#ifdef __GNUC__
247#warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
248#endif
249#endif
250
258
259}; // namespace Xpetra
260
261#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
262template <>
264 : public CrsMatrix<double, int, int, EpetraNode> {
265 typedef int GlobalOrdinal;
269
270 // The following typedefs are used by the Kokkos interface
271#ifdef HAVE_XPETRA_TPETRA
272 public:
277
278 private:
279#endif
280
281 public:
283
284
287 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), 0, false)))
288 , isFillResumed_(false) {}
289
291 EpetraCrsMatrixT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
292 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), maxNumEntriesPerRow, true)))
293 , isFillResumed_(false) {}
294
296 EpetraCrsMatrixT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rowMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc, const Teuchos::RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
297 : isFillResumed_(false) {
298 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
299 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(), true));
300 }
301
303 EpetraCrsMatrixT(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> & /* plist */ = Teuchos::null)
304 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), maxNumEntriesPerRow, true)))
305 , isFillResumed_(false) {}
306
308 EpetraCrsMatrixT(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> & /* plist */ = Teuchos::null)
309 : isFillResumed_(false) {
310 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
311 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
312 }
313
316 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(graph))))
317 , isFillResumed_(false) {}
318
322 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
323 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
324 const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null)
325 : isFillResumed_(false) {
326 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
327 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
328
329 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
330 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
331
332 // Follows the Tpetra parameters
333 bool restrictComm = false;
334 if (!params.is_null()) restrictComm = params->get("Restrict Communicator", restrictComm);
335 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), myDomainMap, myRangeMap, restrictComm));
336 if (restrictComm && mtx_->NumMyRows() == 0)
337 mtx_ = Teuchos::null;
338 }
339
343 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
344 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
345 const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null)
346 : isFillResumed_(false) {
347 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
348 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
349
350 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
351 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
352
353 // Follows the Tpetra parameters
354 bool restrictComm = false;
355 if (!params.is_null()) restrictComm = params->get("Restrict Communicator", restrictComm);
356
357 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), myDomainMap, myRangeMap, restrictComm));
358 }
359
362 const Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> > DomainImporter,
366 : isFillResumed_(false) {
367 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
368 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, RowImporter, tImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
369 XPETRA_RCP_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, DomainImporter, tdImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
370
371 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
372 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
373
374 // Follows the Tpetra parameters
375 bool restrictComm = false;
376 if (!params.is_null()) restrictComm = params->get("Restrict Communicator", restrictComm);
377 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), tdImporter->getEpetra_Import().get(), myDomainMap, myRangeMap, restrictComm));
378 if (restrictComm && mtx_->NumMyRows() == 0)
379 mtx_ = Teuchos::null;
380 }
381
384 const Teuchos::RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> > DomainExporter,
388 : isFillResumed_(false) {
389 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
390 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, RowExporter, tExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
391 XPETRA_RCP_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, DomainExporter, tdExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
392
393 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
394 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
395
396 // Follows the Tpetra parameters
397 bool restrictComm = false;
398 if (!params.is_null()) restrictComm = params->get("Restrict Communicator", restrictComm);
399
400 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), tdExporter->getEpetra_Export().get(), myDomainMap, myRangeMap, restrictComm));
401 }
402
403#ifdef HAVE_XPETRA_TPETRA
404 // NOTE: TPETRA means we can use C++11 here
405
429 const local_matrix_type &lclMatrix,
430 const Teuchos::RCP<Teuchos::ParameterList> &params = null)
431 : EpetraCrsMatrixT(lclMatrix, rowMap, colMap, Teuchos::null, Teuchos::null, params) {}
432
434 const local_matrix_type &lclMatrix,
437 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
438 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
439 const Teuchos::RCP<Teuchos::ParameterList> &params = null) {
440 // local typedefs from local_matrix_type
441 // typedef typename local_matrix_type::size_type size_type;
442 typedef typename local_matrix_type::value_type value_type;
443 typedef typename local_matrix_type::ordinal_type ordinal_type;
444
445 // The number of rows in the sparse matrix.
446 ordinal_type lclNumRows = lclMatrix.numRows();
447 ordinal_type lclNumCols = lclMatrix.numCols(); // do we need this?
448
449 // plausibility checks
450 TEUCHOS_TEST_FOR_EXCEPTION(lclNumRows != Teuchos::as<ordinal_type>(rowMap->getLocalNumElements()), Xpetra::Exceptions::RuntimeError,
451 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
452 TEUCHOS_TEST_FOR_EXCEPTION(lclNumCols != Teuchos::as<ordinal_type>(colMap->getLocalNumElements()), Xpetra::Exceptions::RuntimeError,
453 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
454
455 Teuchos::ArrayRCP<size_t> NumEntriesPerRowToAlloc(lclNumRows);
456 for (ordinal_type r = 0; r < lclNumRows; ++r) {
457 // extract data from current row r
458 auto rowview = lclMatrix.row(r);
459 NumEntriesPerRowToAlloc[r] = rowview.length;
460 }
461
462 // setup matrix
463 isFillResumed_ = false;
464 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
465 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
466
467 // loop over all rows and colums of local matrix and fill matrix
468 for (ordinal_type r = 0; r < lclNumRows; ++r) {
469 // extract data from current row r
470 auto rowview = lclMatrix.row(r);
471
472 // arrays for current row data
475
476 for (ordinal_type c = 0; c < rowview.length; c++) {
477 value_type value = rowview.value(c);
478 ordinal_type colidx = rowview.colidx(c);
479
480 TEUCHOS_TEST_FOR_EXCEPTION(colMap->isNodeLocalElement(colidx) == false, Xpetra::Exceptions::RuntimeError,
481 "Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
482
483 indout[c] = colidx;
484 valout[c] = value;
485 }
486 insertLocalValues(r, indout.view(0, indout.size()), valout.view(0, valout.size()));
487 }
488
489 // call fill complete
490 if (!domainMap.is_null() && !rangeMap.is_null())
491 this->fillComplete(domainMap, rowMap, params);
492 else
493 this->fillComplete(rowMap, rowMap, params);
494 }
495#endif
496
498 virtual ~EpetraCrsMatrixT() {}
499
501
503
504
507 XPETRA_MONITOR("EpetraCrsMatrixT::insertGlobalValues");
508 XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
509 }
510
513 XPETRA_MONITOR("EpetraCrsMatrixT::insertLocalValues");
514 XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
515 }
516
519 XPETRA_MONITOR("EpetraCrsMatrixT::replaceGlobalValues");
520
521 {
522 const std::string tfecfFuncName("replaceGlobalValues");
523 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!isFillActive(), std::runtime_error,
524 ": Fill must be active in order to call this method. If you have already "
525 "called fillComplete(), you need to call resumeFill() before you can "
526 "replace values.");
527
528 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
529 std::runtime_error, ": values.size() must equal indices.size().");
530 }
531
532 XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
533 }
534
537 XPETRA_MONITOR("EpetraCrsMatrixT::replaceLocalValues");
538
539 {
540 const std::string tfecfFuncName("replaceLocalValues");
541 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!isFillActive(), std::runtime_error,
542 ": Fill must be active in order to call this method. If you have already "
543 "called fillComplete(), you need to call resumeFill() before you can "
544 "replace values.");
545
546 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
547 std::runtime_error, ": values.size() must equal indices.size().");
548 }
549
550 XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
551 }
552
554 void setAllToScalar(const Scalar &alpha) {
555 XPETRA_MONITOR("EpetraCrsMatrixT::setAllToScalar");
556 mtx_->PutScalar(alpha);
557 }
558
560 void scale(const Scalar &alpha) {
561 XPETRA_MONITOR("EpetraCrsMatrixT::scale");
562 mtx_->Scale(alpha);
563 }
564
566 //** \warning This is an expert-only routine and should not be called from user code. */
567 void allocateAllValues(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {
568 XPETRA_MONITOR("EpetraCrsMatrixT::allocateAllValues");
569
570 // Row offsets
571 // Unfortunately, we cannot do this in the same manner as column indices
572 // and values (see below). The problem is that Tpetra insists on using
573 // size_t, and Epetra uses int internally. So we only resize here, and
574 // will need to copy in setAllValues
575 rowptr.resize(getLocalNumRows() + 1);
576
577 int lowerOffset = 0;
578 bool ownMemory = false;
579
580 // Column indices
581 // Extract, resize, set colind
582 Epetra_IntSerialDenseVector &myColind = mtx_->ExpertExtractIndices();
583 myColind.Resize(numNonZeros);
584 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
585
586 // Values
587 // Extract, reallocate, set values
588 double *&myValues = mtx_->ExpertExtractValues();
589 delete[] myValues;
590 myValues = new double[numNonZeros];
591 values = Teuchos::arcp(myValues, lowerOffset, numNonZeros, ownMemory);
592 }
593
595 void setAllValues(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind, const ArrayRCP<Scalar> &values) {
596 XPETRA_MONITOR("EpetraCrsMatrixT::setAllValues");
597
598 // Check sizes
599 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(rowptr.size()) != getLocalNumRows() + 1, Xpetra::Exceptions::RuntimeError,
600 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
602 "An exception is thrown to let you know that you mismatched your pointers.");
603
604 // Check pointers
605 if (values.size() > 0) {
606 TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
607 "An exception is thrown to let you know that you mismatched your pointers.");
608 TEUCHOS_TEST_FOR_EXCEPTION(values.getRawPtr() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
609 "An exception is thrown to let you know that you mismatched your pointers.");
610 }
611
612 // We have to make a copy here, it is unavoidable
613 // See comments in allocateAllValues
614 const size_t N = getLocalNumRows();
615
616 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
617 myRowptr.Resize(N + 1);
618 for (size_t i = 0; i < N + 1; i++)
619 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
620 }
621
624 XPETRA_MONITOR("EpetraCrsMatrixT::getAllValues");
625
626 int lowerOffset = 0;
627 bool ownMemory = false;
628
629 const size_t n = getLocalNumRows();
630 const size_t nnz = getLocalNumEntries();
631
632 // Row offsets
633 // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
634 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
635 rowptr.resize(n + 1);
636 for (size_t i = 0; i < n + 1; i++)
637 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
638
639 // Column indices
640 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
641
642 // Values
643 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
644 }
645
648 XPETRA_MONITOR("EpetraCrsMatrixT::getAllValues");
649
650 int lowerOffset = 0;
651 bool ownMemory = false;
652
653 const size_t nnz = getLocalNumEntries();
654 // Values
655 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
656 }
657
658 // Epetra always has global constants
659 bool haveGlobalConstants() const { return true; }
661 //** \warning This is an expert-only routine and should not be called from user code. */
663 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap,
664 const RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> > &importer = Teuchos::null,
665 const RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> > &exporter = Teuchos::null,
666 const RCP<ParameterList> & /* params */ = Teuchos::null) {
667 XPETRA_MONITOR("EpetraCrsMatrixT::expertStaticFillComplete");
668
669 // For Epetra matrices, resumeFill() is a fictive operation.
670 isFillResumed_ = false;
671
672 int rv = 0;
673 const Epetra_Import *myimport = 0;
674 const Epetra_Export *myexport = 0;
675
676 if (!importer.is_null()) {
677 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, *importer, eImporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
678 myimport = eImporter.getEpetra_Import().getRawPtr();
679 }
680 if (!exporter.is_null()) {
681 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, *exporter, eExporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
682 myexport = eExporter.getEpetra_Export().getRawPtr();
683 }
684
685 rv = mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), myimport, myexport);
686
687 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
688 }
690
692
693
695 void resumeFill(const RCP<ParameterList> & /* params */ = Teuchos::null) {
696 XPETRA_MONITOR("EpetraCrsMatrixT::resumeFill");
697
698 // According to Tpetra documentation, resumeFill() may be called repeatedly.
699 isFillResumed_ = true;
700 }
701
703 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap, const RCP<ParameterList> &params = Teuchos::null) {
704 XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
705
706 // For Epetra matrices, resumeFill() is a fictive operation.
707 isFillResumed_ = false;
708
709 bool doOptimizeStorage = true;
710 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
711 mtx_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), doOptimizeStorage);
712 }
713
715 void fillComplete(const RCP<ParameterList> &params = Teuchos::null) {
716 XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
717
718 // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
719 if (isFillResumed_ == true) {
720 isFillResumed_ = false;
721 return;
722 }
723
724 bool doOptimizeStorage = true;
725 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
726 mtx_->FillComplete(doOptimizeStorage);
727 }
728
731 XPETRA_MONITOR("EpetraCrsMatrixT::replaceDomainMapAndImporter");
732 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, *newImporter, eImporter, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter only accepts Xpetra::EpetraImportT.");
733
734 const RCP<const Epetra_Import> &myImport = eImporter.getEpetra_Import();
735 int rv = 0;
736 if (myImport == Teuchos::null)
737 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), 0);
738 else
739 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), &*myImport);
740 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
741 }
742
744
746
747
749 const RCP<const Comm<int> > getComm() const {
750 XPETRA_MONITOR("EpetraCrsMatrixT::getComm");
751 return toXpetra(mtx_->Comm());
752 }
753
756 XPETRA_MONITOR("EpetraCrsMatrixT::getRowMap");
757 return toXpetra<GlobalOrdinal, Node>(mtx_->RowMap());
758 }
759
762 XPETRA_MONITOR("EpetraCrsMatrixT::getColMap");
763 return toXpetra<GlobalOrdinal, Node>(mtx_->ColMap());
764 }
765
768 XPETRA_MONITOR("EpetraCrsMatrixT::getCrsGraph");
769 return toXpetra<GlobalOrdinal, Node>(mtx_->Graph());
770 }
771
774 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumRows");
775 return mtx_->NumGlobalRows64();
776 }
777
780 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumCols");
781 return mtx_->NumGlobalCols64();
782 }
783
785 size_t getLocalNumRows() const {
786 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalNumRows");
787 return mtx_->NumMyRows();
788 }
789
791 size_t getLocalNumCols() const {
792 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalNumCols");
793 return mtx_->NumMyCols();
794 }
795
798 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumEntries");
799 return mtx_->NumGlobalNonzeros64();
800 }
801
803 size_t getLocalNumEntries() const {
804 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalNumEntries");
805 return mtx_->NumMyNonzeros();
806 }
807
809 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
810 XPETRA_MONITOR("EpetraCrsMatrixT::getNumEntriesInLocalRow");
811 return mtx_->NumMyEntries(localRow);
812 }
813
815 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
816 XPETRA_MONITOR("EpetraCrsMatrixT::getNumEntriesInGlobalRow");
817 return mtx_->NumGlobalEntries(globalRow);
818 }
819
822 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalMaxNumRowEntries");
823 return mtx_->GlobalMaxNumEntries();
824 }
825
828 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalMaxNumRowEntries");
829 return mtx_->MaxNumEntries();
830 }
831
833 bool isLocallyIndexed() const {
834 XPETRA_MONITOR("EpetraCrsMatrixT::isLocallyIndexed");
835 return mtx_->IndicesAreLocal();
836 }
837
839 bool isGloballyIndexed() const {
840 XPETRA_MONITOR("EpetraCrsMatrixT::isGloballyIndexed");
841 return mtx_->IndicesAreGlobal();
842 }
843
845 bool isFillComplete() const {
846 XPETRA_MONITOR("EpetraCrsMatrixT::isFillComplete");
847 if (isFillResumed_)
848 return false;
849 else
850 return mtx_->Filled();
851 }
852
854 bool isFillActive() const {
855 XPETRA_MONITOR("EpetraCrsMatrixT::isFillActive");
856 return !isFillComplete();
857 }
858
861 XPETRA_MONITOR("EpetraCrsMatrixT::getFrobeniusNorm");
862 return mtx_->NormFrobenius();
863 }
864
866 bool supportsRowViews() const {
867 XPETRA_MONITOR("EpetraCrsMatrixT::supportsRowViews");
868 return true;
869 }
870
872 void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView<LocalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
873 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowCopy");
874
875 int numEntries = -1;
876 XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
877 NumEntries = numEntries;
878 }
879
881 void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView<GlobalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
882 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowCopy");
883
884 int numEntries = -1;
885 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
886 NumEntries = numEntries;
887 }
888
891 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowView");
892
893 int numEntries;
894 double *eValues;
895 GlobalOrdinal *eIndices;
896
897 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
898 if (numEntries == 0) {
899 eValues = NULL;
900 eIndices = NULL;
901 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
902
903 indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
904 values = ArrayView<const double>(eValues, numEntries);
905 }
906
909 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowView");
910
911 int numEntries;
912 double *eValues;
913 int *eIndices;
914
915 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
916 if (numEntries == 0) {
917 eValues = NULL;
918 eIndices = NULL;
919 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
920
921 indices = ArrayView<const int>(eIndices, numEntries);
922 values = ArrayView<const double>(eValues, numEntries);
923 }
924
927 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalDiagCopy");
928 XPETRA_ERR_CHECK(mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal, Node>(diag)));
929 }
930
932 void getLocalDiagOffsets(Teuchos::ArrayRCP<size_t> & /* offsets */) const {
933 TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagOffsets() is not implemented or supported.");
934 }
935
938 TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagCopy using offsets is not implemented or supported.");
939 }
940
942 void getLocalDiagCopy(Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> & /* diag */, const Kokkos::View<const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> & /* offsets */) const {
943 TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagCopy using offsets is not implemented or supported.");
944 }
945
948 mtx_->ReplaceDiagonalValues(toEpetra<GlobalOrdinal, Node>(diag));
949 }
950
952 XPETRA_ERR_CHECK(mtx_->LeftScale(toEpetra<GlobalOrdinal, Node>(x)));
953 };
955 XPETRA_ERR_CHECK(mtx_->RightScale(toEpetra<GlobalOrdinal, Node>(x)));
956 };
957
959
961
962
965 XPETRA_MONITOR("EpetraCrsMatrixT::apply");
966
967 // TEUCHOS_TEST_FOR_EXCEPTION((alpha != 1) || (beta != 0), Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.multiply() only accept alpha==1 and beta==0");
968
969 XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, X, eX, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
970 XPETRA_DYNAMIC_CAST(EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, Y, eY, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
971
972 TEUCHOS_TEST_FOR_EXCEPTION((mode != Teuchos::NO_TRANS) && (mode != Teuchos::TRANS), Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT->apply() only accept mode == NO_TRANS or mode == TRANS");
973 bool eTrans = toEpetra(mode);
974
975 // /!\ UseTranspose value
976 TEUCHOS_TEST_FOR_EXCEPTION(mtx_->UseTranspose(), Xpetra::Exceptions::NotImplemented, "An exception is throw to let you know that Xpetra::EpetraCrsMatrixT->apply() do not take into account the UseTranspose() parameter of Epetra_CrsMatrix.");
977
978 RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
979
980 // helper vector: tmp = A*x
982 tmp->PutScalar(0.0);
983 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
984
985 // calculate alpha * A * x + beta * y
986 XPETRA_ERR_CHECK(eY.getEpetra_MultiVector()->Update(alpha, *tmp, beta));
987 }
988
991 TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.apply() is not implemented for region matricies.");
992 }
993
996 XPETRA_MONITOR("EpetraCrsMatrixT::getDomainMap");
997 return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap());
998 }
999
1002 XPETRA_MONITOR("EpetraCrsMatrixT::getRangeMap");
1003 return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap());
1004 }
1005
1007
1009
1010
1012 std::string description() const {
1013 XPETRA_MONITOR("EpetraCrsMatrixT::description");
1014
1015 // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
1016 std::ostringstream oss;
1017 // TODO: oss << DistObject<char, LocalOrdinal,GlobalOrdinal>::description();
1018 if (isFillComplete()) {
1019 oss << "{status = fill complete"
1020 << ", global rows = " << getGlobalNumRows()
1021 << ", global cols = " << getGlobalNumCols()
1022 << ", global num entries = " << getGlobalNumEntries()
1023 << "}";
1024 } else {
1025 oss << "{status = fill not complete"
1026 << ", global rows = " << getGlobalNumRows()
1027 << "}";
1028 }
1029 return oss.str();
1030 }
1031
1034 XPETRA_MONITOR("EpetraCrsMatrixT::describe");
1035
1036 // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
1037 using std::endl;
1038 using std::setw;
1041 using Teuchos::VERB_HIGH;
1042 using Teuchos::VERB_LOW;
1044 using Teuchos::VERB_NONE;
1045 Teuchos::EVerbosityLevel vl = verbLevel;
1046 if (vl == VERB_DEFAULT) vl = VERB_LOW;
1047 RCP<const Comm<int> > comm = this->getComm();
1048 const int myImageID = comm->getRank(),
1049 numImages = comm->getSize();
1050 size_t width = 1;
1051 for (size_t dec = 10; dec < getGlobalNumRows(); dec *= 10) {
1052 ++width;
1053 }
1054 width = std::max<size_t>(width, 11) + 2;
1055 Teuchos::OSTab tab(out);
1056 // none: print nothing
1057 // low: print O(1) info from node 0
1058 // medium: print O(P) info, num entries per node
1059 // high: print O(N) info, num entries per row
1060 // extreme: print O(NNZ) info: print indices and values
1061 //
1062 // for medium and higher, print constituent objects at specified verbLevel
1063 if (vl != VERB_NONE) {
1064 if (myImageID == 0) out << this->description() << std::endl;
1065 // O(1) globals, minus what was already printed by description()
1066 if (isFillComplete() && myImageID == 0) {
1067 out << "Global max number of entries = " << getGlobalMaxNumRowEntries() << std::endl;
1068 }
1069 // constituent objects
1070 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1071 if (myImageID == 0) out << "\nRow map: " << std::endl;
1072 getRowMap()->describe(out, vl);
1073 //
1074 if (getColMap() != null) {
1075 if (getColMap() == getRowMap()) {
1076 if (myImageID == 0) out << "\nColumn map is row map.";
1077 } else {
1078 if (myImageID == 0) out << "\nColumn map: " << std::endl;
1079 getColMap()->describe(out, vl);
1080 }
1081 }
1082 if (getDomainMap() != null) {
1083 if (getDomainMap() == getRowMap()) {
1084 if (myImageID == 0) out << "\nDomain map is row map.";
1085 } else if (getDomainMap() == getColMap()) {
1086 if (myImageID == 0) out << "\nDomain map is row map.";
1087 } else {
1088 if (myImageID == 0) out << "\nDomain map: " << std::endl;
1089 getDomainMap()->describe(out, vl);
1090 }
1091 }
1092 if (getRangeMap() != null) {
1093 if (getRangeMap() == getDomainMap()) {
1094 if (myImageID == 0) out << "\nRange map is domain map." << std::endl;
1095 } else if (getRangeMap() == getRowMap()) {
1096 if (myImageID == 0) out << "\nRange map is row map." << std::endl;
1097 } else {
1098 if (myImageID == 0) out << "\nRange map: " << std::endl;
1099 getRangeMap()->describe(out, vl);
1100 }
1101 }
1102 if (myImageID == 0) out << std::endl;
1103 }
1104 // O(P) data
1105 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1106 for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1107 if (myImageID == imageCtr) {
1108 out << "Node ID = " << imageCtr << std::endl;
1109 // TODO: need a graph
1110 // if (staticGraph_->indicesAreAllocated() == false) {
1111 // out << "Node not allocated" << std::endl;
1112 // }
1113 // else {
1114 // out << "Node number of allocated entries = " << staticGraph_->getLocalAllocationSize() << std::endl;
1115 // }
1116
1117 // TMP:
1118 // const Epetra_CrsGraph & staticGraph_ = mtx_->Graph();
1119 // End of TMP
1120
1121 out << "Node number of entries = " << getLocalNumEntries() << std::endl;
1122 out << "Node max number of entries = " << getLocalMaxNumRowEntries() << std::endl;
1123 }
1124 comm->barrier();
1125 comm->barrier();
1126 comm->barrier();
1127 }
1128 }
1129 // O(N) and O(NNZ) data
1130 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1131 for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1132 if (myImageID == imageCtr) {
1133 out << std::setw(width) << "Node ID"
1134 << std::setw(width) << "Global Row"
1135 << std::setw(width) << "Num Entries";
1136 if (vl == VERB_EXTREME) {
1137 out << std::setw(width) << "(Index,Value)";
1138 }
1139 out << std::endl;
1140 for (size_t r = 0; r < getLocalNumRows(); ++r) {
1141 const size_t nE = getNumEntriesInLocalRow(r);
1142 GlobalOrdinal gid = getRowMap()->getGlobalElement(r);
1143 out << std::setw(width) << myImageID
1144 << std::setw(width) << gid
1145 << std::setw(width) << nE;
1146 if (vl == VERB_EXTREME) {
1147 if (isGloballyIndexed()) {
1150 getGlobalRowView(gid, rowinds, rowvals);
1151 for (size_t j = 0; j < nE; ++j) {
1152 out << " (" << rowinds[j]
1153 << ", " << rowvals[j]
1154 << ") ";
1155 }
1156 } else if (isLocallyIndexed()) {
1159 getLocalRowView(r, rowinds, rowvals);
1160 for (size_t j = 0; j < nE; ++j) {
1161 out << " (" << getColMap()->getGlobalElement(rowinds[j])
1162 << ", " << rowvals[j]
1163 << ") ";
1164 }
1165 }
1166 }
1167 out << std::endl;
1168 }
1169 }
1170 comm->barrier();
1171 comm->barrier();
1172 comm->barrier();
1173 }
1174 }
1175 }
1176 }
1177
1178 void setObjectLabel(const std::string &objectLabel) {
1180 mtx_->SetLabel(objectLabel.c_str());
1181 }
1183
1186 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_))))
1187 , isFillResumed_(false) {}
1188
1190 //{@
1191
1194 XPETRA_MONITOR("EpetraCrsMatrixT::getMap");
1195 return toXpetra<GlobalOrdinal, Node>(mtx_->Map());
1196 }
1197
1201 XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
1202
1203 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1204 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1205
1206 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1207 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1208 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1209 }
1210
1214 XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
1215
1216 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1217 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1218
1219 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1220 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1221 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1222 }
1223
1227 XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
1228
1229 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1230 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1231
1232 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1233 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1234 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1235 }
1236
1240 XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
1241
1242 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1243 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1244
1245 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1246 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1247 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Caught nonzero error code " + std::to_string(err) + " returned by Epetra.");
1248 }
1249
1251 XPETRA_MONITOR("EpetraCrsMatrixT::removeEmptyProcessesInPlace");
1252 const Epetra_Map *newMapEpetra = (!newMap.is_null()) ? &toEpetra<GlobalOrdinal, Node>(newMap) : 0;
1253 int err = mtx_->RemoveEmptyProcessesInPlace(newMapEpetra);
1254 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Caught nonzero error code " + std::to_string(err) + " returned by Epetra.");
1255 }
1256
1258
1260
1261
1263 bool hasMatrix() const { return !mtx_.is_null(); }
1264
1267 : mtx_(mtx)
1268 , isFillResumed_(false) {}
1269
1272
1274 RCP<Epetra_CrsMatrix> getEpetra_CrsMatrixNonConst() const { return mtx_; } // TODO: remove
1275
1276#ifdef HAVE_XPETRA_TPETRA
1278
1280#if 0
1282 "Xpetra::EpetraCrsMatrx only available on host for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
1284#endif
1285 return getLocalMatrixHost();
1286 }
1287
1288#if KOKKOS_VERSION >= 40799
1289 typename local_matrix_type::host_mirror_type getLocalMatrixHost() const {
1290#else
1291 typename local_matrix_type::HostMirror getLocalMatrixHost() const {
1292#endif
1293 RCP<Epetra_CrsMatrix> matrix = getEpetra_CrsMatrixNonConst();
1294
1295 const int numRows = matrix->NumMyRows();
1296 const int numCols = matrix->NumMyCols();
1297 const int nnz = matrix->NumMyNonzeros();
1298
1299 int *rowptr;
1300 int *colind;
1301 double *vals;
1302 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
1303 TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error, "Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
1304
1305 // Transform int* rowptr array to size_type* array
1306 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
1307 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
1308 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
1309
1310 // create Kokkos::Views
1311 typename local_matrix_type::index_type kokkosColind(colind, nnz);
1312 typename local_matrix_type::values_type kokkosVals(vals, nnz);
1313
1314 local_matrix_type localMatrix = local_matrix_type("LocalMatrix", numRows, numCols, nnz, kokkosVals, kokkosRowPtr, kokkosColind);
1315
1316 return localMatrix;
1317 }
1318
1319 void setAllValues(const typename local_matrix_type::row_map_type &ptr,
1320 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
1321 const typename local_matrix_type::values_type &val) {
1322 // Check sizes
1323 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(ptr.size()) != getLocalNumRows() + 1, Xpetra::Exceptions::RuntimeError,
1324 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1326 "An exception is thrown to let you know that you mismatched your pointers.");
1327
1328 // Check pointers
1329 if (val.size() > 0) {
1330 std::cout << ind.data() << " " << mtx_->ExpertExtractIndices().Values() << std::endl;
1331 TEUCHOS_TEST_FOR_EXCEPTION(ind.data() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
1332 "An exception is thrown to let you know that you mismatched your pointers.");
1333 TEUCHOS_TEST_FOR_EXCEPTION(val.data() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
1334 "An exception is thrown to let you know that you mismatched your pointers.");
1335 }
1336
1337 // We have to make a copy here, it is unavoidable
1338 // See comments in allocateAllValues
1339 const size_t N = getLocalNumRows();
1340
1341 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1342 myRowptr.Resize(N + 1);
1343 for (size_t i = 0; i < N + 1; i++)
1344 myRowptr[i] = Teuchos::as<int>(ptr(i));
1345 }
1346
1347 LocalOrdinal GetStorageBlockSize() const { return 1; }
1348
1349 private:
1350#else
1351#ifdef __GNUC__
1352#warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
1353#endif
1354#endif
1356
1365
1366 private:
1369
1377
1378}; // EpetraCrsMatrixT class
1379
1380#endif //#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
1381
1382#ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1383template <>
1385 : public CrsMatrix<double, int, long long, EpetraNode> {
1386 typedef long long GlobalOrdinal;
1390
1391 // The following typedefs are used by the Kokkos interface
1392#ifdef HAVE_XPETRA_TPETRA
1393 public:
1398
1399 private:
1400#endif
1401
1402 public:
1404
1405
1407 EpetraCrsMatrixT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
1408 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), maxNumEntriesPerRow, true)))
1409 , isFillResumed_(false) {}
1410
1412 EpetraCrsMatrixT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rowMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc, const Teuchos::RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
1413 : isFillResumed_(false) {
1414 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
1415 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(), true));
1416 }
1417
1419 EpetraCrsMatrixT(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> & /* plist */ = Teuchos::null)
1420 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), maxNumEntriesPerRow, true)))
1421 , isFillResumed_(false) {}
1422
1424 EpetraCrsMatrixT(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> & /* plist */ = Teuchos::null)
1425 : isFillResumed_(false) {
1426 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
1427 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
1428 }
1429
1432 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(graph))))
1433 , isFillResumed_(false) {}
1434
1438 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
1439 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
1440 const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null)
1441 : isFillResumed_(false) {
1442 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
1443 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
1444
1445 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1446 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1447
1448 // Follows the Tpetra parameters
1449 bool restrictComm = false;
1450 if (!params.is_null()) restrictComm = params->get("Restrict Communicator", restrictComm);
1451 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), myDomainMap, myRangeMap, restrictComm));
1452 if (restrictComm && mtx_->NumMyRows() == 0)
1453 mtx_ = Teuchos::null;
1454 }
1455
1459 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
1460 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
1461 const Teuchos::RCP<Teuchos::ParameterList> &params = Teuchos::null)
1462 : isFillResumed_(false) {
1463 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
1464 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
1465
1466 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1467 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1468
1469 // Follows the Tpetra parameters
1470 bool restrictComm = false;
1471 if (!params.is_null()) restrictComm = params->get("Restrict Communicator", restrictComm);
1472
1473 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), myDomainMap, myRangeMap, restrictComm));
1474 }
1475
1478 const Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> > DomainImporter,
1482 : isFillResumed_(false) {
1483 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
1484 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, RowImporter, tImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
1485 XPETRA_RCP_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, DomainImporter, tdImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
1486
1487 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1488 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1489
1490 // Follows the Tpetra parameters
1491 bool restrictComm = false;
1492 if (!params.is_null()) restrictComm = params->get("Restrict Communicator", restrictComm);
1493 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tImporter.getEpetra_Import(), tdImporter->getEpetra_Import().get(), myDomainMap, myRangeMap, restrictComm));
1494 if (restrictComm && mtx_->NumMyRows() == 0)
1495 mtx_ = Teuchos::null;
1496 }
1497
1500 const Teuchos::RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> > DomainExporter,
1504 : isFillResumed_(false) {
1505 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
1506 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, RowExporter, tExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
1507 XPETRA_RCP_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, DomainExporter, tdExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
1508
1509 const Epetra_Map *myDomainMap = (domainMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(domainMap) : 0;
1510 const Epetra_Map *myRangeMap = (rangeMap != Teuchos::null) ? &toEpetra<GlobalOrdinal, Node>(rangeMap) : 0;
1511
1512 // Follows the Tpetra parameters
1513 bool restrictComm = false;
1514 if (!params.is_null()) restrictComm = params->get("Restrict Communicator", restrictComm);
1515
1516 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(), *tExporter.getEpetra_Export(), tdExporter->getEpetra_Export().get(), myDomainMap, myRangeMap, restrictComm));
1517 }
1518
1519#ifdef HAVE_XPETRA_TPETRA
1542 const local_matrix_type &lclMatrix,
1543 const Teuchos::RCP<Teuchos::ParameterList> &params = null)
1544 : EpetraCrsMatrixT(lclMatrix, rowMap, colMap, Teuchos::null, Teuchos::null, params) {}
1545
1547 const local_matrix_type &lclMatrix,
1550 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap = Teuchos::null,
1551 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap = Teuchos::null,
1552 const Teuchos::RCP<Teuchos::ParameterList> &params = null) {
1553 // local typedefs from local_matrix_type
1554 // typedef typename local_matrix_type::size_type size_type;
1555 typedef typename local_matrix_type::value_type value_type;
1556 typedef typename local_matrix_type::ordinal_type ordinal_type;
1557
1558 // The number of rows in the sparse matrix.
1559 ordinal_type lclNumRows = lclMatrix.numRows();
1560 ordinal_type lclNumCols = lclMatrix.numCols(); // do we need this?
1561
1562 // plausibility checks
1563 TEUCHOS_TEST_FOR_EXCEPTION(lclNumRows != Teuchos::as<ordinal_type>(rowMap->getLocalNumElements()), Xpetra::Exceptions::RuntimeError,
1564 "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
1565 TEUCHOS_TEST_FOR_EXCEPTION(lclNumCols != Teuchos::as<ordinal_type>(colMap->getLocalNumElements()), Xpetra::Exceptions::RuntimeError,
1566 "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
1567
1568 Teuchos::ArrayRCP<size_t> NumEntriesPerRowToAlloc(lclNumRows);
1569 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1570 // extract data from current row r
1571 auto rowview = lclMatrix.row(r);
1572 NumEntriesPerRowToAlloc[r] = rowview.length;
1573 }
1574
1575 // setup matrix
1576 isFillResumed_ = false;
1577 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
1578 mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
1579
1580 // loop over all rows and colums of local matrix and fill matrix
1581 for (ordinal_type r = 0; r < lclNumRows; ++r) {
1582 // extract data from current row r
1583 auto rowview = lclMatrix.row(r);
1584
1585 // arrays for current row data
1588
1589 for (ordinal_type c = 0; c < rowview.length; c++) {
1590 value_type value = rowview.value(c);
1591 ordinal_type colidx = rowview.colidx(c);
1592
1593 TEUCHOS_TEST_FOR_EXCEPTION(colMap->isNodeLocalElement(colidx) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrixT: local matrix contains column elements which are not in the provided column map!");
1594
1595 indout[c] = colidx;
1596 valout[c] = value;
1597 }
1598 insertLocalValues(r, indout.view(0, indout.size()), valout.view(0, valout.size()));
1599 }
1600
1601 // call fill complete
1602 if (!domainMap.is_null() && !rangeMap.is_null())
1603 this->fillComplete(domainMap, rowMap, params);
1604 else
1605 this->fillComplete(rowMap, rowMap, params);
1606 }
1607#endif
1608
1611
1613
1615
1616
1619 XPETRA_MONITOR("EpetraCrsMatrixT::insertGlobalValues");
1620 XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1621 }
1622
1625 XPETRA_MONITOR("EpetraCrsMatrixT::insertLocalValues");
1626 XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1627 }
1628
1631 XPETRA_MONITOR("EpetraCrsMatrixT::replaceGlobalValues");
1632
1633 {
1634 const std::string tfecfFuncName("replaceGlobalValues");
1635 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!isFillActive(), std::runtime_error,
1636 ": Fill must be active in order to call this method. If you have already "
1637 "called fillComplete(), you need to call resumeFill() before you can "
1638 "replace values.");
1639
1640 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1641 std::runtime_error, ": values.size() must equal indices.size().");
1642 }
1643
1644 XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1645 }
1646
1649 XPETRA_MONITOR("EpetraCrsMatrixT::replaceLocalValues");
1650
1651 {
1652 const std::string tfecfFuncName("replaceLocalValues");
1653 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!isFillActive(), std::runtime_error,
1654 ": Fill must be active in order to call this method. If you have already "
1655 "called fillComplete(), you need to call resumeFill() before you can "
1656 "replace values.");
1657
1658 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1659 std::runtime_error, ": values.size() must equal indices.size().");
1660 }
1661
1662 XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1663 }
1664
1666 void setAllToScalar(const Scalar &alpha) {
1667 XPETRA_MONITOR("EpetraCrsMatrixT::setAllToScalar");
1668 mtx_->PutScalar(alpha);
1669 }
1670
1672 void scale(const Scalar &alpha) {
1673 XPETRA_MONITOR("EpetraCrsMatrixT::scale");
1674 mtx_->Scale(alpha);
1675 }
1676
1678 //** \warning This is an expert-only routine and should not be called from user code. */
1679 void allocateAllValues(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind, ArrayRCP<Scalar> &values) {
1680 XPETRA_MONITOR("EpetraCrsMatrixT::allocateAllValues");
1681
1682 // Row offsets
1683 // Unfortunately, we cannot do this in the same manner as column indices
1684 // and values (see below). The problem is that Tpetra insists on using
1685 // size_t, and Epetra uses int internally. So we only resize here, and
1686 // will need to copy in setAllValues
1687 rowptr.resize(getLocalNumRows() + 1);
1688
1689 int lowerOffset = 0;
1690 bool ownMemory = false;
1691
1692 // Column indices
1693 // Extract, resize, set colind
1694 Epetra_IntSerialDenseVector &myColind = mtx_->ExpertExtractIndices();
1695 myColind.Resize(numNonZeros);
1696 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1697
1698 // Values
1699 // Extract, reallocate, set values
1700 double *&myValues = mtx_->ExpertExtractValues();
1701 delete[] myValues;
1702 myValues = new double[numNonZeros];
1703 values = Teuchos::arcp(myValues, lowerOffset, numNonZeros, ownMemory);
1704 }
1705
1707 void setAllValues(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind, const ArrayRCP<Scalar> &values) {
1708 XPETRA_MONITOR("EpetraCrsMatrixT::setAllValues");
1709
1710 // Check sizes
1711 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(rowptr.size()) != getLocalNumRows() + 1, Xpetra::Exceptions::RuntimeError,
1712 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1714 "An exception is thrown to let you know that you mismatched your pointers.");
1715
1716 // Check pointers
1717 if (values.size() > 0) {
1718 TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
1719 "An exception is thrown to let you know that you mismatched your pointers.");
1720 TEUCHOS_TEST_FOR_EXCEPTION(values.getRawPtr() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
1721 "An exception is thrown to let you know that you mismatched your pointers.");
1722 }
1723
1724 // We have to make a copy here, it is unavoidable
1725 // See comments in allocateAllValues
1726 const size_t N = getLocalNumRows();
1727
1728 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1729 myRowptr.Resize(N + 1);
1730 for (size_t i = 0; i < N + 1; i++)
1731 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1732 }
1733
1736 XPETRA_MONITOR("EpetraCrsMatrixT::getAllValues");
1737
1738 int lowerOffset = 0;
1739 bool ownMemory = false;
1740
1741 const size_t n = getLocalNumRows();
1742 const size_t nnz = getLocalNumEntries();
1743
1744 // Row offsets
1745 // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
1746 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
1747 rowptr.resize(n + 1);
1748 for (size_t i = 0; i < n + 1; i++)
1749 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1750
1751 // Column indices
1752 colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1753
1754 // Values
1755 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1756 }
1757
1760 XPETRA_MONITOR("EpetraCrsMatrixT::getAllValues");
1761
1762 int lowerOffset = 0;
1763 bool ownMemory = false;
1764
1765 const size_t nnz = getLocalNumEntries();
1766 // Values
1767 values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1768 }
1769
1770 // Epetra always has global constants
1771 bool haveGlobalConstants() const { return true; }
1772
1774 //** \warning This is an expert-only routine and should not be called from user code. */
1776 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap,
1777 const RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> > &importer = Teuchos::null,
1778 const RCP<const Export<LocalOrdinal, GlobalOrdinal, Node> > &exporter = Teuchos::null,
1779 const RCP<ParameterList> & /* params */ = Teuchos::null) {
1780 XPETRA_MONITOR("EpetraCrsMatrixT::expertStaticFillComplete");
1781
1782 // For Epetra matrices, resumeFill() is a fictive operation.
1783 isFillResumed_ = false;
1784
1785 int rv = 0;
1786 const Epetra_Import *myimport = 0;
1787 const Epetra_Export *myexport = 0;
1788
1789 if (!importer.is_null()) {
1790 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, *importer, eImporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
1791 myimport = eImporter.getEpetra_Import().getRawPtr();
1792 }
1793 if (!exporter.is_null()) {
1794 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, *exporter, eExporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
1795 myexport = eExporter.getEpetra_Export().getRawPtr();
1796 }
1797
1798 rv = mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), myimport, myexport);
1799
1800 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
1801 }
1803
1805
1806
1808 void resumeFill(const RCP<ParameterList> & /* params */ = Teuchos::null) {
1809 XPETRA_MONITOR("EpetraCrsMatrixT::resumeFill");
1810
1811 // According to Tpetra documentation, resumeFill() may be called repeatedly.
1812 isFillResumed_ = true;
1813 }
1814
1816 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &rangeMap, const RCP<ParameterList> &params = Teuchos::null) {
1817 XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
1818
1819 // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
1820 if (isFillResumed_ == true) {
1821 isFillResumed_ = false;
1822 return;
1823 }
1824
1825 bool doOptimizeStorage = true;
1826 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
1827 mtx_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap), doOptimizeStorage);
1828 }
1829
1831 void fillComplete(const RCP<ParameterList> &params = Teuchos::null) {
1832 XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
1833
1834 // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
1835 if (isFillResumed_ == true) {
1836 isFillResumed_ = false;
1837 return;
1838 }
1839
1840 bool doOptimizeStorage = true;
1841 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
1842 mtx_->FillComplete(doOptimizeStorage);
1843 }
1844
1847 XPETRA_MONITOR("EpetraCrsMatrixT::replaceDomainMapAndImporter");
1848 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, *newImporter, eImporter, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter only accepts Xpetra::EpetraImportT.");
1849
1850 const RCP<const Epetra_Import> &myImport = eImporter.getEpetra_Import();
1851 int rv = 0;
1852 if (myImport == Teuchos::null)
1853 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), 0);
1854 else
1855 rv = mtx_->ReplaceDomainMapAndImporter(toEpetra<GlobalOrdinal, Node>(newDomainMap), &*myImport);
1856 TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
1857 }
1858
1860
1862
1863
1866 XPETRA_MONITOR("EpetraCrsMatrixT::getComm");
1867 return toXpetra(mtx_->Comm());
1868 }
1869
1872 XPETRA_MONITOR("EpetraCrsMatrixT::getRowMap");
1873 return toXpetra<GlobalOrdinal, Node>(mtx_->RowMap());
1874 }
1875
1878 XPETRA_MONITOR("EpetraCrsMatrixT::getColMap");
1879 return toXpetra<GlobalOrdinal, Node>(mtx_->ColMap());
1880 }
1881
1884 XPETRA_MONITOR("EpetraCrsMatrixT::getCrsGraph");
1885 return toXpetra<GlobalOrdinal, Node>(mtx_->Graph());
1886 }
1887
1890 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumRows");
1891 return mtx_->NumGlobalRows64();
1892 }
1893
1896 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumCols");
1897 return mtx_->NumGlobalCols64();
1898 }
1899
1901 size_t getLocalNumRows() const {
1902 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalNumRows");
1903 return mtx_->NumMyRows();
1904 }
1905
1907 size_t getLocalNumCols() const {
1908 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalNumCols");
1909 return mtx_->NumMyCols();
1910 }
1911
1914 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumEntries");
1915 return mtx_->NumGlobalNonzeros64();
1916 }
1917
1919 size_t getLocalNumEntries() const {
1920 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalNumEntries");
1921 return mtx_->NumMyNonzeros();
1922 }
1923
1925 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
1926 XPETRA_MONITOR("EpetraCrsMatrixT::getNumEntriesInLocalRow");
1927 return mtx_->NumMyEntries(localRow);
1928 }
1929
1931 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
1932 XPETRA_MONITOR("EpetraCrsMatrixT::getNumEntriesInGlobalRow");
1933 return mtx_->NumGlobalEntries(globalRow);
1934 }
1935
1938 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalMaxNumRowEntries");
1939 return mtx_->GlobalMaxNumEntries();
1940 }
1941
1944 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalMaxNumRowEntries");
1945 return mtx_->MaxNumEntries();
1946 }
1947
1949 bool isLocallyIndexed() const {
1950 XPETRA_MONITOR("EpetraCrsMatrixT::isLocallyIndexed");
1951 return mtx_->IndicesAreLocal();
1952 }
1953
1955 bool isGloballyIndexed() const {
1956 XPETRA_MONITOR("EpetraCrsMatrixT::isGloballyIndexed");
1957 return mtx_->IndicesAreGlobal();
1958 }
1959
1961 bool isFillComplete() const {
1962 XPETRA_MONITOR("EpetraCrsMatrixT::isFillComplete");
1963 if (isFillResumed_)
1964 return false;
1965 else
1966 return mtx_->Filled();
1967 }
1968
1970 bool isFillActive() const {
1971 XPETRA_MONITOR("EpetraCrsMatrixT::isFillActive");
1972 return !isFillComplete();
1973 }
1974
1977 XPETRA_MONITOR("EpetraCrsMatrixT::getFrobeniusNorm");
1978 return mtx_->NormFrobenius();
1979 }
1980
1982 bool supportsRowViews() const {
1983 XPETRA_MONITOR("EpetraCrsMatrixT::supportsRowViews");
1984 return true;
1985 }
1986
1988 void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView<LocalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
1989 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowCopy");
1990
1991 int numEntries = -1;
1992 XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1993 NumEntries = numEntries;
1994 }
1995
1997 void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView<GlobalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
1998 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowCopy");
1999
2000 int numEntries = -1;
2001 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
2002 NumEntries = numEntries;
2003 }
2004
2007 XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowView");
2008
2009 int numEntries;
2010 double *eValues;
2011 GlobalOrdinal *eIndices;
2012
2013 XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
2014 if (numEntries == 0) {
2015 eValues = NULL;
2016 eIndices = NULL;
2017 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
2018
2019 indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
2020 values = ArrayView<const double>(eValues, numEntries);
2021 }
2022
2025 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowView");
2026
2027 int numEntries;
2028 double *eValues;
2029 int *eIndices;
2030
2031 XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
2032 if (numEntries == 0) {
2033 eValues = NULL;
2034 eIndices = NULL;
2035 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
2036
2037 indices = ArrayView<const int>(eIndices, numEntries);
2038 values = ArrayView<const double>(eValues, numEntries);
2039 }
2040
2043 XPETRA_MONITOR("EpetraCrsMatrixT::getLocalDiagCopy");
2044 mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal, Node>(diag));
2045 }
2046
2049 TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagOffsets() is not implemented or supported.");
2050 }
2051
2054 TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagCopy using offsets is not implemented or supported.");
2055 }
2056
2058 void getLocalDiagCopy(Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> & /* diag */, const Kokkos::View<const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> & /* offsets */) const {
2059 TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagCopy using offsets is not implemented or supported.");
2060 }
2061
2064 mtx_->ReplaceDiagonalValues(toEpetra<GlobalOrdinal, Node>(diag));
2065 }
2066
2068 XPETRA_ERR_CHECK(mtx_->LeftScale(toEpetra<GlobalOrdinal, Node>(x)));
2069 };
2071 XPETRA_ERR_CHECK(mtx_->RightScale(toEpetra<GlobalOrdinal, Node>(x)));
2072 };
2073
2075
2077
2078
2081 XPETRA_MONITOR("EpetraCrsMatrixT::apply");
2082
2083 // TEUCHOS_TEST_FOR_EXCEPTION((alpha != 1) || (beta != 0), Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.multiply() only accept alpha==1 and beta==0");
2084
2085 XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, X, eX, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
2086 XPETRA_DYNAMIC_CAST(EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, Y, eY, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
2087
2088 TEUCHOS_TEST_FOR_EXCEPTION((mode != Teuchos::NO_TRANS) && (mode != Teuchos::TRANS), Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT->apply() only accept mode == NO_TRANS or mode == TRANS");
2089 bool eTrans = toEpetra(mode);
2090
2091 // /!\ UseTranspose value
2092 TEUCHOS_TEST_FOR_EXCEPTION(mtx_->UseTranspose(), Xpetra::Exceptions::NotImplemented, "An exception is throw to let you know that Xpetra::EpetraCrsMatrixT->apply() do not take into account the UseTranspose() parameter of Epetra_CrsMatrix.");
2093
2094 RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
2095
2096 // helper vector: tmp = A*x
2098 tmp->PutScalar(0.0);
2099 XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
2100
2101 // calculate alpha * A * x + beta * y
2102 XPETRA_ERR_CHECK(eY.getEpetra_MultiVector()->Update(alpha, *tmp, beta));
2103 }
2104
2106 TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.apply() is not implemented for region matricies.");
2107 }
2108
2111 XPETRA_MONITOR("EpetraCrsMatrixT::getDomainMap");
2112 return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap());
2113 }
2114
2117 XPETRA_MONITOR("EpetraCrsMatrixT::getRangeMap");
2118 return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap());
2119 }
2120
2122
2124
2125
2127 std::string description() const {
2128 XPETRA_MONITOR("EpetraCrsMatrixT::description");
2129
2130 // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
2131 std::ostringstream oss;
2132 // TODO: oss << DistObject<char, LocalOrdinal,GlobalOrdinal>::description();
2133 if (isFillComplete()) {
2134 oss << "{status = fill complete"
2135 << ", global rows = " << getGlobalNumRows()
2136 << ", global cols = " << getGlobalNumCols()
2137 << ", global num entries = " << getGlobalNumEntries()
2138 << "}";
2139 } else {
2140 oss << "{status = fill not complete"
2141 << ", global rows = " << getGlobalNumRows()
2142 << "}";
2143 }
2144 return oss.str();
2145 }
2146
2149 XPETRA_MONITOR("EpetraCrsMatrixT::describe");
2150
2151 // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
2152 using std::endl;
2153 using std::setw;
2156 using Teuchos::VERB_HIGH;
2157 using Teuchos::VERB_LOW;
2159 using Teuchos::VERB_NONE;
2160 Teuchos::EVerbosityLevel vl = verbLevel;
2161 if (vl == VERB_DEFAULT) vl = VERB_LOW;
2162 RCP<const Comm<int> > comm = this->getComm();
2163 const int myImageID = comm->getRank(),
2164 numImages = comm->getSize();
2165 size_t width = 1;
2166 for (size_t dec = 10; dec < getGlobalNumRows(); dec *= 10) {
2167 ++width;
2168 }
2169 width = std::max<size_t>(width, 11) + 2;
2170 Teuchos::OSTab tab(out);
2171 // none: print nothing
2172 // low: print O(1) info from node 0
2173 // medium: print O(P) info, num entries per node
2174 // high: print O(N) info, num entries per row
2175 // extreme: print O(NNZ) info: print indices and values
2176 //
2177 // for medium and higher, print constituent objects at specified verbLevel
2178 if (vl != VERB_NONE) {
2179 if (myImageID == 0) out << this->description() << std::endl;
2180 // O(1) globals, minus what was already printed by description()
2181 if (isFillComplete() && myImageID == 0) {
2182 out << "Global max number of entries = " << getGlobalMaxNumRowEntries() << std::endl;
2183 }
2184 // constituent objects
2185 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2186 if (myImageID == 0) out << "\nRow map: " << std::endl;
2187 getRowMap()->describe(out, vl);
2188 //
2189 if (getColMap() != null) {
2190 if (getColMap() == getRowMap()) {
2191 if (myImageID == 0) out << "\nColumn map is row map.";
2192 } else {
2193 if (myImageID == 0) out << "\nColumn map: " << std::endl;
2194 getColMap()->describe(out, vl);
2195 }
2196 }
2197 if (getDomainMap() != null) {
2198 if (getDomainMap() == getRowMap()) {
2199 if (myImageID == 0) out << "\nDomain map is row map.";
2200 } else if (getDomainMap() == getColMap()) {
2201 if (myImageID == 0) out << "\nDomain map is row map.";
2202 } else {
2203 if (myImageID == 0) out << "\nDomain map: " << std::endl;
2204 getDomainMap()->describe(out, vl);
2205 }
2206 }
2207 if (getRangeMap() != null) {
2208 if (getRangeMap() == getDomainMap()) {
2209 if (myImageID == 0) out << "\nRange map is domain map." << std::endl;
2210 } else if (getRangeMap() == getRowMap()) {
2211 if (myImageID == 0) out << "\nRange map is row map." << std::endl;
2212 } else {
2213 if (myImageID == 0) out << "\nRange map: " << std::endl;
2214 getRangeMap()->describe(out, vl);
2215 }
2216 }
2217 if (myImageID == 0) out << std::endl;
2218 }
2219 // O(P) data
2220 if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
2221 for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2222 if (myImageID == imageCtr) {
2223 out << "Node ID = " << imageCtr << std::endl;
2224 // TODO: need a graph
2225 // if (staticGraph_->indicesAreAllocated() == false) {
2226 // out << "Node not allocated" << std::endl;
2227 // }
2228 // else {
2229 // out << "Node number of allocated entries = " << staticGraph_->getLocalAllocationSize() << std::endl;
2230 // }
2231
2232 // TMP:
2233 // const Epetra_CrsGraph & staticGraph_ = mtx_->Graph();
2234 // End of TMP
2235
2236 out << "Node number of entries = " << getLocalNumEntries() << std::endl;
2237 out << "Node max number of entries = " << getLocalMaxNumRowEntries() << std::endl;
2238 }
2239 comm->barrier();
2240 comm->barrier();
2241 comm->barrier();
2242 }
2243 }
2244 // O(N) and O(NNZ) data
2245 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
2246 for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
2247 if (myImageID == imageCtr) {
2248 out << std::setw(width) << "Node ID"
2249 << std::setw(width) << "Global Row"
2250 << std::setw(width) << "Num Entries";
2251 if (vl == VERB_EXTREME) {
2252 out << std::setw(width) << "(Index,Value)";
2253 }
2254 out << std::endl;
2255 for (size_t r = 0; r < getLocalNumRows(); ++r) {
2256 const size_t nE = getNumEntriesInLocalRow(r);
2257 GlobalOrdinal gid = getRowMap()->getGlobalElement(r);
2258 out << std::setw(width) << myImageID
2259 << std::setw(width) << gid
2260 << std::setw(width) << nE;
2261 if (vl == VERB_EXTREME) {
2262 if (isGloballyIndexed()) {
2265 getGlobalRowView(gid, rowinds, rowvals);
2266 for (size_t j = 0; j < nE; ++j) {
2267 out << " (" << rowinds[j]
2268 << ", " << rowvals[j]
2269 << ") ";
2270 }
2271 } else if (isLocallyIndexed()) {
2274 getLocalRowView(r, rowinds, rowvals);
2275 for (size_t j = 0; j < nE; ++j) {
2276 out << " (" << getColMap()->getGlobalElement(rowinds[j])
2277 << ", " << rowvals[j]
2278 << ") ";
2279 }
2280 }
2281 }
2282 out << std::endl;
2283 }
2284 }
2285 comm->barrier();
2286 comm->barrier();
2287 comm->barrier();
2288 }
2289 }
2290 }
2291 }
2292
2293 void setObjectLabel(const std::string &objectLabel) {
2295 mtx_->SetLabel(objectLabel.c_str());
2296 }
2298
2301 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_))))
2302 , isFillResumed_(false) {}
2303
2305 //{@
2306
2309 XPETRA_MONITOR("EpetraCrsMatrixT::getMap");
2310 return toXpetra<GlobalOrdinal, Node>(mtx_->Map());
2311 }
2312
2316 XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
2317
2318 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
2319 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
2320
2321 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2322 int err = mtx_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
2323 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
2324 }
2325
2329 XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
2330
2331 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
2332 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
2333
2334 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
2335 int err = mtx_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
2336 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
2337 }
2338
2342 XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
2343
2344 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
2345 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
2346
2347 RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2348 int err = mtx_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
2349 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
2350 }
2351
2355 XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
2356
2357 XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
2358 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
2359
2360 RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
2361 int err = mtx_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
2362 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
2363 }
2364
2366 XPETRA_MONITOR("EpetraCrsMatrixT::removeEmptyProcessesInPlace");
2367 const Epetra_Map *newMapEpetra = (!newMap.is_null()) ? &toEpetra<GlobalOrdinal, Node>(newMap) : 0;
2368 int err = mtx_->RemoveEmptyProcessesInPlace(newMapEpetra);
2369 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Caught nonzero error code " + std::to_string(err) + " returned by Epetra.");
2370 }
2371
2373
2375
2376
2378 bool hasMatrix() const { return !mtx_.is_null(); }
2379
2382 : mtx_(mtx)
2383 , isFillResumed_(false) {}
2384
2387
2389 RCP<Epetra_CrsMatrix> getEpetra_CrsMatrixNonConst() const { return mtx_; } // TODO: remove
2390
2391#ifdef HAVE_XPETRA_TPETRA
2394 RCP<Epetra_CrsMatrix> matrix = getEpetra_CrsMatrixNonConst();
2395
2396 const int numRows = matrix->NumMyRows();
2397 const int numCols = matrix->NumMyCols();
2398 const int nnz = matrix->NumMyNonzeros();
2399
2400 int *rowptr;
2401 int *colind;
2402 double *vals;
2403 int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
2404 TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error, "Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
2405
2406 // Transform int* rowptr array to size_type* array
2407 typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
2408 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
2409 kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
2410
2411 // create Kokkos::Views
2412 typename local_matrix_type::index_type kokkosColind(colind, nnz);
2413 typename local_matrix_type::values_type kokkosVals(vals, nnz);
2414
2415 local_matrix_type localMatrix = local_matrix_type("LocalMatrix", numRows, numCols, nnz, kokkosVals, kokkosRowPtr, kokkosColind);
2416
2417 return localMatrix;
2418 }
2419
2420 void setAllValues(const typename local_matrix_type::row_map_type &ptr,
2421 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind,
2422 const typename local_matrix_type::values_type &val) {
2423 // Check sizes
2424 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(ptr.size()) != getLocalNumRows() + 1, Xpetra::Exceptions::RuntimeError,
2425 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
2427 "An exception is thrown to let you know that you mismatched your pointers.");
2428
2429 // Check pointers
2430 if (val.size() > 0) {
2431 TEUCHOS_TEST_FOR_EXCEPTION(ind.data() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
2432 "An exception is thrown to let you know that you mismatched your pointers.");
2433 TEUCHOS_TEST_FOR_EXCEPTION(val.data() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
2434 "An exception is thrown to let you know that you mismatched your pointers.");
2435 }
2436
2437 // We have to make a copy here, it is unavoidable
2438 // See comments in allocateAllValues
2439 const size_t N = getLocalNumRows();
2440
2441 Epetra_IntSerialDenseVector &myRowptr = mtx_->ExpertExtractIndexOffset();
2442 myRowptr.Resize(N + 1);
2443 for (size_t i = 0; i < N + 1; i++)
2444 myRowptr[i] = Teuchos::as<int>(ptr(i));
2445 }
2446
2447 LocalOrdinal GetStorageBlockSize() const { return 1; }
2448
2449 private:
2450#else
2451#ifdef __GNUC__
2452#warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
2453#endif
2454#endif
2455
2457
2465
2466 private:
2468
2469 bool isFillResumed_; //< For Epetra, fillResume() is a fictive operation but we need to keep track of it. This boolean is true only is resumeFill() have been called and fillComplete() have not been called afterward.
2470
2471}; // EpetraCrsMatrixT class
2472
2473#endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
2474
2475} // namespace Xpetra
2476
2477#define XPETRA_EPETRACRSMATRIX_SHORT
2478#endif // XPETRA_EPETRACRSMATRIX_HPP
#define XPETRA_MONITOR(funcName)
#define XPETRA_ERR_CHECK(arg)
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
int Resize(int Length_in)
size_type size() const
T * getRawPtr() const
ArrayView< T > view(size_type lowerOffset, size_type size) const
void resize(const size_type n, const T &val=T())
iterator begin() const
iterator end() const
size_type size() const
T * getRawPtr() const
static const EVerbosityLevel verbLevel_default
virtual void setObjectLabel(const std::string &objectLabel)
bool is_null() const
T * get() const
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...
KokkosSparse::CrsMatrix< impl_scalar_type, LocalOrdinal, execution_space, void, typename local_graph_type::size_type > local_matrix_device_type
LocalOrdinal local_ordinal_type
typename local_matrix_device_type::HostMirror local_matrix_host_type
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution 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.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
EpetraCrsMatrixT(const local_matrix_type &lclMatrix, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=null)
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism, which is usually 1, except for Tpetra::BlockCrsMatri...
const RCP< const Comm< int > > getComm() const
Returns the communicator.
void fillComplete(const RCP< ParameterList > &params=Teuchos::null)
Signal that data entry is complete.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_host_type local_matrix_host_type
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix.
bool isFillResumed_
Flag to keep track of fill status.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor for a fused import.
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.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_device_type local_matrix_device_type
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying a previously constructed graph.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
EpetraCrsMatrixT(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 > &=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val)
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
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.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=Teuchos::null)
Signal that data entry is complete, specifying domain and range maps.
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...
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Kokkos::View< const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
RCP< Epetra_CrsMatrix > mtx_
The underlying actual matrix object.
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 getAllValues(ArrayRCP< Scalar > &values)
Gets the 1D pointer arrays of the graph.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void setObjectLabel(const std::string &objectLabel)
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph.
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...
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
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.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified (locally owned) global row.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using local IDs.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
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....
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
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.
EpetraCrsMatrixT(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 > &=Teuchos::null)
Constructor specifying row and column Maps and number of entries in each row.
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
local_matrix_type getLocalMatrixDevice() const
Compatibility layer for accessing the matrix data through a Kokkos interface.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap)
Constructor for empty DynamicProfile matrix (no space is preallocated).
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
bool isFillActive() const
Returns true if the matrix is in edit mode.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &) const
Get offsets of the diagonal entries in the matrix.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
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.
std::string description() const
A simple one-line description of this object.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
void resumeFill(const RCP< ParameterList > &=Teuchos::null)
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Teuchos::ArrayView< const size_t > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor for a fused export.
local_matrix_type::HostMirror getLocalMatrixHost() const
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying fixed number of entries for each row.
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 > &=Teuchos::null)
Expert static fill complete.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > &regionInterfaceImporter, const Teuchos::ArrayRCP< LocalOrdinal > &regionInterfaceLIDs) const
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const local_matrix_type &lclMatrix, const Teuchos::RCP< Teuchos::ParameterList > &params=null)
Constructor specifying column Map and a local matrix, which the resulting CrsMatrix views.
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
bool hasMatrix() const
Does this have an underlying matrix.
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &) const
Get offsets of the diagonal entries in the matrix.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
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.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying fixed number of entries for each row.
bool hasMatrix() const
Does this have an underlying matrix.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_host_type local_matrix_host_type
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val)
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified (locally owned) global row.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using local IDs.
void getAllValues(ArrayRCP< Scalar > &values)
Gets the 1D pointer arrays of the graph.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Kokkos::View< const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
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.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > &regionInterfaceImporter, const Teuchos::ArrayRCP< LocalOrdinal > &regionInterfaceLIDs) const
void fillComplete(const RCP< ParameterList > &params=Teuchos::null)
Signal that data entry is complete.
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
EpetraCrsMatrixT(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 > &=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
EpetraCrsMatrixT(const local_matrix_type &lclMatrix, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=null)
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.
void resumeFill(const RCP< ParameterList > &=Teuchos::null)
local_matrix_type getLocalMatrix() const
Compatibility layer for accessing the matrix data through a Kokkos interface.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Teuchos::ArrayView< const size_t > &) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_device_type local_matrix_device_type
const RCP< const Comm< int > > getComm() const
Returns the communicator.
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 isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
bool isFillActive() const
Returns true if the matrix is in edit mode.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor for a fused export.
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.
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
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....
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...
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=Teuchos::null)
Signal that data entry is complete, specifying domain and range maps.
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism, which is usually 1, except for Tpetra::BlockCrsMatri...
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const local_matrix_type &lclMatrix, const Teuchos::RCP< Teuchos::ParameterList > &params=null)
Constructor specifying column Map and a local matrix, which the resulting CrsMatrix views.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
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.
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 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.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying a previously constructed graph.
std::string description() const
A simple one-line description of this object.
EpetraCrsMatrixT(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 > &=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
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 > &=Teuchos::null)
Expert static fill complete.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor for a fused import.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
size_t getLocalNumCols() const
Returns the number of matrix columns owned on the calling node.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the specified global row.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const local_matrix_type &lclMatrix, const Teuchos::RCP< Teuchos::ParameterList > &params=null)
void fillComplete(const RCP< ParameterList > &params=null)
Signal that data entry is complete.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
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....
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
void resumeFill(const RCP< ParameterList > &params=null)
void setObjectLabel(const std::string &objectLabel)
void scale(const Scalar &alpha)
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &RowExporter, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > DomainExporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=null)
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
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 getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
Kokkos::ArithTraits< Scalar > ATS
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
void setAllToScalar(const Scalar &alpha)
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
EpetraCrsMatrixT(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 > &params=Teuchos::null)
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism, which is usually 1, except for Tpetra::BlockCrsMatri...
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
local_matrix_type getLocalMatrixDevice() const
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
const RCP< const Comm< int > > getComm() const
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
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
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
void getAllValues(ArrayRCP< Scalar > &values)
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP< Import< LocalOrdinal, GlobalOrdinal, Node > > &regionInterfaceImporter, const Teuchos::ArrayRCP< LocalOrdinal > &regionInterfaceLIDs) const
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
The Map describing the parallel distribution of this object.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Kokkos::View< const size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &offsets) const
bool isFillActive() const
Returns true if the matrix is in edit mode.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_device_type local_matrix_device_type
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
void setAllValues(const typename local_matrix_type::row_map_type &ptr, const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type &ind, const typename local_matrix_type::values_type &val)
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
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 > &params=Teuchos::null)
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
typename Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_host_type local_matrix_host_type
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
EpetraCrsMatrixT(const local_matrix_type &lclMatrix, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=null)
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.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
local_matrix_type::HostMirror getLocalMatrixHost() const
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
typename ATS::val_type impl_scalar_type
bool hasMatrix() const
Does this have an underlying matrix.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
std::string description() const
A simple one-line description of this object.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
EpetraCrsMatrixT(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 > &params=Teuchos::null)
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
EpetraCrsMatrixT(const Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &sourceMatrix, const Import< LocalOrdinal, GlobalOrdinal, Node > &RowImporter, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > DomainImporter, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Exception throws when you call an unimplemented method of Xpetra.
Exception throws to report errors in the internal logical of the program.
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.
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
size_t global_size_t
Global size_t object.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
CombineMode
Xpetra::Combine Mode enumerable type.