Xpetra_EpetraCrsMatrix.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_EPETRACRSMATRIX_HPP
47 #define XPETRA_EPETRACRSMATRIX_HPP
48 
49 /* this file is automatically generated - do not edit (see script/epetra.py) */
50 
51 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
52 #include <Kokkos_View.hpp>
53 #endif
54 
56 
57 #include "Xpetra_CrsMatrix.hpp"
58 
59 #include <Epetra_CrsMatrix.h>
60 #include <Epetra_Map.h>
61 
62 #include "Xpetra_EpetraMap.hpp"
63 #include "Xpetra_EpetraVector.hpp"
66 
67 #include "Xpetra_MapFactory.hpp"
68 
69 #include "Xpetra_Utils.hpp"
70 #include "Xpetra_Exceptions.hpp"
71 
72 namespace Xpetra {
73 
74 // general implementation: empty stub
75 template<class EpetraGlobalOrdinal, class Node>
77  : public CrsMatrix<double, int, EpetraGlobalOrdinal, Node>
78 {
79  typedef EpetraGlobalOrdinal GlobalOrdinal;
82 
83 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
86 #endif
87 
88 public:
89  EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, 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  "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
96  }
97  EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, 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=Kokkos::Compat::KokkosSerialWrapperNode."); }
98  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, ProfileType pftype=DynamicProfile, 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=Kokkos::Compat::KokkosSerialWrapperNode."); }
99  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=Kokkos::Compat::KokkosSerialWrapperNode."); }
102  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
103  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
104  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
106  "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
107  }
110  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
111  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
112  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
114  "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
115  }
116 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
119  const local_matrix_type& lclMatrix,
120  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
122  "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
123  }
124 #endif
125  virtual ~EpetraCrsMatrixT() { }
126 
127  void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals) {}
128  void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals) { }
129  void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals) { }
130  void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals) { }
131  void setAllToScalar(const Scalar &alpha) { }
132  void scale(const Scalar &alpha) { }
133  void allocateAllValues(size_t numNonZeros,ArrayRCP<size_t> & rowptr, ArrayRCP<LocalOrdinal> & colind, ArrayRCP<Scalar> & values) { }
134  void setAllValues(const ArrayRCP<size_t> & rowptr, const ArrayRCP<LocalOrdinal> & colind, const ArrayRCP<Scalar> & values) { }
137  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
138  const RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > &importer=Teuchos::null,
139  const RCP<const Export<LocalOrdinal,GlobalOrdinal,Node> > &exporter=Teuchos::null,
140  const RCP<ParameterList> &params=Teuchos::null) { }
141 
142  void resumeFill(const RCP< ParameterList > &params=null) { }
143  void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=null) { }
144  void fillComplete(const RCP< ParameterList > &params=null) { }
146  const RCP< const Comm< int > > getComm() const { return Teuchos::null; }
147  const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> > getRowMap() const { return Teuchos::null; }
148  const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> > getColMap() const { return Teuchos::null; }
150  global_size_t getGlobalNumRows() const { return 0; }
151  global_size_t getGlobalNumCols() const { return 0; }
152  size_t getNodeNumRows() const { return 0; }
153  size_t getNodeNumCols() const { return 0; }
154  global_size_t getGlobalNumEntries() const { return 0; }
155  size_t getNodeNumEntries() const { return 0; }
156  size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const { return 0; }
157  global_size_t getGlobalNumDiags() const { return 0; }
158  size_t getNodeNumDiags() const { return 0; }
159  size_t getGlobalMaxNumRowEntries() const { return 0; }
160  size_t getNodeMaxNumRowEntries() const { return 0; }
161  bool isLocallyIndexed() const { return false; }
162  bool isGloballyIndexed() const { return false; }
163  bool isFillComplete() const { return false; }
164  bool isFillActive() const { return false; }
166  bool supportsRowViews() const { return false; }
167  void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const { }
168  void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const { }
169  void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const { }
170  void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const { }
174 
176  const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const { return Teuchos::null; }
177  const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const { return Teuchos::null; }
178 
179  std::string description() const { return std::string(""); }
181 
184  "Xpetra::EpetraCrsMatrix only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
185  }
186 
193 
194  bool hasMatrix() const { return false; }
196  RCP<const Epetra_CrsMatrix> getEpetra_CrsMatrix() const { return Teuchos::null; }
197  RCP<Epetra_CrsMatrix> getEpetra_CrsMatrixNonConst() const { return Teuchos::null; } //TODO: remove
198 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
199  local_matrix_type getLocalMatrix () const {
200  TEUCHOS_TEST_FOR_EXCEPTION(isFillComplete() == false, std::runtime_error,
201  "Xpetra::EpetraCrsMatrix::getLocalMatrix: matrix must be filled and completed before you can access the data through the Kokkos interface!");
202  return localMatrix_;
203  }
204 private:
205  mutable
206  local_matrix_type localMatrix_;
207 #endif
208 
209 }; // EpetraCrsMatrixT class (specialization on GO=long, empty stub implementation)
210 
211 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
212 template<>
214 : public CrsMatrix <double, int, int, EpetraNode>
215 {
216  typedef int GlobalOrdinal;
217  typedef EpetraNode Node;
220 
221 
222  // The following typedefs are used by the Kokkos interface
223 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
226 #endif
227 
228 public:
229 
231 
232 
234  EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist = Teuchos::null)
235 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), maxNumEntriesPerRow, toEpetra(pftype)))), isFillResumed_(false)
236 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
237 , isInitializedLocalMatrix_(false)
238 #endif
239 { }
240 
241 
244  : isFillResumed_(false)
245 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
246  , isInitializedLocalMatrix_(false)
247 #endif
248  {
249  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
250  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(pftype)));
251  }
252 
253 
256  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), maxNumEntriesPerRow, toEpetra(pftype)))), isFillResumed_(false)
257 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
258  , isInitializedLocalMatrix_(false)
259 #endif
260  { }
261 
262 
265  : isFillResumed_(false)
266 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
267  , isInitializedLocalMatrix_(false)
268 #endif
269  {
270  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
271  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(pftype)));
272  }
273 
274 
277  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(graph)))), isFillResumed_(false)
278 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
279  , isInitializedLocalMatrix_(false)
280 #endif
281  { }
282 
283 
287  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
288  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
289  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null):
290  isFillResumed_(false)
291 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
292  , isInitializedLocalMatrix_(false)
293 #endif
294  {
295  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
296  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
297 
298  const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
299  const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
300 
301  // Follows the Tpetra parameters
302  bool restrictComm=false;
303  if(!params.is_null()) restrictComm = params->get("Restrict Communicator",restrictComm);
304  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),myDomainMap,myRangeMap,restrictComm));
305  if(restrictComm && mtx_->NumMyRows()==0)
306  mtx_=Teuchos::null;
307  }
308 
309 
310 
314  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
315  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
316  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) :
317  isFillResumed_(false)
318 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
319  , isInitializedLocalMatrix_(false)
320 #endif
321  {
322  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
323  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
324 
325  const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
326  const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
327 
328  // Follows the Tpetra parameters
329  bool restrictComm=false;
330  if(!params.is_null()) restrictComm = params->get("Restrict Communicator",restrictComm);
331 
332  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),myDomainMap,myRangeMap,restrictComm));
333  }
334 
335 
336 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
359  const local_matrix_type& lclMatrix,
360  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
361  // local typedefs from local_matrix_type
362  typedef typename local_matrix_type::size_type size_type;
363  typedef typename local_matrix_type::value_type value_type;
364  typedef typename local_matrix_type::ordinal_type ordinal_type;
365 
366  // The number of rows in the sparse matrix.
367  ordinal_type lclNumRows = lclMatrix.numRows ();
368  ordinal_type lclNumCols = lclMatrix.numCols (); // do we need this?
369 
370  // plausibility checks
371  TEUCHOS_TEST_FOR_EXCEPTION(lclNumRows != Teuchos::as<ordinal_type>(rowMap->getNodeNumElements()), Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
372  TEUCHOS_TEST_FOR_EXCEPTION(lclNumCols != Teuchos::as<ordinal_type>(colMap->getNodeNumElements()), Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
373 
374  std::vector<GlobalOrdinal> domainMapGids; // vector for collecting domain map GIDs
375 
376  Teuchos::ArrayRCP< size_t > NumEntriesPerRowToAlloc(lclNumRows);
377  for (ordinal_type r = 0; r < lclNumRows; ++r) {
378  // extract data from current row r
379  Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
380  NumEntriesPerRowToAlloc[r] = rowview.length;
381  }
382 
383  // setup matrix
384  isFillResumed_ = false;
385  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
386  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(DynamicProfile)));
387 
388  // loop over all rows and colums of local matrix and fill matrix
389  for (ordinal_type r = 0; r < lclNumRows; ++r) {
390  // extract data from current row r
391  Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
392 
393  // arrays for current row data
396 
397  for(ordinal_type c = 0; c < rowview.length; c++) {
398  value_type value = rowview.value (c);
399  ordinal_type colidx = rowview.colidx (c);
400 
401  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!");
402 
403  indout [c] = colidx;
404  valout [c] = value;
405 
406  // collect GIDs for domain map
407  GlobalOrdinal gcid = colMap->getGlobalElement(c);
408  if(rowMap->isNodeGlobalElement(gcid)) domainMapGids.push_back(gcid);
409  }
410  insertLocalValues(r, indout.view(0,indout.size()), valout.view(0,valout.size()));
411  }
412 
413  // sort entries in domainMapGids and remove duplicates
414  const GlobalOrdinal INVALID = Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid();
415  std::sort(domainMapGids.begin(), domainMapGids.end());
416  domainMapGids.erase(std::unique(domainMapGids.begin(), domainMapGids.end()), domainMapGids.end());
417  Teuchos::ArrayView<GlobalOrdinal> domainMapGidsView(&domainMapGids[0], domainMapGids.size());
419  Xpetra::MapFactory<LocalOrdinal,GlobalOrdinal,Node>::Build(colMap->lib(), INVALID, domainMapGidsView, colMap->getIndexBase(), colMap->getComm());
420 
421  // call fill complete
422  this->fillComplete(domainMap, rowMap, params);
423 
424  // AP (2015/10/22): Could probably be optimized using provided lclMatrix, but lets not worry about that
425  isInitializedLocalMatrix_ = false;
426  }
427 
428 #endif
429 
431  virtual ~EpetraCrsMatrixT() { }
432 
434 
436 
437 
439  void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal> &cols, const ArrayView<const Scalar> &vals) {
440  XPETRA_MONITOR("EpetraCrsMatrixT::insertGlobalValues");
441  XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
442  }
443 
444 
446  void insertLocalValues(LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &cols, const ArrayView<const Scalar> &vals) {
447  XPETRA_MONITOR("EpetraCrsMatrixT::insertLocalValues");
448  XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
449  }
450 
452  void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values) {
453  XPETRA_MONITOR("EpetraCrsMatrixT::replaceGlobalValues");
454 
455  {
456  const std::string tfecfFuncName("replaceGlobalValues");
457  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(! isFillActive(), std::runtime_error,
458  ": Fill must be active in order to call this method. If you have already "
459  "called fillComplete(), you need to call resumeFill() before you can "
460  "replace values.");
461 
462  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
463  std::runtime_error, ": values.size() must equal indices.size().");
464  }
465 
466  XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
467 
468  }
469 
471  void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values) {
472  XPETRA_MONITOR("EpetraCrsMatrixT::replaceLocalValues");
473 
474  {
475  const std::string tfecfFuncName("replaceLocalValues");
476  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(! isFillActive(), std::runtime_error,
477  ": Fill must be active in order to call this method. If you have already "
478  "called fillComplete(), you need to call resumeFill() before you can "
479  "replace values.");
480 
481  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
482  std::runtime_error, ": values.size() must equal indices.size().");
483  }
484 
485  XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
486 
487  }
488 
489 
491  void setAllToScalar(const Scalar &alpha) { XPETRA_MONITOR("EpetraCrsMatrixT::setAllToScalar"); mtx_->PutScalar(alpha); }
492 
494  void scale(const Scalar &alpha) { XPETRA_MONITOR("EpetraCrsMatrixT::scale"); mtx_->Scale(alpha); }
495 
497  //** \warning This is an expert-only routine and should not be called from user code. */
498  void allocateAllValues(size_t numNonZeros, ArrayRCP<size_t>& rowptr, ArrayRCP<LocalOrdinal>& colind, ArrayRCP<Scalar>& values) {
499  XPETRA_MONITOR("EpetraCrsMatrixT::allocateAllValues");
500 
501  // Row offsets
502  // Unfortunately, we cannot do this in the same manner as column indices
503  // and values (see below). The problem is that Tpetra insists on using
504  // size_t, and Epetra uses int internally. So we only resize here, and
505  // will need to copy in setAllValues
506  rowptr.resize(getNodeNumRows()+1);
507 
508  int lowerOffset = 0;
509  bool ownMemory = false;
510 
511  // Column indices
512  // Extract, resize, set colind
513  Epetra_IntSerialDenseVector& myColind = mtx_->ExpertExtractIndices();
514  myColind.Resize(numNonZeros);
515  colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
516 
517  // Values
518  // Extract, reallocate, set values
519  double *& myValues = mtx_->ExpertExtractValues();
520  delete [] myValues;
521  myValues = new double[numNonZeros];
522  values = Teuchos::arcp(myValues,lowerOffset,numNonZeros,ownMemory);
523  }
524 
526  void setAllValues(const ArrayRCP<size_t>& rowptr, const ArrayRCP<LocalOrdinal>& colind, const ArrayRCP<Scalar>& values) {
527  XPETRA_MONITOR("EpetraCrsMatrixT::setAllValues");
528 
529  // Check sizes
531  "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
533  "An exception is thrown to let you know that you mismatched your pointers.");
534 
535  // Check pointers
536  if (values.size() > 0) {
537  TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
538  "An exception is thrown to let you know that you mismatched your pointers.");
539  TEUCHOS_TEST_FOR_EXCEPTION(values.getRawPtr() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
540  "An exception is thrown to let you know that you mismatched your pointers.");
541  }
542 
543  // We have to make a copy here, it is unavoidable
544  // See comments in allocateAllValues
545  const size_t N = getNodeNumRows();
546 
547  Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
548  myRowptr.Resize(N+1);
549  for (size_t i = 0; i < N+1; i++)
550  myRowptr[i] = Teuchos::as<int>(rowptr[i]);
551  }
552 
553 
556  XPETRA_MONITOR("EpetraCrsMatrixT::getAllValues");
557 
558  int lowerOffset = 0;
559  bool ownMemory = false;
560 
561  const size_t n = getNodeNumRows();
562  const size_t nnz = getNodeNumEntries();
563 
564  // Row offsets
565  // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
566  Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
567  rowptr.resize(n+1);
568  for (size_t i = 0; i < n+1; i++)
569  (*const_cast<size_t*>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
570 
571  // Column indices
572  colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
573 
574  // Values
575  values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
576  }
577 
579  //** \warning This is an expert-only routine and should not be called from user code. */
581  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
582  const RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > &importer=Teuchos::null,
583  const RCP<const Export<LocalOrdinal,GlobalOrdinal,Node> > &exporter=Teuchos::null,
584  const RCP<ParameterList> & params=Teuchos::null) {
585  XPETRA_MONITOR("EpetraCrsMatrixT::expertStaticFillComplete");
586  int rv=0;
587  const Epetra_Import * myimport =0;
588  const Epetra_Export * myexport =0;
589 
590  if(!importer.is_null()) {
591  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, *importer, eImporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
592  myimport = eImporter.getEpetra_Import().getRawPtr();
593  }
594  if(!exporter.is_null()) {
595  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, *exporter, eExporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
596  myexport = eExporter.getEpetra_Export().getRawPtr();
597  }
598 
599  rv=mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), myimport, myexport);
600 
601  TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
602  }
604 
606 
607 
609  void resumeFill(const RCP< ParameterList > &params=Teuchos::null) {
610  XPETRA_MONITOR("EpetraCrsMatrixT::resumeFill");
611 
612  // According to Tpetra documentation, resumeFill() may be called repeatedly.
613  isFillResumed_ = true;
614  }
615 
617  void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=Teuchos::null) {
618  XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
619 
620  // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
621  if (isFillResumed_ == true) { isFillResumed_ = false; return; }
622 
623  bool doOptimizeStorage = true;
624  if (params != null && params->get("Optimize Storage",true) == false) doOptimizeStorage = false;
625  mtx_->FillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), doOptimizeStorage);
626  }
627 
628 
630  void fillComplete(const RCP< ParameterList > &params=Teuchos::null) {
631  XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
632 
633  // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
634  if (isFillResumed_ == true) { isFillResumed_ = false; return; }
635 
636  bool doOptimizeStorage = true;
637  if (params != null && params->get("Optimize Storage",true) == false) doOptimizeStorage = false;
638  mtx_->FillComplete(doOptimizeStorage);
639  }
640 
641 
644  XPETRA_MONITOR("EpetraCrsMatrixT::replaceDomainMapAndImporter");
645  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, *newImporter, eImporter, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter only accepts Xpetra::EpetraImportT.");
646 
647  const RCP<const Epetra_Import> & myImport = eImporter.getEpetra_Import();
648  int rv=0;
649  if(myImport==Teuchos::null)
650  rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),0);
651  else
652  rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),&*myImport);
653  TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
654  }
655 
657 
659 
660 
662  const RCP< const Comm< int > > getComm() const { XPETRA_MONITOR("EpetraCrsMatrixT::getComm"); return toXpetra(mtx_->Comm()); }
663 
665  const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> > getRowMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getRowMap"); return toXpetra<GlobalOrdinal,Node>(mtx_->RowMap()); }
666 
668  const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> > getColMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getColMap"); return toXpetra<GlobalOrdinal,Node>(mtx_->ColMap()); }
669 
671  RCP< const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > getCrsGraph() const { XPETRA_MONITOR("EpetraCrsMatrixT::getCrsGraph"); return toXpetra<GlobalOrdinal,Node>(mtx_->Graph()); }
672 
674  global_size_t getGlobalNumRows() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumRows"); return mtx_->NumGlobalRows64(); }
675 
677  global_size_t getGlobalNumCols() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumCols"); return mtx_->NumGlobalCols64(); }
678 
680  size_t getNodeNumRows() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeNumRows"); return mtx_->NumMyRows(); }
681 
683  size_t getNodeNumCols() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeNumCols"); return mtx_->NumMyCols(); }
684 
686  global_size_t getGlobalNumEntries() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumEntries"); return mtx_->NumGlobalNonzeros64(); }
687 
689  size_t getNodeNumEntries() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeNumEntries"); return mtx_->NumMyNonzeros(); }
690 
692  size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const { XPETRA_MONITOR("EpetraCrsMatrixT::getNumEntriesInLocalRow"); return mtx_->NumMyEntries(localRow); }
693 
695  global_size_t getGlobalNumDiags() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumDiags"); return mtx_->NumGlobalDiagonals64(); }
696 
698  size_t getNodeNumDiags() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeNumDiags"); return mtx_->NumMyDiagonals(); }
699 
701  size_t getGlobalMaxNumRowEntries() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalMaxNumRowEntries"); return mtx_->GlobalMaxNumEntries(); }
702 
704  size_t getNodeMaxNumRowEntries() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeMaxNumRowEntries"); return mtx_->MaxNumEntries(); }
705 
707  bool isLocallyIndexed() const { XPETRA_MONITOR("EpetraCrsMatrixT::isLocallyIndexed"); return mtx_->IndicesAreLocal(); }
708 
710  bool isGloballyIndexed() const { XPETRA_MONITOR("EpetraCrsMatrixT::isGloballyIndexed"); return mtx_->IndicesAreGlobal(); }
711 
713  bool isFillComplete() const { XPETRA_MONITOR("EpetraCrsMatrixT::isFillComplete"); if (isFillResumed_) return false; else return mtx_->Filled(); }
714 
716  bool isFillActive() const { XPETRA_MONITOR("EpetraCrsMatrixT::isFillActive"); return !isFillComplete(); }
717 
719  typename ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const { XPETRA_MONITOR("EpetraCrsMatrixT::getFrobeniusNorm"); return mtx_->NormFrobenius(); }
720 
722  bool supportsRowViews() const { XPETRA_MONITOR("EpetraCrsMatrixT::supportsRowViews"); return true; }
723 
725  void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView<LocalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
726  XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowCopy");
727 
728  int numEntries = -1;
729  XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
730  NumEntries = numEntries;
731  }
732 
734  void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView<GlobalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
735  XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowCopy");
736 
737  int numEntries = -1;
738  XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
739  NumEntries = numEntries;
740  }
741 
743  void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &indices, ArrayView<const Scalar> &values) const {
744  XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowView");
745 
746  int numEntries;
747  double * eValues;
748  GlobalOrdinal * eIndices;
749 
750  XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
751  if (numEntries == 0) { eValues = NULL; eIndices = NULL; } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
752 
753  indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
754  values = ArrayView<const double>(eValues, numEntries);
755  }
756 
758  void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal> &indices, ArrayView<const Scalar> &values) const {
759  XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowView");
760 
761  int numEntries;
762  double * eValues;
763  int * eIndices;
764 
765  XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
766  if (numEntries == 0) { eValues = NULL; eIndices = NULL; } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
767 
768  indices = ArrayView<const int>(eIndices, numEntries);
769  values = ArrayView<const double>(eValues, numEntries);
770  }
771 
773  void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const { XPETRA_MONITOR("EpetraCrsMatrixT::getLocalDiagCopy"); mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal,Node>(diag)); }
774 
777  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagOffsets() is not implemented or supported.");
778  }
779 
782  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagCopy using offsets is not implemented or supported.");
783  }
784 
786 
788 
789 
792  XPETRA_MONITOR("EpetraCrsMatrixT::apply");
793 
794  //TEUCHOS_TEST_FOR_EXCEPTION((alpha != 1) || (beta != 0), Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.multiply() only accept alpha==1 and beta==0");
795 
796  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, X, eX, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
797  XPETRA_DYNAMIC_CAST( EpetraMultiVectorT<GlobalOrdinal COMMA Node>, Y, eY, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
798 
799  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");
800  bool eTrans = toEpetra(mode);
801 
802  // /!\ UseTranspose value
803  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.");
804 
805  RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
806 
807  // helper vector: tmp = A*x
808  RCP<Epetra_MultiVector> tmp = Teuchos::rcp(new Epetra_MultiVector(*epY));
809  tmp->PutScalar(0.0);
810  XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
811 
812  // calculate alpha * A * x + beta * y
813  XPETRA_ERR_CHECK(eY.getEpetra_MultiVector()->Update(alpha,*tmp,beta));
814  }
815 
817  const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getDomainMap"); return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap()); }
818 
820  const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getRangeMap"); return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap()); }
821 
823 
825 
826 
828  std::string description() const {
829  XPETRA_MONITOR("EpetraCrsMatrixT::description");
830 
831  // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
832  std::ostringstream oss;
833  //TODO: oss << DistObject<char, LocalOrdinal,GlobalOrdinal>::description();
834  if (isFillComplete()) {
835  oss << "{status = fill complete"
836  << ", global rows = " << getGlobalNumRows()
837  << ", global cols = " << getGlobalNumCols()
838  << ", global num entries = " << getGlobalNumEntries()
839  << "}";
840  }
841  else {
842  oss << "{status = fill not complete"
843  << ", global rows = " << getGlobalNumRows()
844  << "}";
845  }
846  return oss.str();
847 
848  }
849 
850 
853  XPETRA_MONITOR("EpetraCrsMatrixT::describe");
854 
855  // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
856  using std::endl;
857  using std::setw;
858  using Teuchos::VERB_DEFAULT;
859  using Teuchos::VERB_NONE;
860  using Teuchos::VERB_LOW;
861  using Teuchos::VERB_MEDIUM;
862  using Teuchos::VERB_HIGH;
863  using Teuchos::VERB_EXTREME;
864  Teuchos::EVerbosityLevel vl = verbLevel;
865  if (vl == VERB_DEFAULT) vl = VERB_LOW;
866  RCP<const Comm<int> > comm = this->getComm();
867  const int myImageID = comm->getRank(),
868  numImages = comm->getSize();
869  size_t width = 1;
870  for (size_t dec=10; dec<getGlobalNumRows(); dec *= 10) {
871  ++width;
872  }
873  width = std::max<size_t>(width,11) + 2;
874  Teuchos::OSTab tab(out);
875  // none: print nothing
876  // low: print O(1) info from node 0
877  // medium: print O(P) info, num entries per node
878  // high: print O(N) info, num entries per row
879  // extreme: print O(NNZ) info: print indices and values
880  //
881  // for medium and higher, print constituent objects at specified verbLevel
882  if (vl != VERB_NONE) {
883  if (myImageID == 0) out << this->description() << std::endl;
884  // O(1) globals, minus what was already printed by description()
885  if (isFillComplete() && myImageID == 0) {
886  out << "Global number of diagonals = " << getGlobalNumDiags() << std::endl;
887  out << "Global max number of entries = " << getGlobalMaxNumRowEntries() << std::endl;
888  }
889  // constituent objects
890  if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
891  if (myImageID == 0) out << "\nRow map: " << std::endl;
892  getRowMap()->describe(out,vl);
893  //
894  if (getColMap() != null) {
895  if (getColMap() == getRowMap()) {
896  if (myImageID == 0) out << "\nColumn map is row map.";
897  }
898  else {
899  if (myImageID == 0) out << "\nColumn map: " << std::endl;
900  getColMap()->describe(out,vl);
901  }
902  }
903  if (getDomainMap() != null) {
904  if (getDomainMap() == getRowMap()) {
905  if (myImageID == 0) out << "\nDomain map is row map.";
906  }
907  else if (getDomainMap() == getColMap()) {
908  if (myImageID == 0) out << "\nDomain map is row map.";
909  }
910  else {
911  if (myImageID == 0) out << "\nDomain map: " << std::endl;
912  getDomainMap()->describe(out,vl);
913  }
914  }
915  if (getRangeMap() != null) {
916  if (getRangeMap() == getDomainMap()) {
917  if (myImageID == 0) out << "\nRange map is domain map." << std::endl;
918  }
919  else if (getRangeMap() == getRowMap()) {
920  if (myImageID == 0) out << "\nRange map is row map." << std::endl;
921  }
922  else {
923  if (myImageID == 0) out << "\nRange map: " << std::endl;
924  getRangeMap()->describe(out,vl);
925  }
926  }
927  if (myImageID == 0) out << std::endl;
928  }
929  // O(P) data
930  if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
931  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
932  if (myImageID == imageCtr) {
933  out << "Node ID = " << imageCtr << std::endl;
934  // TODO: need a graph
935  // if (staticGraph_->indicesAreAllocated() == false) {
936  // out << "Node not allocated" << std::endl;
937  // }
938  // else {
939  // out << "Node number of allocated entries = " << staticGraph_->getNodeAllocationSize() << std::endl;
940  // }
941 
942  // TMP:
943  // const Epetra_CrsGraph & staticGraph_ = mtx_->Graph();
944  // End of TMP
945 
946  out << "Node number of entries = " << getNodeNumEntries() << std::endl;
947  if (isFillComplete()) {
948  out << "Node number of diagonals = " << getNodeNumDiags() << std::endl;
949  }
950  out << "Node max number of entries = " << getNodeMaxNumRowEntries() << std::endl;
951  }
952  comm->barrier();
953  comm->barrier();
954  comm->barrier();
955  }
956  }
957  // O(N) and O(NNZ) data
958  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
959  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
960  if (myImageID == imageCtr) {
961  out << std::setw(width) << "Node ID"
962  << std::setw(width) << "Global Row"
963  << std::setw(width) << "Num Entries";
964  if (vl == VERB_EXTREME) {
965  out << std::setw(width) << "(Index,Value)";
966  }
967  out << std::endl;
968  for (size_t r=0; r < getNodeNumRows(); ++r) {
969  const size_t nE = getNumEntriesInLocalRow(r);
970  GlobalOrdinal gid = getRowMap()->getGlobalElement(r);
971  out << std::setw(width) << myImageID
972  << std::setw(width) << gid
973  << std::setw(width) << nE;
974  if (vl == VERB_EXTREME) {
975  if (isGloballyIndexed()) {
977  ArrayView<const Scalar> rowvals;
978  getGlobalRowView(gid,rowinds,rowvals);
979  for (size_t j=0; j < nE; ++j) {
980  out << " (" << rowinds[j]
981  << ", " << rowvals[j]
982  << ") ";
983  }
984  }
985  else if (isLocallyIndexed()) {
987  ArrayView<const Scalar> rowvals;
988  getLocalRowView(r,rowinds,rowvals);
989  for (size_t j=0; j < nE; ++j) {
990  out << " (" << getColMap()->getGlobalElement(rowinds[j])
991  << ", " << rowvals[j]
992  << ") ";
993  }
994  }
995  }
996  out << std::endl;
997  }
998  }
999  comm->barrier();
1000  comm->barrier();
1001  comm->barrier();
1002  }
1003  }
1004  }
1005 
1006  }
1007 
1008 
1010 
1013  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_)))), isFillResumed_(false)
1014 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1015  , isInitializedLocalMatrix_(false)
1016 #endif
1017  { }
1018 
1019 
1021  //{@
1022 
1024  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getMap"); return toXpetra<GlobalOrdinal,Node>(mtx_->Map()); }
1025 
1029  XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
1030 
1031  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1032  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1033 
1034  RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1035  int err = mtx_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1036  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1037  }
1038 
1042  XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
1043 
1044  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1045  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1046 
1047  RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1048  int err = mtx_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1049  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1050  }
1051 
1055  XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
1056 
1057  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1058  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1059 
1060  RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1061  int err = mtx_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1062  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1063 
1064  }
1065 
1069  XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
1070 
1071  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1072  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1073 
1074  RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1075  int err = mtx_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1076  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1077  }
1078 
1080 
1082 
1084 
1085 
1087  bool hasMatrix() const { return !mtx_.is_null();}
1088 
1090  EpetraCrsMatrixT(const Teuchos::RCP<Epetra_CrsMatrix > &mtx) : mtx_(mtx), isFillResumed_(false) { }
1091 
1094 
1096  RCP<Epetra_CrsMatrix> getEpetra_CrsMatrixNonConst() const { return mtx_; } //TODO: remove
1097 
1098 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1099  local_matrix_type getLocalMatrix () const {
1101  TEUCHOS_TEST_FOR_EXCEPTION(isFillComplete() == false, std::runtime_error,
1102  "Xpetra::EpetraCrsMatrix::getLocalMatrix: matrix must be filled and completed before you can access the data through the Kokkos interface!");
1103  if (isInitializedLocalMatrix_)
1104  return localMatrix_;
1105 
1107 
1108  const int numRows = matrix->NumMyRows();
1109  const int numCols = matrix->NumMyCols();
1110  const int nnz = matrix->NumMyNonzeros();
1111 
1112  int* rowptr;
1113  int* colind;
1114  double* vals;
1115  int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
1116  TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error, "Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
1117 
1118  // Transform int* rowptr array to size_type* array
1119  typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr("local row map", numRows+1);
1120  for (size_t i = 0; i < kokkosRowPtr.size(); i++)
1121  kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
1122 
1123  // create Kokkos::Views
1124  typename local_matrix_type::index_type kokkosColind(colind, nnz);
1125  typename local_matrix_type::values_type kokkosVals (vals, nnz);
1126 
1127  localMatrix_ = local_matrix_type("LocalMatrix", numRows, numCols, nnz, kokkosVals, kokkosRowPtr, kokkosColind);
1128  isInitializedLocalMatrix_ = true;
1129 
1130  return localMatrix_;
1131  }
1132 #endif
1133 
1134 
1135 private:
1137 
1138  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.
1139 
1140 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1141  mutable
1142  local_matrix_type localMatrix_;
1143  mutable
1144  bool isInitializedLocalMatrix_;
1145 #endif
1146 
1147 }; // EpetraCrsMatrixT class
1148 
1149 #endif //#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
1150 
1151 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
1152 template<>
1153 class EpetraCrsMatrixT <long long, EpetraNode>
1154 : public CrsMatrix <double, int, long long, EpetraNode>
1155 {
1156  typedef long long GlobalOrdinal;
1157  typedef EpetraNode Node;
1160 
1161 
1162  // The following typedefs are used by the Kokkos interface
1163 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1166 #endif
1167 
1168 public:
1169 
1171 
1172 
1174  EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist = Teuchos::null)
1175 : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), maxNumEntriesPerRow, toEpetra(pftype)))), isFillResumed_(false)
1176 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1177 , isInitializedLocalMatrix_(false)
1178 #endif
1179 { }
1180 
1181 
1184  : isFillResumed_(false)
1185 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1186  , isInitializedLocalMatrix_(false)
1187 #endif
1188  {
1189  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
1190  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(pftype)));
1191  }
1192 
1193 
1196  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), maxNumEntriesPerRow, toEpetra(pftype)))), isFillResumed_(false)
1197 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1198  , isInitializedLocalMatrix_(false)
1199 #endif
1200  { }
1201 
1202 
1205  : isFillResumed_(false)
1206 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1207  , isInitializedLocalMatrix_(false)
1208 #endif
1209  {
1210  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
1211  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(pftype)));
1212  }
1213 
1214 
1217  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(graph)))), isFillResumed_(false)
1218 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1219  , isInitializedLocalMatrix_(false)
1220 #endif
1221  { }
1222 
1223 
1227  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
1228  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
1229  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null):
1230  isFillResumed_(false)
1231 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1232  , isInitializedLocalMatrix_(false)
1233 #endif
1234  {
1235  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
1236  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraImportT as an input argument.");
1237 
1238  const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
1239  const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
1240 
1241  // Follows the Tpetra parameters
1242  bool restrictComm=false;
1243  if(!params.is_null()) restrictComm = params->get("Restrict Communicator",restrictComm);
1244  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tImporter.getEpetra_Import(),myDomainMap,myRangeMap,restrictComm));
1245  if(restrictComm && mtx_->NumMyRows()==0)
1246  mtx_=Teuchos::null;
1247  }
1248 
1249 
1250 
1254  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & domainMap = Teuchos::null,
1255  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap = Teuchos::null,
1256  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) :
1257  isFillResumed_(false)
1258 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1259  , isInitializedLocalMatrix_(false)
1260 #endif
1261  {
1262  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, *sourceMatrix, tSourceMatrix, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraCrsMatrixT as an input argument.");
1263  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT constructor only accepts Xpetra::EpetraExportT as an input argument.");
1264 
1265  const Epetra_Map* myDomainMap = (domainMap!=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(domainMap): 0;
1266  const Epetra_Map* myRangeMap = (rangeMap !=Teuchos::null)? &toEpetra<GlobalOrdinal,Node>(rangeMap) : 0;
1267 
1268  // Follows the Tpetra parameters
1269  bool restrictComm=false;
1270  if(!params.is_null()) restrictComm = params->get("Restrict Communicator",restrictComm);
1271 
1272  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(*tSourceMatrix.getEpetra_CrsMatrix(),*tExporter.getEpetra_Export(),myDomainMap,myRangeMap,restrictComm));
1273  }
1274 
1275 
1276 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1298  const Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> >& colMap,
1299  const local_matrix_type& lclMatrix,
1300  const Teuchos::RCP<Teuchos::ParameterList>& params = null) {
1301  // local typedefs from local_matrix_type
1302  typedef typename local_matrix_type::size_type size_type;
1303  typedef typename local_matrix_type::value_type value_type;
1304  typedef typename local_matrix_type::ordinal_type ordinal_type;
1305 
1306  // The number of rows in the sparse matrix.
1307  ordinal_type lclNumRows = lclMatrix.numRows ();
1308  ordinal_type lclNumCols = lclMatrix.numCols (); // do we need this?
1309 
1310  // plausibility checks
1311  TEUCHOS_TEST_FOR_EXCEPTION(lclNumRows != Teuchos::as<ordinal_type>(rowMap->getNodeNumElements()), Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrixT: number of rows in local matrix and number of local entries in row map do not match!");
1312  TEUCHOS_TEST_FOR_EXCEPTION(lclNumCols != Teuchos::as<ordinal_type>(colMap->getNodeNumElements()), Xpetra::Exceptions::RuntimeError, "Xpetra::EpetraCrsMatrixT: number of columns in local matrix and number of local entries in column map do not match!");
1313 
1314  std::vector<GlobalOrdinal> domainMapGids; // vector for collecting domain map GIDs
1315 
1316  Teuchos::ArrayRCP< size_t > NumEntriesPerRowToAlloc(lclNumRows);
1317  for (ordinal_type r = 0; r < lclNumRows; ++r) {
1318  // extract data from current row r
1319  Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
1320  NumEntriesPerRowToAlloc[r] = rowview.length;
1321  }
1322 
1323  // setup matrix
1324  isFillResumed_ = false;
1325  Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
1326  mtx_ = Teuchos::rcp(new Epetra_CrsMatrix(Copy, toEpetra<GlobalOrdinal,Node>(rowMap), toEpetra<GlobalOrdinal,Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), toEpetra(DynamicProfile)));
1327 
1328  // loop over all rows and colums of local matrix and fill matrix
1329  for (ordinal_type r = 0; r < lclNumRows; ++r) {
1330  // extract data from current row r
1331  Kokkos::SparseRowView<local_matrix_type,size_type> rowview = lclMatrix.template row<size_type>(r);
1332 
1333  // arrays for current row data
1336 
1337  for(ordinal_type c = 0; c < rowview.length; c++) {
1338  value_type value = rowview.value (c);
1339  ordinal_type colidx = rowview.colidx (c);
1340 
1341  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!");
1342 
1343  indout [c] = colidx;
1344  valout [c] = value;
1345 
1346  // collect GIDs for domain map
1347  GlobalOrdinal gcid = colMap->getGlobalElement(c);
1348  if(rowMap->isNodeGlobalElement(gcid)) domainMapGids.push_back(gcid);
1349  }
1350  insertLocalValues(r, indout.view(0,indout.size()), valout.view(0,valout.size()));
1351  }
1352 
1353  // sort entries in domainMapGids and remove duplicates
1354  const GlobalOrdinal INVALID = Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid();
1355  std::sort(domainMapGids.begin(), domainMapGids.end());
1356  domainMapGids.erase(std::unique(domainMapGids.begin(), domainMapGids.end()), domainMapGids.end());
1357  Teuchos::ArrayView<GlobalOrdinal> domainMapGidsView(&domainMapGids[0], domainMapGids.size());
1359  Xpetra::MapFactory<LocalOrdinal,GlobalOrdinal,Node>::Build(colMap->lib(), INVALID, domainMapGidsView, colMap->getIndexBase(), colMap->getComm());
1360 
1361  // call fill complete
1362  this->fillComplete(domainMap, rowMap, params);
1363 
1364  // AP (2015/10/22): Could probably be optimized using provided lclMatrix, but lets not worry about that
1365  isInitializedLocalMatrix_ = false;
1366  }
1367 
1368 #endif
1369 
1371  virtual ~EpetraCrsMatrixT() { }
1372 
1374 
1376 
1377 
1379  void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal> &cols, const ArrayView<const Scalar> &vals) {
1380  XPETRA_MONITOR("EpetraCrsMatrixT::insertGlobalValues");
1381  XPETRA_ERR_CHECK(mtx_->InsertGlobalValues(globalRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1382  }
1383 
1384 
1386  void insertLocalValues(LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &cols, const ArrayView<const Scalar> &vals) {
1387  XPETRA_MONITOR("EpetraCrsMatrixT::insertLocalValues");
1388  XPETRA_ERR_CHECK(mtx_->InsertMyValues(localRow, vals.size(), vals.getRawPtr(), cols.getRawPtr()));
1389  }
1390 
1392  void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values) {
1393  XPETRA_MONITOR("EpetraCrsMatrixT::replaceGlobalValues");
1394 
1395  {
1396  const std::string tfecfFuncName("replaceGlobalValues");
1397  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(! isFillActive(), std::runtime_error,
1398  ": Fill must be active in order to call this method. If you have already "
1399  "called fillComplete(), you need to call resumeFill() before you can "
1400  "replace values.");
1401 
1402  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1403  std::runtime_error, ": values.size() must equal indices.size().");
1404  }
1405 
1406  XPETRA_ERR_CHECK(mtx_->ReplaceGlobalValues(globalRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1407 
1408  }
1409 
1411  void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values) {
1412  XPETRA_MONITOR("EpetraCrsMatrixT::replaceLocalValues");
1413 
1414  {
1415  const std::string tfecfFuncName("replaceLocalValues");
1416  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(! isFillActive(), std::runtime_error,
1417  ": Fill must be active in order to call this method. If you have already "
1418  "called fillComplete(), you need to call resumeFill() before you can "
1419  "replace values.");
1420 
1421  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(values.size() != indices.size(),
1422  std::runtime_error, ": values.size() must equal indices.size().");
1423  }
1424 
1425  XPETRA_ERR_CHECK(mtx_->ReplaceMyValues(localRow, indices.size(), values.getRawPtr(), indices.getRawPtr()));
1426 
1427  }
1428 
1429 
1431  void setAllToScalar(const Scalar &alpha) { XPETRA_MONITOR("EpetraCrsMatrixT::setAllToScalar"); mtx_->PutScalar(alpha); }
1432 
1434  void scale(const Scalar &alpha) { XPETRA_MONITOR("EpetraCrsMatrixT::scale"); mtx_->Scale(alpha); }
1435 
1437  //** \warning This is an expert-only routine and should not be called from user code. */
1438  void allocateAllValues(size_t numNonZeros, ArrayRCP<size_t>& rowptr, ArrayRCP<LocalOrdinal>& colind, ArrayRCP<Scalar>& values) {
1439  XPETRA_MONITOR("EpetraCrsMatrixT::allocateAllValues");
1440 
1441  // Row offsets
1442  // Unfortunately, we cannot do this in the same manner as column indices
1443  // and values (see below). The problem is that Tpetra insists on using
1444  // size_t, and Epetra uses int internally. So we only resize here, and
1445  // will need to copy in setAllValues
1446  rowptr.resize(getNodeNumRows()+1);
1447 
1448  int lowerOffset = 0;
1449  bool ownMemory = false;
1450 
1451  // Column indices
1452  // Extract, resize, set colind
1453  Epetra_IntSerialDenseVector& myColind = mtx_->ExpertExtractIndices();
1454  myColind.Resize(numNonZeros);
1455  colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1456 
1457  // Values
1458  // Extract, reallocate, set values
1459  double *& myValues = mtx_->ExpertExtractValues();
1460  delete [] myValues;
1461  myValues = new double[numNonZeros];
1462  values = Teuchos::arcp(myValues,lowerOffset,numNonZeros,ownMemory);
1463  }
1464 
1466  void setAllValues(const ArrayRCP<size_t>& rowptr, const ArrayRCP<LocalOrdinal>& colind, const ArrayRCP<Scalar>& values) {
1467  XPETRA_MONITOR("EpetraCrsMatrixT::setAllValues");
1468 
1469  // Check sizes
1471  "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1473  "An exception is thrown to let you know that you mismatched your pointers.");
1474 
1475  // Check pointers
1476  if (values.size() > 0) {
1477  TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
1478  "An exception is thrown to let you know that you mismatched your pointers.");
1479  TEUCHOS_TEST_FOR_EXCEPTION(values.getRawPtr() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
1480  "An exception is thrown to let you know that you mismatched your pointers.");
1481  }
1482 
1483  // We have to make a copy here, it is unavoidable
1484  // See comments in allocateAllValues
1485  const size_t N = getNodeNumRows();
1486 
1487  Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
1488  myRowptr.Resize(N+1);
1489  for (size_t i = 0; i < N+1; i++)
1490  myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1491  }
1492 
1493 
1496  XPETRA_MONITOR("EpetraCrsMatrixT::getAllValues");
1497 
1498  int lowerOffset = 0;
1499  bool ownMemory = false;
1500 
1501  const size_t n = getNodeNumRows();
1502  const size_t nnz = getNodeNumEntries();
1503 
1504  // Row offsets
1505  // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
1506  Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
1507  rowptr.resize(n+1);
1508  for (size_t i = 0; i < n+1; i++)
1509  (*const_cast<size_t*>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1510 
1511  // Column indices
1512  colind = Teuchos::arcp(mtx_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1513 
1514  // Values
1515  values = Teuchos::arcp(mtx_->ExpertExtractValues(), lowerOffset, nnz, ownMemory);
1516  }
1517 
1519  //** \warning This is an expert-only routine and should not be called from user code. */
1521  const RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > & rangeMap,
1522  const RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > &importer=Teuchos::null,
1523  const RCP<const Export<LocalOrdinal,GlobalOrdinal,Node> > &exporter=Teuchos::null,
1524  const RCP<ParameterList> & params=Teuchos::null) {
1525  XPETRA_MONITOR("EpetraCrsMatrixT::expertStaticFillComplete");
1526  int rv=0;
1527  const Epetra_Import * myimport =0;
1528  const Epetra_Export * myexport =0;
1529 
1530  if(!importer.is_null()) {
1531  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, *importer, eImporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
1532  myimport = eImporter.getEpetra_Import().getRawPtr();
1533  }
1534  if(!exporter.is_null()) {
1535  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, *exporter, eExporter, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete only accepts Xpetra::EpetraImportT.");
1536  myexport = eExporter.getEpetra_Export().getRawPtr();
1537  }
1538 
1539  rv=mtx_->ExpertStaticFillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), myimport, myexport);
1540 
1541  TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::expertStaticFillComplete FAILED!");
1542  }
1544 
1546 
1547 
1549  void resumeFill(const RCP< ParameterList > &params=Teuchos::null) {
1550  XPETRA_MONITOR("EpetraCrsMatrixT::resumeFill");
1551 
1552  // According to Tpetra documentation, resumeFill() may be called repeatedly.
1553  isFillResumed_ = true;
1554  }
1555 
1557  void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=Teuchos::null) {
1558  XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
1559 
1560  // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
1561  if (isFillResumed_ == true) { isFillResumed_ = false; return; }
1562 
1563  bool doOptimizeStorage = true;
1564  if (params != null && params->get("Optimize Storage",true) == false) doOptimizeStorage = false;
1565  mtx_->FillComplete(toEpetra<GlobalOrdinal,Node>(domainMap), toEpetra<GlobalOrdinal,Node>(rangeMap), doOptimizeStorage);
1566  }
1567 
1568 
1570  void fillComplete(const RCP< ParameterList > &params=Teuchos::null) {
1571  XPETRA_MONITOR("EpetraCrsMatrixT::fillComplete");
1572 
1573  // For Epetra matrices, resumeFill() is a fictive operation. There is no need for a fillComplete after some resumeFill() operations.
1574  if (isFillResumed_ == true) { isFillResumed_ = false; return; }
1575 
1576  bool doOptimizeStorage = true;
1577  if (params != null && params->get("Optimize Storage",true) == false) doOptimizeStorage = false;
1578  mtx_->FillComplete(doOptimizeStorage);
1579  }
1580 
1581 
1584  XPETRA_MONITOR("EpetraCrsMatrixT::replaceDomainMapAndImporter");
1585  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, *newImporter, eImporter, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter only accepts Xpetra::EpetraImportT.");
1586 
1587  const RCP<const Epetra_Import> & myImport = eImporter.getEpetra_Import();
1588  int rv=0;
1589  if(myImport==Teuchos::null)
1590  rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),0);
1591  else
1592  rv=mtx_->ReplaceDomainMapAndImporter( toEpetra<GlobalOrdinal,Node>(newDomainMap),&*myImport);
1593  TEUCHOS_TEST_FOR_EXCEPTION(rv != 0, std::runtime_error, "Xpetra::EpetraCrsMatrixT::replaceDomainMapAndImporter FAILED!");
1594  }
1595 
1597 
1599 
1600 
1602  const RCP< const Comm< int > > getComm() const { XPETRA_MONITOR("EpetraCrsMatrixT::getComm"); return toXpetra(mtx_->Comm()); }
1603 
1605  const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> > getRowMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getRowMap"); return toXpetra<GlobalOrdinal,Node>(mtx_->RowMap()); }
1606 
1608  const RCP< const Map<LocalOrdinal, GlobalOrdinal, Node> > getColMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getColMap"); return toXpetra<GlobalOrdinal,Node>(mtx_->ColMap()); }
1609 
1611  RCP< const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > getCrsGraph() const { XPETRA_MONITOR("EpetraCrsMatrixT::getCrsGraph"); return toXpetra<GlobalOrdinal,Node>(mtx_->Graph()); }
1612 
1614  global_size_t getGlobalNumRows() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumRows"); return mtx_->NumGlobalRows64(); }
1615 
1617  global_size_t getGlobalNumCols() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumCols"); return mtx_->NumGlobalCols64(); }
1618 
1620  size_t getNodeNumRows() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeNumRows"); return mtx_->NumMyRows(); }
1621 
1623  size_t getNodeNumCols() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeNumCols"); return mtx_->NumMyCols(); }
1624 
1626  global_size_t getGlobalNumEntries() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumEntries"); return mtx_->NumGlobalNonzeros64(); }
1627 
1629  size_t getNodeNumEntries() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeNumEntries"); return mtx_->NumMyNonzeros(); }
1630 
1632  size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const { XPETRA_MONITOR("EpetraCrsMatrixT::getNumEntriesInLocalRow"); return mtx_->NumMyEntries(localRow); }
1633 
1635  global_size_t getGlobalNumDiags() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalNumDiags"); return mtx_->NumGlobalDiagonals64(); }
1636 
1638  size_t getNodeNumDiags() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeNumDiags"); return mtx_->NumMyDiagonals(); }
1639 
1641  size_t getGlobalMaxNumRowEntries() const { XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalMaxNumRowEntries"); return mtx_->GlobalMaxNumEntries(); }
1642 
1644  size_t getNodeMaxNumRowEntries() const { XPETRA_MONITOR("EpetraCrsMatrixT::getNodeMaxNumRowEntries"); return mtx_->MaxNumEntries(); }
1645 
1647  bool isLocallyIndexed() const { XPETRA_MONITOR("EpetraCrsMatrixT::isLocallyIndexed"); return mtx_->IndicesAreLocal(); }
1648 
1650  bool isGloballyIndexed() const { XPETRA_MONITOR("EpetraCrsMatrixT::isGloballyIndexed"); return mtx_->IndicesAreGlobal(); }
1651 
1653  bool isFillComplete() const { XPETRA_MONITOR("EpetraCrsMatrixT::isFillComplete"); if (isFillResumed_) return false; else return mtx_->Filled(); }
1654 
1656  bool isFillActive() const { XPETRA_MONITOR("EpetraCrsMatrixT::isFillActive"); return !isFillComplete(); }
1657 
1659  typename ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const { XPETRA_MONITOR("EpetraCrsMatrixT::getFrobeniusNorm"); return mtx_->NormFrobenius(); }
1660 
1662  bool supportsRowViews() const { XPETRA_MONITOR("EpetraCrsMatrixT::supportsRowViews"); return true; }
1663 
1665  void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView<LocalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
1666  XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowCopy");
1667 
1668  int numEntries = -1;
1669  XPETRA_ERR_CHECK(mtx_->ExtractMyRowCopy(LocalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1670  NumEntries = numEntries;
1671  }
1672 
1674  void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView<GlobalOrdinal> &Indices, const ArrayView<Scalar> &Values, size_t &NumEntries) const {
1675  XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowCopy");
1676 
1677  int numEntries = -1;
1678  XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowCopy(GlobalRow, Indices.size(), numEntries, Values.getRawPtr(), Indices.getRawPtr()));
1679  NumEntries = numEntries;
1680  }
1681 
1683  void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &indices, ArrayView<const Scalar> &values) const {
1684  XPETRA_MONITOR("EpetraCrsMatrixT::getGlobalRowView");
1685 
1686  int numEntries;
1687  double * eValues;
1688  GlobalOrdinal * eIndices;
1689 
1690  XPETRA_ERR_CHECK(mtx_->ExtractGlobalRowView(GlobalRow, numEntries, eValues, eIndices));
1691  if (numEntries == 0) { eValues = NULL; eIndices = NULL; } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
1692 
1693  indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
1694  values = ArrayView<const double>(eValues, numEntries);
1695  }
1696 
1698  void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal> &indices, ArrayView<const Scalar> &values) const {
1699  XPETRA_MONITOR("EpetraCrsMatrixT::getLocalRowView");
1700 
1701  int numEntries;
1702  double * eValues;
1703  int * eIndices;
1704 
1705  XPETRA_ERR_CHECK(mtx_->ExtractMyRowView(LocalRow, numEntries, eValues, eIndices));
1706  if (numEntries == 0) { eValues = NULL; eIndices = NULL; } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
1707 
1708  indices = ArrayView<const int>(eIndices, numEntries);
1709  values = ArrayView<const double>(eValues, numEntries);
1710  }
1711 
1713  void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const { XPETRA_MONITOR("EpetraCrsMatrixT::getLocalDiagCopy"); mtx_->ExtractDiagonalCopy(toEpetra<GlobalOrdinal,Node>(diag)); }
1714 
1717  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagOffsets() is not implemented or supported.");
1718  }
1719 
1722  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.getLocalDiagCopy using offsets is not implemented or supported.");
1723  }
1724 
1726 
1728 
1729 
1732  XPETRA_MONITOR("EpetraCrsMatrixT::apply");
1733 
1734  //TEUCHOS_TEST_FOR_EXCEPTION((alpha != 1) || (beta != 0), Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraCrsMatrixT.multiply() only accept alpha==1 and beta==0");
1735 
1736  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, X, eX, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
1737  XPETRA_DYNAMIC_CAST( EpetraMultiVectorT<GlobalOrdinal COMMA Node>, Y, eY, "Xpetra::EpetraCrsMatrixT->apply() only accept Xpetra::EpetraMultiVectorT as input arguments.");
1738 
1739  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");
1740  bool eTrans = toEpetra(mode);
1741 
1742  // /!\ UseTranspose value
1743  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.");
1744 
1745  RCP<Epetra_MultiVector> epY = eY.getEpetra_MultiVector();
1746 
1747  // helper vector: tmp = A*x
1748  RCP<Epetra_MultiVector> tmp = Teuchos::rcp(new Epetra_MultiVector(*epY));
1749  tmp->PutScalar(0.0);
1750  XPETRA_ERR_CHECK(mtx_->Multiply(eTrans, *eX.getEpetra_MultiVector(), *tmp));
1751 
1752  // calculate alpha * A * x + beta * y
1753  XPETRA_ERR_CHECK(eY.getEpetra_MultiVector()->Update(alpha,*tmp,beta));
1754  }
1755 
1757  const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getDomainMap"); return toXpetra<GlobalOrdinal, Node>(mtx_->DomainMap()); }
1758 
1760  const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getRangeMap"); return toXpetra<GlobalOrdinal, Node>(mtx_->RangeMap()); }
1761 
1763 
1765 
1766 
1768  std::string description() const {
1769  XPETRA_MONITOR("EpetraCrsMatrixT::description");
1770 
1771  // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
1772  std::ostringstream oss;
1773  //TODO: oss << DistObject<char, LocalOrdinal,GlobalOrdinal>::description();
1774  if (isFillComplete()) {
1775  oss << "{status = fill complete"
1776  << ", global rows = " << getGlobalNumRows()
1777  << ", global cols = " << getGlobalNumCols()
1778  << ", global num entries = " << getGlobalNumEntries()
1779  << "}";
1780  }
1781  else {
1782  oss << "{status = fill not complete"
1783  << ", global rows = " << getGlobalNumRows()
1784  << "}";
1785  }
1786  return oss.str();
1787 
1788  }
1789 
1790 
1793  XPETRA_MONITOR("EpetraCrsMatrixT::describe");
1794 
1795  // This implementation come from Tpetra_CrsMatrix_def.hpp (without modification)
1796  using std::endl;
1797  using std::setw;
1798  using Teuchos::VERB_DEFAULT;
1799  using Teuchos::VERB_NONE;
1800  using Teuchos::VERB_LOW;
1801  using Teuchos::VERB_MEDIUM;
1802  using Teuchos::VERB_HIGH;
1803  using Teuchos::VERB_EXTREME;
1804  Teuchos::EVerbosityLevel vl = verbLevel;
1805  if (vl == VERB_DEFAULT) vl = VERB_LOW;
1806  RCP<const Comm<int> > comm = this->getComm();
1807  const int myImageID = comm->getRank(),
1808  numImages = comm->getSize();
1809  size_t width = 1;
1810  for (size_t dec=10; dec<getGlobalNumRows(); dec *= 10) {
1811  ++width;
1812  }
1813  width = std::max<size_t>(width,11) + 2;
1814  Teuchos::OSTab tab(out);
1815  // none: print nothing
1816  // low: print O(1) info from node 0
1817  // medium: print O(P) info, num entries per node
1818  // high: print O(N) info, num entries per row
1819  // extreme: print O(NNZ) info: print indices and values
1820  //
1821  // for medium and higher, print constituent objects at specified verbLevel
1822  if (vl != VERB_NONE) {
1823  if (myImageID == 0) out << this->description() << std::endl;
1824  // O(1) globals, minus what was already printed by description()
1825  if (isFillComplete() && myImageID == 0) {
1826  out << "Global number of diagonals = " << getGlobalNumDiags() << std::endl;
1827  out << "Global max number of entries = " << getGlobalMaxNumRowEntries() << std::endl;
1828  }
1829  // constituent objects
1830  if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1831  if (myImageID == 0) out << "\nRow map: " << std::endl;
1832  getRowMap()->describe(out,vl);
1833  //
1834  if (getColMap() != null) {
1835  if (getColMap() == getRowMap()) {
1836  if (myImageID == 0) out << "\nColumn map is row map.";
1837  }
1838  else {
1839  if (myImageID == 0) out << "\nColumn map: " << std::endl;
1840  getColMap()->describe(out,vl);
1841  }
1842  }
1843  if (getDomainMap() != null) {
1844  if (getDomainMap() == getRowMap()) {
1845  if (myImageID == 0) out << "\nDomain map is row map.";
1846  }
1847  else if (getDomainMap() == getColMap()) {
1848  if (myImageID == 0) out << "\nDomain map is row map.";
1849  }
1850  else {
1851  if (myImageID == 0) out << "\nDomain map: " << std::endl;
1852  getDomainMap()->describe(out,vl);
1853  }
1854  }
1855  if (getRangeMap() != null) {
1856  if (getRangeMap() == getDomainMap()) {
1857  if (myImageID == 0) out << "\nRange map is domain map." << std::endl;
1858  }
1859  else if (getRangeMap() == getRowMap()) {
1860  if (myImageID == 0) out << "\nRange map is row map." << std::endl;
1861  }
1862  else {
1863  if (myImageID == 0) out << "\nRange map: " << std::endl;
1864  getRangeMap()->describe(out,vl);
1865  }
1866  }
1867  if (myImageID == 0) out << std::endl;
1868  }
1869  // O(P) data
1870  if (vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME) {
1871  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1872  if (myImageID == imageCtr) {
1873  out << "Node ID = " << imageCtr << std::endl;
1874  // TODO: need a graph
1875  // if (staticGraph_->indicesAreAllocated() == false) {
1876  // out << "Node not allocated" << std::endl;
1877  // }
1878  // else {
1879  // out << "Node number of allocated entries = " << staticGraph_->getNodeAllocationSize() << std::endl;
1880  // }
1881 
1882  // TMP:
1883  // const Epetra_CrsGraph & staticGraph_ = mtx_->Graph();
1884  // End of TMP
1885 
1886  out << "Node number of entries = " << getNodeNumEntries() << std::endl;
1887  if (isFillComplete()) {
1888  out << "Node number of diagonals = " << getNodeNumDiags() << std::endl;
1889  }
1890  out << "Node max number of entries = " << getNodeMaxNumRowEntries() << std::endl;
1891  }
1892  comm->barrier();
1893  comm->barrier();
1894  comm->barrier();
1895  }
1896  }
1897  // O(N) and O(NNZ) data
1898  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
1899  for (int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
1900  if (myImageID == imageCtr) {
1901  out << std::setw(width) << "Node ID"
1902  << std::setw(width) << "Global Row"
1903  << std::setw(width) << "Num Entries";
1904  if (vl == VERB_EXTREME) {
1905  out << std::setw(width) << "(Index,Value)";
1906  }
1907  out << std::endl;
1908  for (size_t r=0; r < getNodeNumRows(); ++r) {
1909  const size_t nE = getNumEntriesInLocalRow(r);
1910  GlobalOrdinal gid = getRowMap()->getGlobalElement(r);
1911  out << std::setw(width) << myImageID
1912  << std::setw(width) << gid
1913  << std::setw(width) << nE;
1914  if (vl == VERB_EXTREME) {
1915  if (isGloballyIndexed()) {
1917  ArrayView<const Scalar> rowvals;
1918  getGlobalRowView(gid,rowinds,rowvals);
1919  for (size_t j=0; j < nE; ++j) {
1920  out << " (" << rowinds[j]
1921  << ", " << rowvals[j]
1922  << ") ";
1923  }
1924  }
1925  else if (isLocallyIndexed()) {
1927  ArrayView<const Scalar> rowvals;
1928  getLocalRowView(r,rowinds,rowvals);
1929  for (size_t j=0; j < nE; ++j) {
1930  out << " (" << getColMap()->getGlobalElement(rowinds[j])
1931  << ", " << rowvals[j]
1932  << ") ";
1933  }
1934  }
1935  }
1936  out << std::endl;
1937  }
1938  }
1939  comm->barrier();
1940  comm->barrier();
1941  comm->barrier();
1942  }
1943  }
1944  }
1945 
1946  }
1947 
1948 
1950 
1953  : mtx_(Teuchos::rcp(new Epetra_CrsMatrix(*(matrix.mtx_)))), isFillResumed_(false)
1954 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1955  , isInitializedLocalMatrix_(false)
1956 #endif
1957  { }
1958 
1959 
1961  //{@
1962 
1964  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("EpetraCrsMatrixT::getMap"); return toXpetra<GlobalOrdinal,Node>(mtx_->Map()); }
1965 
1969  XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
1970 
1971  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1972  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1973 
1974  RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
1975  int err = mtx_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1976  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1977  }
1978 
1982  XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
1983 
1984  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1985  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1986 
1987  RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
1988  int err = mtx_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1989  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1990  }
1991 
1995  XPETRA_MONITOR("EpetraCrsMatrixT::doImport");
1996 
1997  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
1998  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1999 
2000  RCP<const Epetra_CrsMatrix> v = tSource.getEpetra_CrsMatrix();
2001  int err = mtx_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
2002  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
2003 
2004  }
2005 
2009  XPETRA_MONITOR("EpetraCrsMatrixT::doExport");
2010 
2011  XPETRA_DYNAMIC_CAST(const EpetraCrsMatrixT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraCrsMatrixT as input arguments.");
2012  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsMatrixT::doImport only accept Xpetra::EpetraImportT as input arguments.");
2013 
2014  RCP<const Epetra_CrsMatrix> v = tDest.getEpetra_CrsMatrix();
2015  int err = mtx_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
2016  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
2017  }
2018 
2020 
2022 
2024 
2025 
2027  bool hasMatrix() const { return !mtx_.is_null();}
2028 
2030  EpetraCrsMatrixT(const Teuchos::RCP<Epetra_CrsMatrix > &mtx) : mtx_(mtx), isFillResumed_(false) { }
2031 
2034 
2036  RCP<Epetra_CrsMatrix> getEpetra_CrsMatrixNonConst() const { return mtx_; } //TODO: remove
2037 
2038 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
2039  local_matrix_type getLocalMatrix () const {
2041  TEUCHOS_TEST_FOR_EXCEPTION(isFillComplete() == false, std::runtime_error,
2042  "Xpetra::EpetraCrsMatrix::getLocalMatrix: matrix must be filled and completed before you can access the data through the Kokkos interface!");
2043  if (isInitializedLocalMatrix_)
2044  return localMatrix_;
2045 
2047 
2048  const int numRows = matrix->NumMyRows();
2049  const int numCols = matrix->NumMyCols();
2050  const int nnz = matrix->NumMyNonzeros();
2051 
2052  int* rowptr;
2053  int* colind;
2054  double* vals;
2055  int rv = matrix->ExtractCrsDataPointers(rowptr, colind, vals);
2056  TEUCHOS_TEST_FOR_EXCEPTION(rv, std::runtime_error, "Xpetra::CrsMatrix<>::getLocalMatrix: failed in ExtractCrsDataPointers");
2057 
2058  // Transform int* rowptr array to size_type* array
2059  typename local_matrix_type::row_map_type::non_const_type kokkosRowPtr("local row map", numRows+1);
2060  for (size_t i = 0; i < kokkosRowPtr.size(); i++)
2061  kokkosRowPtr(i) = Teuchos::asSafe<typename local_matrix_type::row_map_type::value_type>(rowptr[i]);
2062 
2063  // create Kokkos::Views
2064  typename local_matrix_type::index_type kokkosColind(colind, nnz);
2065  typename local_matrix_type::values_type kokkosVals (vals, nnz);
2066 
2067  localMatrix_ = local_matrix_type("LocalMatrix", numRows, numCols, nnz, kokkosVals, kokkosRowPtr, kokkosColind);
2068  isInitializedLocalMatrix_ = true;
2069 
2070  return localMatrix_;
2071  }
2072 #endif
2073 
2074 
2075 private:
2077 
2078  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.
2079 
2080 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
2081  mutable
2082  local_matrix_type localMatrix_;
2083  mutable
2084  bool isInitializedLocalMatrix_;
2085 #endif
2086 
2087 }; // EpetraCrsMatrixT class
2088 
2089 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
2090 
2091 } // Xpetra namespace
2092 
2093 #define XPETRA_EPETRACRSMATRIX_SHORT
2094 #endif // XPETRA_EPETRACRSMATRIX_HPP
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
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 scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
size_t getNodeNumEntries() const
Returns the local number of entries in this 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.
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=Xpetra::GloballyDistributed, const Teuchos::RCP< Node > &node=defaultArgNode())
Map constructor with Xpetra-defined contiguous uniform distribution.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
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.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
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.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
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)
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
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, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void resumeFill(const RCP< ParameterList > &params=null)
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...
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
const RCP< const Comm< int > > getComm() const
void resumeFill(const RCP< ParameterList > &params=Teuchos::null)
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
bool hasMatrix() const
Does this have an underlying matrix.
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...
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
void fillComplete(const RCP< ParameterList > &params=Teuchos::null)
Signal that data entry is complete.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
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.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
std::string description() const
A simple one-line description of this object.
Xpetra namespace
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...
T * getRawPtr() const
size_type size() const
void resumeFill(const RCP< ParameterList > &params=Teuchos::null)
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
Exception throws to report errors in the internal logical of the program.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
LocalOrdinal local_ordinal_type
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
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...
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
size_t getNodeNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
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_type size() const
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
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, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
std::string description() const
A simple one-line description of this object.
size_t getNodeNumRows() 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 fillComplete(const RCP< ParameterList > &params=Teuchos::null)
Signal that data entry is complete.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using local IDs.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
void resize(const size_type n, const T &val=T())
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 doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
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.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying a previously constructed graph.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void setAllToScalar(const Scalar &alpha)
bool hasMatrix() const
Does this have an underlying matrix.
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, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
Get a copy of the diagonal entries owned by this node, with local row indices, using row offsets...
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
std::string description() const
A simple one-line description of this object.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define XPETRA_ERR_CHECK(arg)
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...
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with 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.
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 describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
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)
Expert static fill complete.
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
size_t getNodeNumCols() const
Returns the number of matrix columns owned on the calling node.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
Get the underlying Epetra matrix.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
bool isFillActive() const
Returns true if the matrix is in edit mode.
RCP< Epetra_CrsMatrix > getEpetra_CrsMatrixNonConst() const
Get the underlying Epetra matrix.
EpetraCrsMatrixT(const EpetraCrsMatrixT &matrix)
Deep copy constructor.
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
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
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
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.
RCP< const Epetra_CrsMatrix > getEpetra_CrsMatrix() const
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this 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.
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
Exception throws when you call an unimplemented method of Xpetra.
T * getRawPtr() const
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
const RCP< const Comm< int > > getComm() const
Returns the communicator.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
size_t global_size_t
Global size_t object.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
static const EVerbosityLevel verbLevel_default
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...
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying (possibly different) number of entries in 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 > &params=Teuchos::null)
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
static magnitudeType magnitude(T a)
void fillComplete(const RCP< ParameterList > &params=null)
Signal that data entry is complete.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
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 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 scale(const Scalar &alpha)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
EpetraCrsMatrixT(const Teuchos::RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying a previously constructed graph.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices, const ArrayView< const Scalar > &values)
Replace matrix entries, using global IDs.
const RCP< const Comm< int > > getComm() const
Returns the communicator.
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)
Expert static fill complete.
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
bool hasMatrix() const
Does this have an underlying matrix.
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...
bool isFillActive() const
Returns true if the matrix is in edit mode.
EpetraCrsMatrixT(const Teuchos::RCP< Epetra_CrsMatrix > &mtx)
EpetraCrsMatrixT constructor to wrap a Epetra_CrsMatrix object.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
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, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
Copy
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=null)
size_t getNodeMaxNumRowEntries() 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.
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
bool isFillActive() const
Returns true if the matrix is in edit mode.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
CombineMode
Xpetra::Combine Mode enumerable type.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
#define XPETRA_MONITOR(funcName)
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
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.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
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.
iterator end() const
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
CrsMatrix< double, int, GlobalOrdinal, Node >::local_ordinal_type LocalOrdinal
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 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.
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 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 getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
iterator begin() const
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 getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
EpetraCrsMatrixT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, ProfileType pftype=DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
CrsMatrix< double, int, GlobalOrdinal, Node >::scalar_type Scalar
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
size_t getNodeNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
global_size_t getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
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
The Map describing the parallel distribution of this object.
ArrayView< T > view(size_type lowerOffset, size_type size) const
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)