Xpetra_CrsMatrixWrap.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 
47 // WARNING: This code is experimental. Backwards compatibility should not be expected.
48 
49 #ifndef XPETRA_CRSMATRIXWRAP_HPP
50 #define XPETRA_CRSMATRIXWRAP_HPP
51 
52 #include <Kokkos_DefaultNode.hpp>
53 
54 #include "Xpetra_ConfigDefs.hpp"
55 #include "Xpetra_Exceptions.hpp"
56 
57 #include "Xpetra_MultiVector.hpp"
58 #include "Xpetra_CrsGraph.hpp"
59 #include "Xpetra_CrsMatrix.hpp"
61 
62 #include "Xpetra_Matrix.hpp"
63 
64 #include <Teuchos_SerialDenseMatrix.hpp>
65 #include <Teuchos_Hashtable.hpp>
66 
71 namespace Xpetra {
72 
73  typedef std::string viewLabel_t;
74 
79 template <class Scalar = Matrix<>::scalar_type,
80  class LocalOrdinal = typename Matrix<Scalar>::local_ordinal_type,
81  class GlobalOrdinal =
83  class Node =
85 class CrsMatrixWrap :
86  public Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>
87 {
92 #ifdef HAVE_XPETRA_TPETRA
94 #endif
97 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
98 #ifdef HAVE_XPETRA_TPETRA
99  typedef typename CrsMatrix::local_matrix_type local_matrix_type;
100 #endif
101 #endif
102 
103 public:
105 
106 
108  CrsMatrixWrap (const RCP<const Map>& rowMap,
109  size_t maxNumEntriesPerRow,
111  : finalDefaultView_ (false)
112  {
113  matrixData_ = CrsMatrixFactory::Build (rowMap, maxNumEntriesPerRow, pftype);
115  }
116 
118  CrsMatrixWrap (const RCP<const Map>& rowMap,
119  const ArrayRCP<const size_t>& NumEntriesPerRowToAlloc,
121  : finalDefaultView_ (false)
122  {
123  matrixData_ = CrsMatrixFactory::Build(rowMap, NumEntriesPerRowToAlloc, pftype);
125  }
126 
128  CrsMatrixWrap(const RCP<const Map> &rowMap, const RCP<const Map>& colMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype = Xpetra::DynamicProfile)
129  : finalDefaultView_(false)
130  {
131  // Set matrix data
132  matrixData_ = CrsMatrixFactory::Build(rowMap, colMap, maxNumEntriesPerRow, pftype);
133 
134  // Default view
136  }
137 
139  CrsMatrixWrap(const RCP<const Map> &rowMap, const RCP<const Map>& colMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc, Xpetra::ProfileType pftype = Xpetra::DynamicProfile)
140  : finalDefaultView_(false)
141  {
142  // Set matrix data
143  matrixData_ = CrsMatrixFactory::Build(rowMap, colMap, NumEntriesPerRowToAlloc, pftype);
144 
145  // Default view
147  }
148 
149 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
150 #ifdef HAVE_XPETRA_TPETRA
151  CrsMatrixWrap(const RCP<const Map> &rowMap, const RCP<const Map>& colMap, const local_matrix_type& lclMatrix, const Teuchos::RCP<Teuchos::ParameterList>& params = null)
153  : finalDefaultView_(false)
154  {
155  // Set matrix data
156  matrixData_ = CrsMatrixFactory::Build(rowMap, colMap, lclMatrix, params);
157 
158  // Default view
160  }
161 #else
162 #ifdef __GNUC__
163 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
164 #endif
165 #endif
166 #endif
167 
168  CrsMatrixWrap(RCP<CrsMatrix> matrix)
169  : finalDefaultView_(matrix->isFillComplete())
170  {
171  // Set matrix data
172  matrixData_ = matrix;
173 
174  // Default view
176  }
177 
178  CrsMatrixWrap(const RCP<const CrsGraph>& graph, const RCP<ParameterList>& paramList = Teuchos::null)
179  : finalDefaultView_(false)
180  {
181  // Set matrix data
182  matrixData_ = CrsMatrixFactory::Build(graph, paramList);
183 
184  // Default view
186  }
187 
189  virtual ~CrsMatrixWrap() {}
190 
192 
193 
195 
196 
198 
209  void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal> &cols, const ArrayView<const Scalar> &vals) {
210  matrixData_->insertGlobalValues(globalRow, cols, vals);
211  }
212 
214 
221  void insertLocalValues(LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &cols, const ArrayView<const Scalar> &vals) {
222  matrixData_->insertLocalValues(localRow, cols, vals);
223  }
224 
226 
231  void replaceGlobalValues(GlobalOrdinal globalRow,
232  const ArrayView<const GlobalOrdinal> &cols,
233  const ArrayView<const Scalar> &vals) { matrixData_->replaceGlobalValues(globalRow, cols, vals); }
234 
236 
239  void replaceLocalValues(LocalOrdinal localRow,
240  const ArrayView<const LocalOrdinal> &cols,
241  const ArrayView<const Scalar> &vals) { matrixData_->replaceLocalValues(localRow, cols, vals); }
242 
244  virtual void setAllToScalar(const Scalar &alpha) { matrixData_->setAllToScalar(alpha); }
245 
247  void scale(const Scalar &alpha) {
248  matrixData_->scale(alpha);
249  }
250 
252 
254 
255 
264  void resumeFill(const RCP< ParameterList > &params=null) {
265  matrixData_->resumeFill(params);
266  }
267 
279  void fillComplete(const RCP<const Map> &domainMap, const RCP<const Map> &rangeMap, const RCP<Teuchos::ParameterList> &params = null) {
280  matrixData_->fillComplete(domainMap, rangeMap, params);
281 
282  // Update default view with the colMap because colMap can be <tt>null</tt> until fillComplete() is called.
284  }
285 
299  //TODO : Get ride of "Tpetra"::OptimizeOption
300  void fillComplete(const RCP<ParameterList> &params = null) {
301  matrixData_->fillComplete(params);
302 
303  // Update default view with the colMap because colMap can be <tt>null</tt> until fillComplete() is called.
305  }
306 
308 
310 
313  return matrixData_->getGlobalNumRows();
314  }
315 
317 
320  return matrixData_->getGlobalNumCols();
321  }
322 
324  size_t getNodeNumRows() const {
325  return matrixData_->getNodeNumRows();
326  }
327 
330  return matrixData_->getGlobalNumEntries();
331  }
332 
334  size_t getNodeNumEntries() const {
335  return matrixData_->getNodeNumEntries();
336  }
337 
339 
340  size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
341  return matrixData_->getNumEntriesInLocalRow(localRow);
342  }
343 
345 
348  return matrixData_->getGlobalNumDiags();
349  }
350 
352 
354  size_t getNodeNumDiags() const {
355  return matrixData_->getNodeNumDiags();
356  }
357 
359 
361  size_t getGlobalMaxNumRowEntries() const {
362  return matrixData_->getGlobalMaxNumRowEntries();
363  }
364 
366 
368  size_t getNodeMaxNumRowEntries() const {
369  return matrixData_->getNodeMaxNumRowEntries();
370  }
371 
373  bool isLocallyIndexed() const {
374  return matrixData_->isLocallyIndexed();
375  }
376 
378  bool isGloballyIndexed() const {
379  return matrixData_->isGloballyIndexed();
380  }
381 
383  bool isFillComplete() const {
384  return matrixData_->isFillComplete();
385  }
386 
388 
400  void getLocalRowCopy(LocalOrdinal LocalRow,
401  const ArrayView<LocalOrdinal> &Indices,
402  const ArrayView<Scalar> &Values,
403  size_t &NumEntries
404  ) const {
405  matrixData_->getLocalRowCopy(LocalRow, Indices, Values, NumEntries);
406  }
407 
409 
418  void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &indices, ArrayView<const Scalar> &values) const {
419  matrixData_->getGlobalRowView(GlobalRow, indices, values);
420  }
421 
423 
432  void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal> &indices, ArrayView<const Scalar> &values) const {
433  matrixData_->getLocalRowView(LocalRow, indices, values);
434  }
435 
437 
440  matrixData_->getLocalDiagCopy(diag);
441  }
442 
444  void getLocalDiagOffsets(Teuchos::ArrayRCP<size_t> &offsets) const {
445  matrixData_->getLocalDiagOffsets(offsets);
446  }
447 
449  void getLocalDiagCopy(Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView<const size_t> &offsets) const {
450  matrixData_->getLocalDiagCopy(diag,offsets);
451  }
452 
454  typename ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const {
455  return matrixData_->getFrobeniusNorm();
456  }
457 
460  matrixData_->leftScale(x);
461  }
462 
465  matrixData_->rightScale(x);
466  }
467 
469 
471 
472 
474 
483  //TODO virtual=0 // TODO: Add default parameters ?
484 // void multiply(const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> & X, MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y, Teuchos::ETransp trans, Scalar alpha, Scalar beta) const {
485 // matrixData_->multiply(X, Y, trans, alpha, beta);
486 // }
487 
489 
491 
492 
494 
499  Teuchos::ETransp mode = Teuchos::NO_TRANS,
500  Scalar alpha = ScalarTraits<Scalar>::one(),
501  Scalar beta = ScalarTraits<Scalar>::zero()) const {
502 
503  matrixData_->apply(X,Y,mode,alpha,beta);
504  }
505 
508  RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getDomainMap() const {
509  return matrixData_->getDomainMap();
510  }
511 
514  RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRangeMap() const {
515  return matrixData_->getRangeMap();
516  }
517 
520  const RCP<const Map> & getColMap() const { return getColMap(Matrix::GetCurrentViewLabel()); }
521 
523  const RCP<const Map> & getColMap(viewLabel_t viewLabel) const {
524  TEUCHOS_TEST_FOR_EXCEPTION(Matrix::operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.GetColMap(): view '" + viewLabel + "' does not exist.");
525  updateDefaultView(); // If CrsMatrix::fillComplete() have been used instead of CrsMatrixWrap::fillComplete(), the default view is updated.
526  return Matrix::operatorViewTable_.get(viewLabel)->GetColMap();
527  }
528 
529  void removeEmptyProcessesInPlace(const Teuchos::RCP<const Map>& newMap) {
530  matrixData_->removeEmptyProcessesInPlace(newMap);
531  this->operatorViewTable_.get(this->GetCurrentViewLabel())->SetRowMap(matrixData_->getRowMap());
532  this->operatorViewTable_.get(this->GetCurrentViewLabel())->SetColMap(matrixData_->getColMap());
533  }
534 
536 
538  //{@
539 
541  const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const {
542  return matrixData_->getMap();
543  }
544 
546  void doImport(const Matrix &source,
548  const CrsMatrixWrap & sourceWrp = dynamic_cast<const CrsMatrixWrap &>(source);
549  matrixData_->doImport(*sourceWrp.getCrsMatrix(), importer, CM);
550  }
551 
553  void doExport(const Matrix &dest,
555  const CrsMatrixWrap & destWrp = dynamic_cast<const CrsMatrixWrap &>(dest);
556  matrixData_->doExport(*destWrp.getCrsMatrix(), importer, CM);
557  }
558 
560  void doImport(const Matrix &source,
562  const CrsMatrixWrap & sourceWrp = dynamic_cast<const CrsMatrixWrap &>(source);
563  matrixData_->doImport(*sourceWrp.getCrsMatrix(), exporter, CM);
564  }
565 
567  void doExport(const Matrix &dest,
569  const CrsMatrixWrap & destWrp = dynamic_cast<const CrsMatrixWrap &>(dest);
570  matrixData_->doExport(*destWrp.getCrsMatrix(), exporter, CM);
571  }
572 
573  // @}
574 
576 
577 
579  std::string description() const {
580  return "Xpetra::CrsMatrixWrap";
581  }
582 
584  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const {
585  // Teuchos::EVerbosityLevel vl = verbLevel;
586  // if (vl == VERB_DEFAULT) vl = VERB_LOW;
587  // RCP<const Comm<int> > comm = this->getComm();
588  // const int myImageID = comm->getRank(),
589  // numImages = comm->getSize();
590 
591  // if (myImageID == 0) out << this->description() << std::endl;
592 
593  matrixData_->describe(out,verbLevel);
594 
595  // Teuchos::OSTab tab(out);
596  }
597 
598 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
599 #ifdef HAVE_XPETRA_TPETRA
600  local_matrix_type getLocalMatrix () const {
602  return matrixData_->getLocalMatrix();
603  }
604 #else
605 #ifdef __GNUC__
606 #warning "Xpetra Kokkos interface for CrsMatrix is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
607 #endif
608 #endif
609 #endif
610 
611  // JG: Added:
612 
614  RCP<const CrsGraph> getCrsGraph() const { return matrixData_->getCrsGraph(); }
615 
616  RCP<CrsMatrix> getCrsMatrix() const { return matrixData_; }
617 
619 
620  template<class Node2>
621  RCP<Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node2> > clone(const RCP<Node2> &node2) const {
622 #ifdef HAVE_XPETRA_TPETRA
623  RCP<const Xpetra::TpetraCrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > tMatrix =
625  if (tMatrix == Teuchos::null)
626  throw Xpetra::Exceptions::RuntimeError("clone() functionality is only available for Tpetra");
627 
628  return RCP<CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node2> >(new CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node2>(tMatrix->clone(node2)));
629  // TODO: inherit strided maps/views ?
630 #else
631  return Teuchos::null;
632 #endif
633  }
634 
635 private:
636 
637  // Default view is created after fillComplete()
638  // Because ColMap might not be available before fillComplete().
640 
641  // Create default view
642  this->defaultViewLabel_ = "point";
643  this->CreateView(this->GetDefaultViewLabel(), matrixData_->getRowMap(), matrixData_->getColMap());
644 
645  // Set current view
646  this->currentViewLabel_ = this->GetDefaultViewLabel();
647  }
648 
649 private:
650 
651  // The colMap can be <tt>null</tt> until fillComplete() is called. The default view of the Matrix have to be updated when fillComplete() is called.
652  // If CrsMatrix::fillComplete() have been used instead of CrsMatrixWrap::fillComplete(), the default view is updated when getColMap() is called.
653  void updateDefaultView() const {
654  if ((finalDefaultView_ == false) && matrixData_->isFillComplete() ) {
655  // Update default view with the colMap
657  finalDefaultView_ = true;
658  }
659  }
660  // The boolean finalDefaultView_ keep track of the status of the default view (= already updated or not)
661  // See also CrsMatrixWrap::updateDefaultView()
662  mutable bool finalDefaultView_;
663 
664 
665  RCP<CrsMatrix> matrixData_;
666 
667 }; //class Matrix
668 
669 } //namespace Xpetra
670 
671 #define XPETRA_CRSMATRIXWRAP_SHORT
672 #endif //XPETRA_CRSMATRIXWRAP_DECL_HPP
673 
674 //NOTE: if CrsMatrix and VbrMatrix share a common interface for fillComplete() etc, I can move some stuff in Xpetra_Matrix.hpp
675 //TODO: getUnderlyingMatrix() method
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Right scale matrix using the given vector entries.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
virtual void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalar.
Xpetra::TpetraCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraCrsMatrix
virtual ~CrsMatrixWrap()
Destructor.
CrsMatrixWrap(const RCP< const Map > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying (possibly different) number of entries in each row.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
void doExport(const Matrix &dest, const Xpetra::Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
static RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile, const Teuchos::RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
Xpetra namespace
const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
LocalOrdinal local_ordinal_type
CrsMatrixWrap(RCP< CrsMatrix > matrix)
Exception throws to report errors in the internal logical of the program.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map > &newMap)
global_size_t getGlobalNumCols() const
Returns the number of global columns in the matrix.
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
CrsMatrixWrap(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row.
void doExport(const Matrix &dest, const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
Teuchos::Hashtable< viewLabel_t, RCP< MatrixView > > operatorViewTable_
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Get Frobenius norm of the matrix.
const RCP< const Map > & getColMap(viewLabel_t viewLabel) const
Returns the Map that describes the column distribution in this matrix.
Xpetra::MatrixView< LocalOrdinal, GlobalOrdinal, Node > MatrixView
size_t getNodeNumDiags() const
Returns the number of local diagonal entries, based on global row/column index comparisons.
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
void doImport(const Matrix &source, const Xpetra::Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void doImport(const Matrix &source, const Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
CrsMatrixWrap(const RCP< const Map > &rowMap, const RCP< const Map > &colMap, size_t maxNumEntriesPerRow, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row and column map.
viewLabel_t defaultViewLabel_
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > CrsGraph
const viewLabel_t & GetDefaultViewLabel() const
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 > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
viewLabel_t currentViewLabel_
RCP< CrsMatrix > getCrsMatrix() const
void apply(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
void 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 getGlobalNumDiags() const
Returns the number of global diagonal entries, based on global row/column index comparisons.
RCP< const CrsGraph > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
std::string viewLabel_t
size_t global_size_t
Global size_t object.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
CrsMatrixWrap(const RCP< const Map > &rowMap, const RCP< const Map > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor specifying fixed number of entries for each row and column map.
void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< Teuchos::ParameterList > &params=null)
Signal that data entry is complete, specifying domain and range maps.
void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void resumeFill(const RCP< ParameterList > &params=null)
const viewLabel_t & GetCurrentViewLabel() const
void getLocalDiagCopy(Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row idices.
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.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
CrsMatrixWrap(const RCP< const CrsGraph > &graph, const RCP< ParameterList > &paramList=Teuchos::null)
Concrete implementation of Xpetra::Matrix.
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
CombineMode
Xpetra::Combine Mode enumerable type.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Left scale matrix using the given vector entries.
std::string description() const
Return a simple one-line description of this object.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > CrsMatrix
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
RCP< Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > clone(const RCP< Node2 > &node2) const
void getLocalDiagCopy(Xpetra::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 fillComplete(const RCP< ParameterList > &params=null)
Signal that data entry is complete.
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > Matrix
Xpetra::CrsMatrixFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > CrsMatrixFactory
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
Xpetra-specific matrix class.
GlobalOrdinal global_ordinal_type