Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 // 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_MATRIX_HPP
50 #define XPETRA_MATRIX_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 #include "Xpetra_MatrixView.hpp"
62 #include "Xpetra_Operator.hpp"
63 #include "Xpetra_StridedMap.hpp"
64 #include "Xpetra_StridedMapFactory.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,
95  class GlobalOrdinal,
97  class Matrix : public Xpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > {
103 
104  public:
105  typedef Scalar scalar_type;
106  typedef LocalOrdinal local_ordinal_type;
107  typedef GlobalOrdinal global_ordinal_type;
108  typedef Node node_type;
109 
110 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
111 #ifdef HAVE_XPETRA_TPETRA
112  typedef typename CrsMatrix::local_matrix_type local_matrix_type;
113 #endif
114 #endif
115 
117 
118 
119  Matrix() { }
120 
122  virtual ~Matrix() { }
123 
125 
127 
128  void CreateView(viewLabel_t viewLabel, const RCP<const Map> & rowMap, const RCP<const Map> & colMap) {
129  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == true, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.CreateView(): a view labeled '" + viewLabel + "' already exist.");
130  RCP<MatrixView> view = rcp(new MatrixView(rowMap, colMap));
131  operatorViewTable_.put(viewLabel, view);
132  }
133 
134  // JG TODO: why this is a member function??
135  void CreateView(const viewLabel_t viewLabel, const RCP<const Matrix>& A, bool transposeA = false, const RCP<const Matrix>& B = Teuchos::null, bool transposeB = false) {
136  RCP<const Map> domainMap = Teuchos::null;
137  RCP<const Map> rangeMap = Teuchos::null;
138 
139  const size_t blkSize = 1;
140  std::vector<size_t> stridingInfo(1, blkSize);
141  LocalOrdinal stridedBlockId = -1;
142 
143 
144  if (A->IsView(viewLabel)) {
145  rangeMap = transposeA ? A->getColMap(viewLabel) : A->getRowMap(viewLabel);
146  domainMap = transposeA ? A->getRowMap(viewLabel) : A->getColMap(viewLabel); // will be overwritten if B != Teuchos::null
147 
148  } else {
149  rangeMap = transposeA ? A->getDomainMap() : A->getRangeMap();
150  domainMap = transposeA ? A->getRangeMap() : A->getDomainMap();
151 
152  if (viewLabel == "stridedMaps") {
153  rangeMap = Xpetra::StridedMapFactory<LocalOrdinal, GlobalOrdinal, Node>::Build(rangeMap, stridingInfo, stridedBlockId);
154  domainMap = Xpetra::StridedMapFactory<LocalOrdinal, GlobalOrdinal, Node>::Build(domainMap, stridingInfo, stridedBlockId);
155  }
156  }
157 
158  if (B != Teuchos::null ) {
159  // B has strided Maps
160 
161  if (B->IsView(viewLabel)) {
162  domainMap = transposeB ? B->getRowMap(viewLabel) : B->getColMap(viewLabel);
163 
164  } else {
165  domainMap = transposeB ? B->getRangeMap() : B->getDomainMap();
166 
167  if (viewLabel == "stridedMaps")
168  domainMap = Xpetra::StridedMapFactory<LocalOrdinal, GlobalOrdinal, Node>::Build(domainMap, stridingInfo, stridedBlockId);
169  }
170  }
171 
172 
173  if (IsView(viewLabel))
174  RemoveView(viewLabel);
175 
176  CreateView(viewLabel, rangeMap, domainMap);
177  }
178 
180  void PrintViews(Teuchos::FancyOStream &out) const {
181  int last = out.getOutputToRootOnly();
182  Teuchos::OSTab tab(out);
183  out.setOutputToRootOnly(0);
184  Teuchos::Array<viewLabel_t> viewLabels;
185  Teuchos::Array<RCP<MatrixView> > viewList;
186  operatorViewTable_.arrayify(viewLabels,viewList);
187  out << "views associated with this operator" << std::endl;
188  for (int i=0; i<viewLabels.size(); ++i)
189  out << viewLabels[i] << std::endl;
190  out.setOutputToRootOnly(last);
191  }
192 
193 
194  void RemoveView(const viewLabel_t viewLabel) {
195  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.RemoveView(): view '" + viewLabel + "' does not exist.");
196  TEUCHOS_TEST_FOR_EXCEPTION(viewLabel == GetDefaultViewLabel(), Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.RemoveView(): view '" + viewLabel + "' is the default view and cannot be removed.");
197  operatorViewTable_.remove(viewLabel);
198  }
199 
200  const viewLabel_t SwitchToView(const viewLabel_t viewLabel) {
201  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.SwitchToView(): view '" + viewLabel + "' does not exist.");
202  viewLabel_t oldViewLabel = GetCurrentViewLabel();
203  currentViewLabel_ = viewLabel;
204  return oldViewLabel;
205  }
206 
207  bool IsView(const viewLabel_t viewLabel) const {
208  return operatorViewTable_.containsKey(viewLabel);
209  }
210 
212 
214 
216 
218 
220 
221 
223 
234  virtual void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal> &cols, const ArrayView<const Scalar> &vals) = 0;
235 
237 
244  virtual void insertLocalValues(LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &cols, const ArrayView<const Scalar> &vals) = 0;
245 
247 
252  virtual void replaceGlobalValues(GlobalOrdinal globalRow,
253  const ArrayView<const GlobalOrdinal> &cols,
254  const ArrayView<const Scalar> &vals) = 0;
255 
257 
260  virtual void replaceLocalValues(LocalOrdinal localRow,
261  const ArrayView<const LocalOrdinal> &cols,
262  const ArrayView<const Scalar> &vals) = 0;
263 
265  virtual void setAllToScalar(const Scalar &alpha)= 0;
266 
268  virtual void scale(const Scalar &alpha)= 0;
269 
271 
273 
274 
283  virtual void resumeFill(const RCP< ParameterList > &params=null) = 0;
284 
296  virtual void fillComplete(const RCP<const Map> &domainMap, const RCP<const Map> &rangeMap, const RCP<ParameterList> &params = null) =0;
297 
311  //TODO : Get ride of "Tpetra"::OptimizeOption
312  virtual void fillComplete(const RCP<ParameterList> &params=null) =0;
313 
315 
317 
318 
320  virtual const RCP<const Map> & getRowMap() const { return getRowMap(GetCurrentViewLabel()); }
321 
323  virtual const RCP<const Map> & getRowMap(viewLabel_t viewLabel) const {
324  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.GetRowMap(): view '" + viewLabel + "' does not exist.");
325  return operatorViewTable_.get(viewLabel)->GetRowMap();
326  }
327 
330  virtual const RCP<const Map> & getColMap() const { return getColMap(GetCurrentViewLabel()); }
331 
333  virtual const RCP<const Map> & getColMap(viewLabel_t viewLabel) const {
334  TEUCHOS_TEST_FOR_EXCEPTION(operatorViewTable_.containsKey(viewLabel) == false, Xpetra::Exceptions::RuntimeError, "Xpetra::Matrix.GetColMap(): view '" + viewLabel + "' does not exist.");
335  return operatorViewTable_.get(viewLabel)->GetColMap();
336  }
337 
339 
341  virtual global_size_t getGlobalNumRows() const =0;
342 
344 
346  virtual global_size_t getGlobalNumCols() const =0;
347 
349  virtual size_t getNodeNumRows() const =0;
350 
352  virtual global_size_t getGlobalNumEntries() const =0;
353 
355  virtual size_t getNodeNumEntries() const =0;
356 
358 
359  virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0;
360 
362 
363  virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const =0;
364 
366 
368  virtual size_t getGlobalMaxNumRowEntries() const =0;
369 
371 
373  virtual size_t getNodeMaxNumRowEntries() const =0;
374 
376  virtual bool isLocallyIndexed() const =0;
377 
379  virtual bool isGloballyIndexed() const =0;
380 
382  virtual bool isFillComplete() const =0;
383 
385 
397  virtual void getLocalRowCopy(LocalOrdinal LocalRow,
398  const ArrayView<LocalOrdinal> &Indices,
399  const ArrayView<Scalar> &Values,
400  size_t &NumEntries
401  ) const =0;
402 
404 
413  virtual void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &indices, ArrayView<const Scalar> &values) const =0;
414 
416 
425  virtual void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal> &indices, ArrayView<const Scalar> &values) const =0;
426 
428 
431 
433  virtual typename ScalarTraits<Scalar>::magnitudeType getFrobeniusNorm() const = 0;
434 
437 
440 
441 
443  virtual bool haveGlobalConstants() const = 0;
444 
445 
447 
449 
450 
452 
461  //TODO virtual=0 // TODO: Add default parameters ?
462 // 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;
463 
465 
467  //{@
468 
470  virtual const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const = 0;
471 
472  // TODO: first argument of doImport/doExport should be a Xpetra::DistObject
473 
475  virtual void doImport(const Matrix &source,
477 
479  virtual void doExport(const Matrix &dest,
481 
483  virtual void doImport(const Matrix &source,
485 
487  virtual void doExport(const Matrix &dest,
489 
490  // @}
491 
493 
494 
495  // TODO: describe of views can be done here
496 
497  // /** \brief Return a simple one-line description of this object. */
498  // virtual std::string description() const =0;
499 
500  // /** \brief Print the object with some verbosity level to an FancyOStream object. */
501  // virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const =0;
502 
504 
505 
507 
508 
510  virtual std::string description() const =0;
511 
513  virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const =0;
515 
517 
518  virtual void setObjectLabel( const std::string &objectLabel ) =0;
520 
521  // JG: Added:
522 
524  virtual bool hasCrsGraph() const =0;
525 
527  virtual RCP<const CrsGraph> getCrsGraph() const =0;
528 
529  // ----------------------------------------------------------------------------------
530  // "TEMPORARY" VIEW MECHANISM
537  void SetFixedBlockSize(LocalOrdinal blksize, GlobalOrdinal offset=0) {
538 
539  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
540 
541  std::vector<size_t> stridingInfo;
542  stridingInfo.push_back(Teuchos::as<size_t>(blksize));
543  LocalOrdinal stridedBlockId = -1;
544 
545  RCP<const Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node> > stridedRangeMap = Xpetra::StridedMapFactory<LocalOrdinal, GlobalOrdinal, Node>::Build(
546  this->getRangeMap(),
547  stridingInfo,
548  stridedBlockId,
549  offset
550  );
552  this->getDomainMap(),
553  stridingInfo,
554  stridedBlockId,
555  offset
556  );
557 
558  if(IsView("stridedMaps") == true) RemoveView("stridedMaps");
559  CreateView("stridedMaps", stridedRangeMap, stridedDomainMap);
560  }
561 
562  //==========================================================================
563 
564  LocalOrdinal GetFixedBlockSize() const {
565  if(IsView("stridedMaps")==true) {
566  Teuchos::RCP<const StridedMap<LocalOrdinal, GlobalOrdinal, Node> > rangeMap = Teuchos::rcp_dynamic_cast<const StridedMap<LocalOrdinal, GlobalOrdinal, Node> >(getRowMap("stridedMaps"));
567  Teuchos::RCP<const StridedMap<LocalOrdinal, GlobalOrdinal, Node> > domainMap = Teuchos::rcp_dynamic_cast<const StridedMap<LocalOrdinal, GlobalOrdinal, Node> >(getColMap("stridedMaps"));
568  TEUCHOS_TEST_FOR_EXCEPTION(rangeMap == Teuchos::null, Exceptions::BadCast, "Xpetra::Matrix::GetFixedBlockSize(): rangeMap is not of type StridedMap");
569  TEUCHOS_TEST_FOR_EXCEPTION(domainMap == Teuchos::null, Exceptions::BadCast, "Xpetra::Matrix::GetFixedBlockSize(): domainMap is not of type StridedMap");
570  TEUCHOS_TEST_FOR_EXCEPTION(domainMap->getFixedBlockSize() != rangeMap->getFixedBlockSize(), Exceptions::RuntimeError, "Xpetra::Matrix::GetFixedBlockSize(): block size of rangeMap and domainMap are different.");
571  return Teuchos::as<LocalOrdinal>(domainMap->getFixedBlockSize()); // TODO: why LocalOrdinal?
572  } else
573  //TEUCHOS_TEST_FOR_EXCEPTION(false, Exceptions::RuntimeError, "Xpetra::Matrix::GetFixedBlockSize(): no strided maps available."); // TODO remove this
574  return 1;
575  }; //TODO: why LocalOrdinal?
576 
577  // ----------------------------------------------------------------------------------
578 
579  virtual void SetMaxEigenvalueEstimate(Scalar const &sigma) {
580  operatorViewTable_.get(GetCurrentViewLabel())->SetMaxEigenvalueEstimate(sigma);
581  }
582 
583  // ----------------------------------------------------------------------------------
584 
585  virtual Scalar GetMaxEigenvalueEstimate() const {
586  return operatorViewTable_.get(GetCurrentViewLabel())->GetMaxEigenvalueEstimate();
587  }
588 
589  // ----------------------------------------------------------------------------------
590 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
591 #ifdef HAVE_XPETRA_TPETRA
592  virtual local_matrix_type getLocalMatrix () const = 0;
594 #else
595 #ifdef __GNUC__
596 #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."
597 #endif
598 #endif
599 #endif
600  // ----------------------------------------------------------------------------------
601 
606 
607  protected:
608  Teuchos::Hashtable<viewLabel_t, RCP<MatrixView> > operatorViewTable_; // hashtable storing the operator views (keys = view names, values = views).
609 
610  viewLabel_t defaultViewLabel_; // label of the view associated with inital Matrix construction
611  viewLabel_t currentViewLabel_; // label of the current view
612 
613  }; //class Matrix
614 
615 } //namespace Xpetra
616 
617 #define XPETRA_MATRIX_SHORT
618 #endif //XPETRA_MATRIX_DECL_HPP
virtual void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Insert matrix entries, using local IDs.
virtual size_t getNodeMaxNumRowEntries() const =0
Returns the maximum number of entries across all rows/columns on this node.
virtual size_t getNodeNumRows() const =0
Returns the number of matrix rows owned on the calling node.
virtual size_t getNodeNumEntries() const =0
Returns the local number of entries in this matrix.
virtual global_size_t getGlobalNumRows() const =0
Returns the number of global rows in this matrix.
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.
void RemoveView(const viewLabel_t viewLabel)
virtual global_size_t getGlobalNumCols() const =0
Returns the number of global columns in the matrix.
LocalOrdinal local_ordinal_type
virtual ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const =0
Get Frobenius norm of the matrix.
virtual void resumeFill(const RCP< ParameterList > &params=null)=0
Exception throws to report errors in the internal logical of the program.
virtual size_t getGlobalMaxNumRowEntries() const =0
Returns the maximum number of entries across all rows/columns on all nodes.
Teuchos::Hashtable< viewLabel_t, RCP< MatrixView > > operatorViewTable_
virtual bool isGloballyIndexed() const =0
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
virtual void doExport(const Matrix &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)=0
Export.
virtual const RCP< const Map > & getColMap() const
Returns the Map that describes the column distribution in this matrix. This might be null until fillC...
Exception indicating invalid cast attempted.
virtual const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
Multiplies this matrix by a MultiVector.
virtual void SetMaxEigenvalueEstimate(Scalar const &sigma)
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.
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > CrsMatrix
virtual void setObjectLabel(const std::string &objectLabel)=0
virtual ~Matrix()
Destructor.
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 indices.
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 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...
viewLabel_t defaultViewLabel_
virtual void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Insert matrix entries, using global IDs.
void SetFixedBlockSize(LocalOrdinal blksize, GlobalOrdinal offset=0)
virtual bool haveGlobalConstants() const =0
Returns true if globalConstants have been computed; false otherwise.
virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const =0
Returns the current number of entries in the specified global row.
virtual void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)=0
Right scale matrix using the given vector entries.
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.
bool IsView(const viewLabel_t viewLabel) const
const viewLabel_t & GetCurrentViewLabel() const
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
virtual bool isFillComplete() const =0
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
virtual void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Replace matrix entries, using local IDs.
virtual const RCP< const Map > & getColMap(viewLabel_t viewLabel) const
Returns the Map that describes the column distribution in this matrix.
viewLabel_t currentViewLabel_
const viewLabel_t SwitchToDefaultView()
virtual void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)=0
Left scale matrix using the given vector entries.
void PrintViews(Teuchos::FancyOStream &out) const
Print all of the views associated with the Matrix.
LocalOrdinal GetFixedBlockSize() const
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0
Returns the current number of entries on this node in the specified local row.
std::string viewLabel_t
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > CrsGraph
size_t global_size_t
Global size_t object.
virtual void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Replace matrix entries, using global IDs.
virtual void doImport(const Matrix &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)=0
Import.
virtual RCP< const CrsGraph > getCrsGraph() const =0
Returns the CrsGraph associated with this matrix.
virtual std::string description() const =0
Return a simple one-line description of this object.
virtual bool isLocallyIndexed() const =0
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
virtual Scalar GetMaxEigenvalueEstimate() const
virtual void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const =0
Compute a residual R = B - (*this) * X.
virtual global_size_t getGlobalNumEntries() const =0
Returns the global number of entries in this matrix.
virtual Teuchos::RCP< const Map > getRangeMap() const =0
The Map associated with the range of this operator, which must be compatible with Y...
CombineMode
Xpetra::Combine Mode enumerable type.
static RCP< Xpetra::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)
Map constructor with Xpetra-defined contiguous uniform distribution.
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this 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)
virtual void scale(const Scalar &alpha)=0
Scale the current values of a matrix, this = alpha*this.
const viewLabel_t & GetDefaultViewLabel() const
Xpetra::MatrixView< Scalar, LocalOrdinal, GlobalOrdinal, Node > MatrixView
virtual const RCP< const Map > & getRowMap(viewLabel_t viewLabel) const
Returns the Map that describes the row distribution in this matrix.
virtual void setAllToScalar(const Scalar &alpha)=0
Set all matrix entries equal to scalar.
virtual Teuchos::RCP< const Map > getDomainMap() const =0
The Map associated with the domain of this operator, which must be compatible with X...
Xpetra::CrsMatrixFactory< Scalar, LocalOrdinal, GlobalOrdinal, Node > CrsMatrixFactory
Xpetra-specific matrix class.
Class that stores a strided map.
const viewLabel_t SwitchToView(const viewLabel_t viewLabel)
virtual bool hasCrsGraph() const =0
Supports the getCrsGraph() call.
GlobalOrdinal global_ordinal_type