Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 {
80  template <class Scalar,
81  class LocalOrdinal,
82  class GlobalOrdinal,
83  class Node>
84  class RowMatrix :
85  virtual public Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
86  virtual public SrcDistObject,
87  public Packable<char, LocalOrdinal> {
88  public:
90 
91 
93  typedef Scalar scalar_type;
95  typedef LocalOrdinal local_ordinal_type;
97  typedef GlobalOrdinal global_ordinal_type;
99  typedef Node node_type;
100 
107 
109 
111 
113  virtual ~RowMatrix();
114 
116 
118 
120  virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const = 0;
121 
122 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
123  virtual TPETRA_DEPRECATED Teuchos::RCP<Node> getNode() const = 0;
125 #endif // TPETRA_ENABLE_DEPRECATED_CODE
126 
128  virtual Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > getRowMap() const = 0;
129 
131  virtual Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Node> > getColMap() const = 0;
132 
134  virtual Teuchos::RCP<const RowGraph<LocalOrdinal,GlobalOrdinal,Node> > getGraph() const = 0;
135 
137  virtual global_size_t getGlobalNumRows() const = 0;
138 
140  virtual global_size_t getGlobalNumCols() const = 0;
141 
143  virtual size_t getNodeNumRows() const = 0;
144 
150  virtual size_t getNodeNumCols() const = 0;
151 
153  virtual GlobalOrdinal getIndexBase() const = 0;
154 
156  virtual global_size_t getGlobalNumEntries() const = 0;
157 
159  virtual size_t getNodeNumEntries() const = 0;
160 
170  virtual size_t getNumEntriesInGlobalRow (GlobalOrdinal globalRow) const = 0;
171 
181  virtual size_t getNumEntriesInLocalRow (LocalOrdinal localRow) const = 0;
182 
191  virtual size_t getGlobalMaxNumRowEntries () const = 0;
192 
201  virtual size_t getNodeMaxNumRowEntries () const = 0;
202 
204  virtual bool hasColMap () const = 0;
205 
215  virtual bool isLocallyIndexed() const = 0;
216 
226  virtual bool isGloballyIndexed() const = 0;
227 
229  virtual bool isFillComplete() const = 0;
230 
232  virtual bool supportsRowViews() const = 0;
233 
234 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
235  virtual global_size_t TPETRA_DEPRECATED getGlobalNumDiags () const = 0;
244 
253  virtual size_t TPETRA_DEPRECATED getNodeNumDiags () const = 0;
254 
265  virtual bool TPETRA_DEPRECATED isLowerTriangular () const = 0;
266 
277  virtual bool TPETRA_DEPRECATED isUpperTriangular () const = 0;
278 #endif // TPETRA_ENABLE_DEPRECATED_CODE
279 
281 
283 
304  virtual void
305  getGlobalRowCopy (GlobalOrdinal GlobalRow,
306  const Teuchos::ArrayView<GlobalOrdinal> &Indices,
307  const Teuchos::ArrayView<Scalar> &Values,
308  size_t &NumEntries) const = 0;
309 
330  virtual void
331  getLocalRowCopy (LocalOrdinal LocalRow,
332  const Teuchos::ArrayView<LocalOrdinal> &Indices,
333  const Teuchos::ArrayView<Scalar> &Values,
334  size_t &NumEntries) const = 0;
335 
360  virtual void
361  getGlobalRowView (GlobalOrdinal GlobalRow,
362  Teuchos::ArrayView<const GlobalOrdinal> &indices,
363  Teuchos::ArrayView<const Scalar> &values) const = 0;
364 
389  virtual void
390  getLocalRowView (LocalOrdinal LocalRow,
391  Teuchos::ArrayView<const LocalOrdinal>& indices,
392  Teuchos::ArrayView<const Scalar>& values) const = 0;
393 
420  virtual LocalOrdinal
421  getLocalRowViewRaw (const LocalOrdinal lclRow,
422  LocalOrdinal& numEnt,
423  const LocalOrdinal*& lclColInds,
424  const Scalar*& vals) const;
425 
438 
440 
442 
448 
454 
463  virtual mag_type getFrobeniusNorm() const = 0;
464 
516  virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
517  add (const Scalar& alpha,
519  const Scalar& beta,
520  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& domainMap = Teuchos::null,
521  const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& rangeMap = Teuchos::null,
522  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
524 
526  private:
527  bool
528  packRow (char* const numEntOut,
529  char* const valOut,
530  char* const indOut,
531  const size_t numEnt,
532  const LocalOrdinal lclRow) const;
533 
534  // TODO (mfh 25 Jan 2015) Could just make this "protected" and let
535  // CrsMatrix use it, since it's exactly the same there.
536  void
537  allocatePackSpace (Teuchos::Array<char>& exports,
538  size_t& totalNumEntries,
539  const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs) const;
540 
545  void
546  packImpl (const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
547  Teuchos::Array<char>& exports,
548  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
549  size_t& constantNumPackets,
550  Distributor& distor) const;
551 
552 
553  public:
562  virtual void
563  pack (const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
564  Teuchos::Array<char>& exports,
565  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
566  size_t& constantNumPackets,
567  Distributor& distor) const;
569  }; // class RowMatrix
570 } // namespace Tpetra
571 
572 #endif // TPETRA_ROWMATRIX_DECL_HPP
573 
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const =0
The communicator over which this matrix is distributed.
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const =0
The Map that describes the distribution of columns over processes.
virtual bool isLocallyIndexed() const =0
Whether matrix indices are locally indexed.
virtual size_t getNodeMaxNumRowEntries() const =0
Maximum number of entries in any row of the matrix, on this process.
virtual global_size_t getGlobalNumCols() const =0
The global number of columns of this matrix.
virtual GlobalOrdinal getIndexBase() const =0
The index base for global indices in this matrix.
Node node_type
The Kokkos Node type.
virtual size_t getNodeNumRows() const =0
The number of rows owned by the calling process.
virtual void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)=0
Scale the matrix on the right with the given Vector.
virtual size_t getNodeNumCols() const =0
The number of columns needed to apply the forward operator on this node.
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&#39;s entries.
Forward declaration of Tpetra::RowMatrix.
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0
The current number of entries on the calling process in the specified local row.
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.
virtual void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)=0
Scale the matrix on the left with the given Vector.
Abstract base class for sources of an Import or Export.
virtual Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const =0
The RowGraph associated with this matrix.
LocalOrdinal local_ordinal_type
The type of local indices.
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, using &quot;raw&quot; pointers instead of Teuchos::ArrayView.
virtual ~RowMatrix()
Destructor (virtual for memory safety of derived classes).
Forward declaration of Tpetra::RowGraph.
size_t global_size_t
Global size_t object.
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.
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&#39;s entries.
virtual size_t getGlobalMaxNumRowEntries() const =0
Maximum number of entries in any row of the matrix, over all processes.
Abstract interface for operators (e.g., matrices and preconditioners).
GlobalOrdinal global_ordinal_type
The type of global indices.
virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const =0
The current number of entries on the calling process in the specified global row. ...
Sets up and executes a communication plan for a Tpetra DistObject.
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&#39;s data for an Import or Export.
CrsGraphType::global_ordinal_type getGlobalNumDiags(const CrsGraphType &G)
Number of populated diagonal entries in the given sparse graph, over all processes in the graph&#39;s (MP...
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
Abstract base class for objects that can be the source of an Import or Export operation.
Forward declaration of Tpetra::Vector.
virtual void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const =0
Get a copy of the diagonal entries, distributed by the row Map.
virtual bool isFillComplete() const =0
Whether fillComplete() has been called.
virtual global_size_t getGlobalNumEntries() const =0
The global number of stored (structurally nonzero) entries.
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.
Scalar scalar_type
The type of the entries in the sparse matrix.
A parallel distribution of indices over processes.
virtual bool supportsRowViews() const =0
Whether this object implements getLocalRowView() and getGlobalRowView().
A read-only, row-oriented interface to a sparse matrix.
A distributed dense vector.
virtual size_t getNodeNumEntries() const =0
The local number of stored (structurally nonzero) entries.
virtual bool isGloballyIndexed() const =0
Whether matrix indices are globally indexed.
Declaration of Tpetra::Packable.
Abstract base class for objects that can be the source of an Import or Export operation, and that also know how to pack their data to send to the target object.
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::mag_type mag_type
Type of a norm result.
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const =0
The Map that describes the distribution of rows over processes.
virtual bool hasColMap() const =0
Whether this matrix has a well-defined column Map.
virtual global_size_t getGlobalNumRows() const =0
The global number of rows of this matrix.
virtual mag_type getFrobeniusNorm() const =0
The Frobenius norm of the matrix.