Xpetra_Matrix.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 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@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_MATRIX_HPP
50 #define XPETRA_MATRIX_HPP
51 
52 #include <Kokkos_DefaultNode.hpp>
54 
55 #include "Xpetra_ConfigDefs.hpp"
56 #include "Xpetra_Exceptions.hpp"
57 
58 #include "Xpetra_MultiVector.hpp"
59 #include "Xpetra_CrsGraph.hpp"
60 #include "Xpetra_CrsMatrix.hpp"
62 #include "Xpetra_MatrixView.hpp"
63 #include "Xpetra_StridedMap.hpp"
65 
66 #include <Teuchos_SerialDenseMatrix.hpp>
67 #include <Teuchos_Hashtable.hpp>
68 
73 namespace Xpetra {
74 
91  typedef std::string viewLabel_t;
92 
93  template <class Scalar,
94  class LocalOrdinal = int,
95  class GlobalOrdinal = LocalOrdinal,
97  class LocalMatOps = typename Kokkos::DefaultKernels<Scalar,LocalOrdinal,Node>::SparseOps > //TODO: or BlockSparseOp ?
98  class Matrix : virtual public Teuchos::Describable {
99 
103 #ifdef HAVE_XPETRA_TPETRA
105 #endif
108 
109  public:
110 
112 
113 
114  Matrix() { }
115 
117  virtual ~Matrix() { }
118 
120 
122 
123  void CreateView(viewLabel_t viewLabel, const RCP<const Map> & rowMap, const RCP<const Map> & colMap) {
124  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == true, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.CreateView(): a view labeled '" + viewLabel + "' already exist.");
125  RCP<MatrixView> view = rcp(new MatrixView(rowMap, colMap));
126  operatorViewTable_.put(viewLabel, view);
127  }
128 
129  // JG TODO: why this is a member function??
130  void CreateView(const viewLabel_t viewLabel, const RCP<const Matrix> & A, bool transposeA = false, const RCP<const Matrix> & B = Teuchos::null, bool transposeB = false) {
131 
132  RCP<const Map> domainMap = Teuchos::null;
133  RCP<const Map> rangeMap = Teuchos::null;
134 
135  if(A->IsView(viewLabel)) {
136  // A has strided Maps
137  // -- JG: ? I don't see how strided Maps are directly related to this functionality
138  RCP<Matrix> nonConstA = Teuchos::rcp_const_cast<Matrix>(A); // FIXME: implement this without changing the view
139 
140  Xpetra::viewLabel_t oldView = nonConstA->SwitchToView(viewLabel); // note: "stridedMaps are always non-overlapping (correspond to range and domain maps!)
141  rangeMap = (transposeA) ? nonConstA->getColMap() : nonConstA->getRowMap();
142  domainMap = (transposeA) ? nonConstA->getRowMap() : nonConstA->getColMap(); // overwrite if B != Teuchos::null
143  oldView = nonConstA->SwitchToView(oldView);
144  } else rangeMap = (transposeA) ? A->getDomainMap() : A->getRangeMap();
145 
146  if(B != Teuchos::null ) {
147  // B has strided Maps
148 
149  if(B->IsView(viewLabel)) {
150  RCP<Matrix> nonConstB = Teuchos::rcp_const_cast<Matrix>(B); // FIXME: implement this without changing the view
151 
152  Xpetra::viewLabel_t oldView = nonConstB->SwitchToView(viewLabel); // note: "stridedMaps are always non-overlapping (correspond to range and domain maps!)
153  domainMap = (transposeB) ? nonConstB->getRowMap() : nonConstB->getColMap();
154  oldView = nonConstB->SwitchToView(oldView);
155  } else domainMap = (transposeB) ? B->getRangeMap() : B->getDomainMap();
156  }
157 
158 
159  if(IsView(viewLabel)) RemoveView(viewLabel);
160 
161  CreateView(viewLabel, rangeMap, domainMap);
162  }
163 
165  void PrintViews(Teuchos::FancyOStream &out) const {
166  int last = out.getOutputToRootOnly();
167  Teuchos::OSTab tab(out);
168  out.setOutputToRootOnly(0);
169  Teuchos::Array<viewLabel_t> viewLabels;
170  Teuchos::Array<RCP<MatrixView> > viewList;
171  operatorViewTable_.arrayify(viewLabels,viewList);
172  out << "views associated with this operator" << std::endl;
173  for (int i=0; i<viewLabels.size(); ++i)
174  out << viewLabels[i] << std::endl;
175  out.setOutputToRootOnly(last);
176  }
177 
178 
179  void RemoveView(const viewLabel_t viewLabel) {
180  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.RemoveView(): view '" + viewLabel + "' does not exist.");
181  TEUCHOS_TEST_FOR_EXCEPTION(viewLabel == GetDefaultViewLabel(), Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.RemoveView(): view '" + viewLabel + "' is the default view and cannot be removed.");
182  operatorViewTable_.remove(viewLabel);
183  }
184 
185  const viewLabel_t SwitchToView(const viewLabel_t viewLabel) {
186  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.SwitchToView(): view '" + viewLabel + "' does not exist.");
187  viewLabel_t oldViewLabel = GetCurrentViewLabel();
188  currentViewLabel_ = viewLabel;
189  return oldViewLabel;
190  }
191 
192  bool IsView(const viewLabel_t viewLabel) const {
193  return operatorViewTable_.containsKey(viewLabel);
194  }
195 
196  const viewLabel_t SwitchToDefaultView() { return SwitchToView(GetDefaultViewLabel()); }
197 
198  const viewLabel_t & GetDefaultViewLabel() const { return defaultViewLabel_; }
199 
200  const viewLabel_t & GetCurrentViewLabel() const { return currentViewLabel_; }
201 
203 
205 
206 
208 
219  virtual void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal> &cols, const ArrayView<const Scalar> &vals) = 0;
220 
222 
229  virtual void insertLocalValues(LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &cols, const ArrayView<const Scalar> &vals) = 0;
230 
232 
237  virtual void replaceGlobalValues(GlobalOrdinal globalRow,
238  const ArrayView<const GlobalOrdinal> &cols,
239  const ArrayView<const Scalar> &vals) = 0;
240 
242 
245  virtual void replaceLocalValues(LocalOrdinal localRow,
246  const ArrayView<const LocalOrdinal> &cols,
247  const ArrayView<const Scalar> &vals) = 0;
248 
250  virtual void setAllToScalar(const Scalar &alpha)= 0;
251 
253  virtual void scale(const Scalar &alpha)= 0;
254 
256 
258 
259 
268  virtual void resumeFill(const RCP< ParameterList > &params=null) = 0;
269 
281  virtual void fillComplete(const RCP<const Map> &domainMap, const RCP<const Map> &rangeMap, const RCP<ParameterList> &params = null) =0;
282 
296  //TODO : Get ride of "Tpetra"::OptimizeOption
297  virtual void fillComplete(const RCP<ParameterList> &params=null) =0;
298 
300 
302 
303 
305  virtual const RCP<const Map> & getRowMap() const { return getRowMap(GetCurrentViewLabel()); }
306 
308  virtual const RCP<const Map> & getRowMap(viewLabel_t viewLabel) const {
309  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.GetRowMap(): view '" + viewLabel + "' does not exist.");
310  return operatorViewTable_.get(viewLabel)->GetRowMap();
311  }
312 
315  virtual const RCP<const Map> & getColMap() const { return getColMap(GetCurrentViewLabel()); }
316 
318  virtual const RCP<const Map> & getColMap(viewLabel_t viewLabel) const {
319  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.GetColMap(): view '" + viewLabel + "' does not exist.");
320  return operatorViewTable_.get(viewLabel)->GetColMap();
321  }
322 
324 
326  virtual global_size_t getGlobalNumRows() const =0;
327 
329 
331  virtual global_size_t getGlobalNumCols() const =0;
332 
334  virtual size_t getNodeNumRows() const =0;
335 
337  virtual global_size_t getGlobalNumEntries() const =0;
338 
340  virtual size_t getNodeNumEntries() const =0;
341 
343 
344  virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0;
345 
347 
349  virtual global_size_t getGlobalNumDiags() const =0;
350 
352 
354  virtual size_t getNodeNumDiags() const =0;
355 
357 
359  virtual size_t getGlobalMaxNumRowEntries() const =0;
360 
362 
364  virtual size_t getNodeMaxNumRowEntries() const =0;
365 
367  virtual bool isLocallyIndexed() const =0;
368 
370  virtual bool isGloballyIndexed() const =0;
371 
373  virtual bool isFillComplete() const =0;
374 
376 
388  virtual void getLocalRowCopy(LocalOrdinal LocalRow,
389  const ArrayView<LocalOrdinal> &Indices,
390  const ArrayView<Scalar> &Values,
391  size_t &NumEntries
392  ) const =0;
393 
395 
404  virtual void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &indices, ArrayView<const Scalar> &values) const =0;
405 
407 
416  virtual void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal> &indices, ArrayView<const Scalar> &values) const =0;
417 
419 
422 
424  virtual typename ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const = 0;
425 
427 
429 
430 
432 
441  //TODO virtual=0 // TODO: Add default parameters ?
442 // virtual void multiply(const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> & X, MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y, Teuchos::ETransp trans, Scalar alpha, Scalar beta) const=0;
443 
445 
447 
448 
450 
454  Teuchos::ETransp mode = Teuchos::NO_TRANS,
455  Scalar alpha = ScalarTraits<Scalar>::one(),
456  Scalar beta = ScalarTraits<Scalar>::zero()) const =0;
457 
460  virtual const RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getDomainMap() const =0;
461 
464  virtual const RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRangeMap() const =0;
465 
466  virtual void removeEmptyProcessesInPlace(const RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal, Node> >& newMap) = 0;
467 
469 
471  //{@
472 
474  virtual const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0;
475 
476  // TODO: first argument of doImport/doExport should be a Xpetra::DistObject
477 
479  virtual void doImport(const Matrix &source,
481 
483  virtual void doExport(const Matrix &dest,
485 
487  virtual void doImport(const Matrix &source,
489 
491  virtual void doExport(const Matrix &dest,
493 
494  // @}
495 
497 
498 
499  // TODO: describe of views can be done here
500 
501  // /** \brief Return a simple one-line description of this object. */
502  // virtual std::string description() const =0;
503 
504  // /** \brief Print the object with some verbosity level to an FancyOStream object. */
505  // virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const =0;
506 
508 
509 
511 
512 
514  virtual std::string description() const =0;
515 
517  virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const =0;
519 
520  // JG: Added:
521 
523  virtual RCP<const CrsGraph> getCrsGraph() const =0;
524 
525  // ----------------------------------------------------------------------------------
526  // "TEMPORARY" VIEW MECHANISM
527  // TODO: the view mechanism should be implemented as in MueMat.
528  void SetFixedBlockSize(LocalOrdinal blksize) {
529 
530  TEUCHOS_TEST_FOR_EXCEPTION(isFillComplete() == false, Exceptions::RuntimeError, "Xpetra::Matrix::SetFixedBlockSize(): operator is not filled and completed."); // TODO: do we need this? we just wanna "copy" the domain and range map
531 
532  std::vector<size_t> stridingInfo;
533  stridingInfo.push_back(Teuchos::as<size_t>(blksize));
534  LocalOrdinal stridedBlockId = -1;
535 
536  RCP<const Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node> > stridedRangeMap = Xpetra::StridedMapFactory<LocalOrdinal, GlobalOrdinal, Node>::Build(getRangeMap()->lib(),
537  getRangeMap(),
538  stridingInfo,
539  stridedBlockId
540  );
542  getDomainMap(),
543  stridingInfo,
544  stridedBlockId
545  );
546 
547  if(IsView("stridedMaps") == true) RemoveView("stridedMaps");
548  CreateView("stridedMaps", stridedRangeMap, stridedDomainMap);
549  }
550 
551  //==========================================================================
552 
553  LocalOrdinal GetFixedBlockSize() const {
554  if(IsView("stridedMaps")==true) {
555  Teuchos::RCP<const StridedMap<LocalOrdinal, GlobalOrdinal, Node> > rangeMap = Teuchos::rcp_dynamic_cast<const StridedMap<LocalOrdinal, GlobalOrdinal, Node> >(getRowMap("stridedMaps"));
556  Teuchos::RCP<const StridedMap<LocalOrdinal, GlobalOrdinal, Node> > domainMap = Teuchos::rcp_dynamic_cast<const StridedMap<LocalOrdinal, GlobalOrdinal, Node> >(getColMap("stridedMaps"));
557  TEUCHOS_TEST_FOR_EXCEPTION(rangeMap == Teuchos::null, Exceptions::BadCast, "Xpetra::Matrix::GetFixedBlockSize(): rangeMap is not of type StridedMap");
558  TEUCHOS_TEST_FOR_EXCEPTION(domainMap == Teuchos::null, Exceptions::BadCast, "Xpetra::Matrix::GetFixedBlockSize(): domainMap is not of type StridedMap");
559  TEUCHOS_TEST_FOR_EXCEPTION(domainMap->getFixedBlockSize() != rangeMap->getFixedBlockSize(), Exceptions::RuntimeError, "Xpetra::Matrix::GetFixedBlockSize(): block size of rangeMap and domainMap are different.");
560  return Teuchos::as<LocalOrdinal>(domainMap->getFixedBlockSize()); // TODO: why LocalOrdinal?
561  } else
562  //TEUCHOS_TEST_FOR_EXCEPTION(false, Exceptions::RuntimeError, "Xpetra::Matrix::GetFixedBlockSize(): no strided maps available."); // TODO remove this
563  return 1;
564  }; //TODO: why LocalOrdinal?
565 
566  // ----------------------------------------------------------------------------------
567 
568  virtual void SetMaxEigenvalueEstimate(Scalar const &sigma) {
569  operatorViewTable_.get(GetCurrentViewLabel())->SetMaxEigenvalueEstimate(sigma);
570  }
571 
572  // ----------------------------------------------------------------------------------
573 
574  virtual Scalar GetMaxEigenvalueEstimate() const {
575  return operatorViewTable_.get(GetCurrentViewLabel())->GetMaxEigenvalueEstimate();
576  }
577 
578  // ----------------------------------------------------------------------------------
579 
580  protected:
581  Teuchos::Hashtable<viewLabel_t, RCP<MatrixView> > operatorViewTable_; // hashtable storing the operator views (keys = view names, values = views).
582 
583  viewLabel_t defaultViewLabel_; // label of the view associated with inital Matrix construction
584  viewLabel_t currentViewLabel_; // label of the current view
585 
586  }; //class Matrix
587 
588 } //namespace Xpetra
589 
590 #define XPETRA_MATRIX_SHORT
591 #endif //XPETRA_MATRIX_DECL_HPP
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
virtual bool isLocallyIndexed() const =0
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
virtual const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const =0
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
const viewLabel_t SwitchToView(const viewLabel_t viewLabel)
virtual void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Replace matrix entries, using local IDs.
virtual void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Insert matrix entries, using global IDs.
virtual const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const =0
virtual void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< ParameterList > &params=null)=0
Signal that data entry is complete, specifying domain and range maps.
virtual const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
Implements DistObject interface.
virtual global_size_t getGlobalNumEntries() const =0
Returns the global number of entries in this matrix.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsGraph
virtual void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const =0
Get a copy of the diagonal entries owned by this node, with local row idices.
void RemoveView(const viewLabel_t viewLabel)
virtual void removeEmptyProcessesInPlace(const RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)=0
Xpetra namespace
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsMatrix
Exception throws to report errors in the internal logical of the program.
virtual 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 =0
Computes the sparse matrix-multivector multiplication.
Xpetra::MatrixView< Scalar, LocalOrdinal, GlobalOrdinal, Node > MatrixView
virtual global_size_t getGlobalNumDiags() const =0
Returns the number of global diagonal entries, based on global row/column index comparisons.
virtual bool isGloballyIndexed() const =0
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
virtual std::string description() const =0
Return a simple one-line description of this object.
virtual const RCP< const Map > & getRowMap(viewLabel_t viewLabel) const
Returns the Map that describes the row distribution in this matrix.
virtual const RCP< const Map > & getColMap(viewLabel_t viewLabel) const
Returns the Map that describes the column distribution in this matrix.
Exception indicating invalid cast attempted.
virtual void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Insert matrix entries, using local IDs.
virtual ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const =0
Get Frobenius norm of the matrix.
const viewLabel_t SwitchToDefaultView()
virtual void doExport(const Matrix &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)=0
Export.
const viewLabel_t & GetCurrentViewLabel() const
virtual void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const =0
Extract a const, non-persisting view of local indices in a specified row of the matrix.
virtual void doImport(const Matrix &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)=0
Import.
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
static Teuchos::RCP< StridedMap< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, LocalGlobal lg=Xpetra::GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::Details::getNode< Node >())
Map constructor with Xpetra-defined contiguous uniform distribution.
virtual void SetMaxEigenvalueEstimate(Scalar const &sigma)
viewLabel_t currentViewLabel_
virtual RCP< const CrsGraph > getCrsGraph() const =0
Returns the CrsGraph associated with this matrix.
virtual size_t getNodeNumRows() const =0
Returns the number of matrix rows owned on the calling node.
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
Teuchos::Hashtable< viewLabel_t, RCP< MatrixView > > operatorViewTable_
virtual Scalar GetMaxEigenvalueEstimate() const
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0
Returns the current number of entries on this node in the specified local row.
virtual size_t getGlobalMaxNumRowEntries() const =0
Returns the maximum number of entries across all rows/columns on all nodes.
void PrintViews(Teuchos::FancyOStream &out) const
Print all of the views associated with the Matrix.
void CreateView(const viewLabel_t viewLabel, const RCP< const Matrix > &A, bool transposeA=false, const RCP< const Matrix > &B=Teuchos::null, bool transposeB=false)
std::string viewLabel_t
size_t global_size_t
Global size_t object.
virtual size_t getNodeMaxNumRowEntries() const =0
Returns the maximum number of entries across all rows/columns on this node.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const =0
Print the object with some verbosity level to an FancyOStream object.
virtual const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
viewLabel_t defaultViewLabel_
LocalOrdinal GetFixedBlockSize() const
Xpetra::TpetraCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > TpetraCrsMatrix
virtual size_t getNodeNumEntries() const =0
Returns the local number of entries in this matrix.
void SetFixedBlockSize(LocalOrdinal blksize)
virtual void setAllToScalar(const Scalar &alpha)=0
Set all matrix entries equal to scalar.
CombineMode
Xpetra::Combine Mode enumerable type.
bool IsView(const viewLabel_t viewLabel) const
virtual void scale(const Scalar &alpha)=0
Scale the current values of a matrix, this = alpha*this.
virtual ~Matrix()
Destructor.
const viewLabel_t & GetDefaultViewLabel() const
virtual bool isFillComplete() const =0
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
virtual void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Replace matrix entries, using global IDs.
virtual global_size_t getGlobalNumRows() const =0
Returns the number of global rows in this matrix.
virtual void resumeFill(const RCP< ParameterList > &params=null)=0
virtual global_size_t getGlobalNumCols() const =0
Returns the number of global columns in the matrix.
Xpetra-specific matrix class.
Class that stores a strided map.
virtual size_t getNodeNumDiags() const =0
Returns the number of local diagonal entries, based on global row/column index comparisons.
virtual void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const =0
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
virtual void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const =0
Extract a const, non-persisting view of global indices in a specified row of the matrix.
Xpetra::CrsMatrixFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps > CrsMatrixFactory