Tpetra parallel linear algebra  Version of the Day
Tpetra_RowMatrix_decl.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Tpetra: Templated Linear Algebra Services Package
5 // Copyright (2008) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #ifndef TPETRA_ROWMATRIX_DECL_HPP
43 #define TPETRA_ROWMATRIX_DECL_HPP
44 
45 #include "Tpetra_ConfigDefs.hpp"
46 #include "Tpetra_RowMatrix_fwd.hpp"
47 #include "Tpetra_Vector_fwd.hpp"
48 #include "Tpetra_Operator.hpp"
49 #include "Tpetra_RowGraph_fwd.hpp"
50 #include "Tpetra_Packable.hpp"
51 #include "Tpetra_SrcDistObject.hpp"
52 #include "Teuchos_Describable.hpp"
53 
54 namespace Tpetra {
55 namespace Classes {
81  template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
83  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
85  class RowMatrix :
86  virtual public Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
87  virtual public SrcDistObject,
88  public Packable<char, LocalOrdinal> {
89  public:
91 
92 
94  typedef Scalar scalar_type;
96  typedef LocalOrdinal local_ordinal_type;
98  typedef GlobalOrdinal global_ordinal_type;
100  typedef Node node_type;
101 
108 
110 
112 
114  virtual ~RowMatrix();
115 
117 
119 
121  virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const = 0;
122 
124  virtual Teuchos::RCP<Node> getNode() const = 0;
125 
127  virtual Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > getRowMap() const = 0;
128 
130  virtual Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > getColMap() const = 0;
131 
133  virtual Teuchos::RCP<const RowGraph<LocalOrdinal,GlobalOrdinal,Node> > getGraph() const = 0;
134 
136  virtual global_size_t getGlobalNumRows() const = 0;
137 
139  virtual global_size_t getGlobalNumCols() const = 0;
140 
142  virtual size_t getNodeNumRows() const = 0;
143 
149  virtual size_t getNodeNumCols() const = 0;
150 
152  virtual GlobalOrdinal getIndexBase() const = 0;
153 
155  virtual global_size_t getGlobalNumEntries() const = 0;
156 
158  virtual size_t getNodeNumEntries() const = 0;
159 
169  virtual size_t getNumEntriesInGlobalRow (GlobalOrdinal globalRow) const = 0;
170 
180  virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const = 0;
181 
190  virtual global_size_t TPETRA_DEPRECATED getGlobalNumDiags () const = 0;
191 
200  virtual size_t TPETRA_DEPRECATED getNodeNumDiags () const = 0;
201 
210  virtual size_t getGlobalMaxNumRowEntries () const = 0;
211 
220  virtual size_t getNodeMaxNumRowEntries () const = 0;
221 
223  virtual bool hasColMap () const = 0;
224 
235  virtual bool TPETRA_DEPRECATED isLowerTriangular () const = 0;
236 
247  virtual bool TPETRA_DEPRECATED isUpperTriangular () const = 0;
248 
258  virtual bool isLocallyIndexed() const = 0;
259 
269  virtual bool isGloballyIndexed() const = 0;
270 
272  virtual bool isFillComplete() const = 0;
273 
275  virtual bool supportsRowViews() const = 0;
276 
278 
280 
301  virtual void
302  getGlobalRowCopy (GlobalOrdinal GlobalRow,
303  const Teuchos::ArrayView<GlobalOrdinal> &Indices,
304  const Teuchos::ArrayView<Scalar> &Values,
305  size_t &NumEntries) const = 0;
306 
327  virtual void
328  getLocalRowCopy (LocalOrdinal LocalRow,
329  const Teuchos::ArrayView<LocalOrdinal> &Indices,
330  const Teuchos::ArrayView<Scalar> &Values,
331  size_t &NumEntries) const = 0;
332 
357  virtual void
358  getGlobalRowView (GlobalOrdinal GlobalRow,
359  Teuchos::ArrayView<const GlobalOrdinal> &indices,
360  Teuchos::ArrayView<const Scalar> &values) const = 0;
361 
386  virtual void
387  getLocalRowView (LocalOrdinal LocalRow,
388  Teuchos::ArrayView<const LocalOrdinal>& indices,
389  Teuchos::ArrayView<const Scalar>& values) const = 0;
390 
417  virtual LocalOrdinal
418  getLocalRowViewRaw (const LocalOrdinal lclRow,
419  LocalOrdinal& numEnt,
420  const LocalOrdinal*& lclColInds,
421  const Scalar*& vals) const;
422 
435 
437 
439 
445 
451 
460  virtual mag_type getFrobeniusNorm() const = 0;
461 
513  virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
514  add (const Scalar& alpha,
516  const Scalar& beta,
517  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& domainMap = Teuchos::null,
518  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& rangeMap = Teuchos::null,
519  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
521 
523  private:
524  bool
525  packRow (char* const numEntOut,
526  char* const valOut,
527  char* const indOut,
528  const size_t numEnt,
529  const LocalOrdinal lclRow) const;
530 
531  // TODO (mfh 25 Jan 2015) Could just make this "protected" and let
532  // CrsMatrix use it, since it's exactly the same there.
533  void
534  allocatePackSpace (Teuchos::Array<char>& exports,
535  size_t& totalNumEntries,
536  const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs) const;
537 
542  void
543  packImpl (const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
544  Teuchos::Array<char>& exports,
545  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
546  size_t& constantNumPackets,
547  Distributor& distor) const;
548 
549 
550  public:
559  virtual void
560  pack (const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
561  Teuchos::Array<char>& exports,
562  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
563  size_t& constantNumPackets,
564  Distributor& distor) const;
566  }; // class RowMatrix
567 } // namespace Classes
568 } // namespace Tpetra
569 
570 #endif // TPETRA_ROWMATRIX_DECL_HPP
571 
Tpetra::Classes::RowMatrix::getGlobalNumRows
virtual global_size_t getGlobalNumRows() const =0
The global number of rows of this matrix.
Tpetra::Classes::RowMatrix::isUpperTriangular
virtual bool TPETRA_DEPRECATED isUpperTriangular() const =0
Whether the matrix is locally upper triangular.
Tpetra::Classes::RowMatrix::getComm
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const =0
The communicator over which this matrix is distributed.
Tpetra::Classes::RowMatrix::isLocallyIndexed
virtual bool isLocallyIndexed() const =0
Whether matrix indices are locally indexed.
Tpetra::Classes::RowMatrix::getColMap
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const =0
The Map that describes the distribution of columns over processes.
Tpetra::Classes::RowMatrix::getGlobalRowCopy
virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow, const Teuchos::ArrayView< GlobalOrdinal > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const =0
Get a copy of the given global row's entries.
Tpetra::Details::DefaultTypes::node_type
::Kokkos::Compat::KokkosDeviceWrapperNode< execution_space > node_type
Default value of Node template parameter.
Definition: Tpetra_Details_DefaultTypes.hpp:105
Tpetra::Classes::RowMatrix::getNode
virtual Teuchos::RCP< Node > getNode() const =0
The Kokkos Node instance.
Tpetra::Classes::RowMatrix::node_type
Node node_type
The Kokkos Node type.
Definition: Tpetra_RowMatrix_decl.hpp:100
Tpetra_RowGraph_fwd.hpp
Forward declaration of Tpetra::RowGraph.
Tpetra::Classes::RowMatrix::leftScale
virtual void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)=0
Scale the matrix on the left with the given Vector.
Tpetra::Classes::RowMatrix::getNodeMaxNumRowEntries
virtual size_t getNodeMaxNumRowEntries() const =0
Maximum number of entries in any row of the matrix, on this process.
Tpetra::Classes::RowMatrix::isLowerTriangular
virtual bool TPETRA_DEPRECATED isLowerTriangular() const =0
Whether the matrix is locally lower triangular.
Tpetra::Classes::RowMatrix::add
virtual Teuchos::RCP< RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > add(const Scalar &alpha, const RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, 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) const
Return a new RowMatrix which is the result of beta*this + alpha*A.
Definition: Tpetra_RowMatrix_def.hpp:58
Tpetra::Classes::RowMatrix::global_ordinal_type
GlobalOrdinal global_ordinal_type
The type of global indices.
Definition: Tpetra_RowMatrix_decl.hpp:98
Tpetra::Classes::RowMatrix::getIndexBase
virtual GlobalOrdinal getIndexBase() const =0
The index base for global indices in this matrix.
Tpetra::Classes::RowMatrix::~RowMatrix
virtual ~RowMatrix()
Destructor (virtual for memory safety of derived classes).
Definition: Tpetra_RowMatrix_def.hpp:53
Tpetra::Classes::Packable
Abstract base class for objects that can be the source of an Import or Export operation,...
Definition: Tpetra_Packable.hpp:101
Tpetra::Classes::RowMatrix::getNodeNumCols
virtual size_t getNodeNumCols() const =0
The number of columns needed to apply the forward operator on this node.
Tpetra::Classes::RowMatrix::getRowMap
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const =0
The Map that describes the distribution of rows over processes.
Tpetra::Classes::RowMatrix::getNodeNumRows
virtual size_t getNodeNumRows() const =0
The number of rows owned by the calling process.
Tpetra::Classes::RowMatrix::getLocalRowViewRaw
virtual LocalOrdinal getLocalRowViewRaw(const LocalOrdinal lclRow, LocalOrdinal &numEnt, const LocalOrdinal *&lclColInds, const Scalar *&vals) const
Get a constant, nonpersisting, locally indexed view of the given row of the matrix,...
Definition: Tpetra_RowMatrix_def.hpp:598
Tpetra::Classes::MultiVector::mag_type
Kokkos::Details::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
Definition: Tpetra_MultiVector_decl.hpp:443
Tpetra::Classes::RowMatrix::rightScale
virtual void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)=0
Scale the matrix on the right with the given Vector.
Tpetra::Classes::RowMatrix::getLocalRowCopy
virtual void getLocalRowCopy(LocalOrdinal LocalRow, const Teuchos::ArrayView< LocalOrdinal > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const =0
Get a copy of the given local row's entries.
Tpetra::Classes::RowMatrix::getGraph
virtual Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const =0
The RowGraph associated with this matrix.
Tpetra::Classes::RowMatrix::getFrobeniusNorm
virtual mag_type getFrobeniusNorm() const =0
The Frobenius norm of the matrix.
Tpetra::Classes::RowMatrix::local_ordinal_type
LocalOrdinal local_ordinal_type
The type of local indices.
Definition: Tpetra_RowMatrix_decl.hpp:96
Tpetra::Distributor
Sets up and executes a communication plan for a Tpetra DistObject.
Definition: Tpetra_Distributor.hpp:188
Tpetra::Classes::RowMatrix::getNumEntriesInGlobalRow
virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const =0
The current number of entries on the calling process in the specified global row.
Tpetra::Classes::RowMatrix::getGlobalMaxNumRowEntries
virtual size_t getGlobalMaxNumRowEntries() const =0
Maximum number of entries in any row of the matrix, over all processes.
Tpetra::Classes::RowMatrix::hasColMap
virtual bool hasColMap() const =0
Whether this matrix has a well-defined column Map.
Tpetra_RowMatrix_fwd.hpp
Forward declaration of Tpetra::RowMatrix.
Tpetra::Classes::RowMatrix::getNodeNumDiags
virtual size_t TPETRA_DEPRECATED getNodeNumDiags() const =0
Number of diagonal entries in the matrix's graph, on the calling process.
Tpetra::Classes::RowMatrix::getGlobalNumDiags
virtual global_size_t TPETRA_DEPRECATED getGlobalNumDiags() const =0
Number of diagonal entries in the matrix's graph, over all processes in the matrix's communicator.
Tpetra_SrcDistObject.hpp
Abstract base class for sources of an Import or Export.
Tpetra::Classes::RowMatrix::isGloballyIndexed
virtual bool isGloballyIndexed() const =0
Whether matrix indices are globally indexed.
Tpetra::Details::DefaultTypes::local_ordinal_type
int local_ordinal_type
Default value of Scalar template parameter.
Definition: Tpetra_Details_DefaultTypes.hpp:72
Tpetra::Classes::RowMatrix::isFillComplete
virtual bool isFillComplete() const =0
Whether fillComplete() has been called.
Tpetra::Classes::RowMatrix::getGlobalRowView
virtual void getGlobalRowView(GlobalOrdinal GlobalRow, Teuchos::ArrayView< const GlobalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const =0
Get a constant, nonpersisting, globally indexed view of the given row of the matrix.
Tpetra::Classes::RowMatrix::supportsRowViews
virtual bool supportsRowViews() const =0
Whether this object implements getLocalRowView() and getGlobalRowView().
Tpetra::Classes::RowMatrix::mag_type
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::mag_type mag_type
Type of a norm result.
Definition: Tpetra_RowMatrix_decl.hpp:107
Tpetra::Classes::RowMatrix::getLocalRowView
virtual void getLocalRowView(LocalOrdinal LocalRow, Teuchos::ArrayView< const LocalOrdinal > &indices, Teuchos::ArrayView< const Scalar > &values) const =0
Get a constant, nonpersisting, locally indexed view of the given row of the matrix.
Tpetra::Classes::RowMatrix::pack
virtual void pack(const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Teuchos::Array< char > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets, Distributor &distor) const
Pack this object's data for an Import or Export.
Definition: Tpetra_RowMatrix_def.hpp:298
Tpetra::Classes::Map
A parallel distribution of indices over processes.
Definition: Tpetra_Map_decl.hpp:247
Tpetra_Vector_fwd.hpp
Forward declaration of Tpetra::Vector.
Tpetra::Classes::RowMatrix::scalar_type
Scalar scalar_type
The type of the entries in the sparse matrix.
Definition: Tpetra_RowMatrix_decl.hpp:94
Tpetra::Classes::RowMatrix::getGlobalNumEntries
virtual global_size_t getGlobalNumEntries() const =0
The global number of stored (structurally nonzero) entries.
Tpetra::Classes::RowMatrix::getGlobalNumCols
virtual global_size_t getGlobalNumCols() const =0
The global number of columns of this matrix.
Tpetra::global_size_t
size_t global_size_t
Global size_t object.
Definition: Tpetra_ConfigDefs.hpp:109
Tpetra::Classes::RowMatrix::getNumEntriesInLocalRow
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0
The current number of entries on the calling process in the specified local row.
Tpetra
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Tpetra::Classes::RowMatrix::getNodeNumEntries
virtual size_t getNodeNumEntries() const =0
The local number of stored (structurally nonzero) entries.
Tpetra::SrcDistObject
Abstract base class for objects that can be the source of an Import or Export operation.
Definition: Tpetra_SrcDistObject.hpp:89
Tpetra::Classes::RowMatrix::getLocalDiagCopy
virtual void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const =0
Get a copy of the diagonal entries, distributed by the row Map.
Tpetra_Packable.hpp
Declaration of Tpetra::Packable.
Tpetra::Classes::Operator
Abstract interface for operators (e.g., matrices and preconditioners).
Definition: Tpetra_Operator.hpp:86
Tpetra::Classes::RowMatrix
A read-only, row-oriented interface to a sparse matrix.
Definition: Tpetra_RowMatrix_decl.hpp:85
Tpetra::Classes::Vector
A distributed dense vector.
Definition: Tpetra_Vector_decl.hpp:82