Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_TpetraRowMatrix_AbstractMatrixAdapter_decl.hpp
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Amesos2: Templated Direct Sparse Solver Package
6 // Copyright 2011 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 Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 //
42 // @HEADER
43 
44 
45 #ifndef AMESOS2_TPETRAROWMATRIX_MATRIXADAPTER_DECL_HPP
46 #define AMESOS2_TPETRAROWMATRIX_MATRIXADAPTER_DECL_HPP
47 
48 #include "Amesos2_config.h"
49 
50 #include <Teuchos_ArrayView.hpp>
51 #include <Tpetra_CrsMatrix.hpp>
52 
53 #include "Amesos2_AbstractConcreteMatrixAdapter.hpp"
54 #include "Amesos2_Util.hpp"
55 
56 namespace Amesos2 {
57 
58  template <class Matrix> class MatrixAdapter;
59 
60  using Teuchos::RCP;
61 
76  template <typename Scalar,
77  typename LocalOrdinal,
78  typename GlobalOrdinal,
79  typename Node,
80  class DerivedMat >
81  class AbstractConcreteMatrixAdapter< Tpetra::RowMatrix<Scalar,
82  LocalOrdinal,
83  GlobalOrdinal,
84  Node >,
85  DerivedMat >
86  : public MatrixAdapter< DerivedMat > {
87  public:
88  // Give our base class access to our private implementation functions
89  friend class MatrixAdapter< DerivedMat >;
90 
91  typedef Tpetra::RowMatrix<Scalar,
92  LocalOrdinal,
93  GlobalOrdinal,
94  Node > matrix_t;
95 
96  typedef Scalar scalar_t;
97  typedef LocalOrdinal local_ordinal_t;
98  typedef GlobalOrdinal global_ordinal_t;
99  typedef Node node_t;
100 
101  private:
103 
104  public:
105  typedef typename super_t::global_size_t global_size_t;
106 
107  typedef AbstractConcreteMatrixAdapter<matrix_t,
108  DerivedMat> type;
109 
112  typedef row_access major_access;
113 
114  AbstractConcreteMatrixAdapter(RCP<matrix_t> m);
115 
116  public: // these functions should technically be private
117 
118  // implementation functions
119  void getGlobalRowCopy_impl(global_ordinal_t row,
120  const Teuchos::ArrayView<global_ordinal_t>& indices,
121  const Teuchos::ArrayView<scalar_t>& vals,
122  size_t& nnz) const;
123 
124  void getGlobalColCopy_impl(global_ordinal_t col,
125  const Teuchos::ArrayView<global_ordinal_t>& indices,
126  const Teuchos::ArrayView<scalar_t>& vals,
127  size_t& nnz) const;
128 
129  global_size_t getGlobalNNZ_impl() const;
130 
131  size_t getLocalNNZ_impl() const;
132 
133  size_t getMaxRowNNZ_impl() const;
134 
135  size_t getMaxColNNZ_impl() const;
136 
137  size_t getGlobalRowNNZ_impl(global_ordinal_t row) const;
138 
139  size_t getLocalRowNNZ_impl(local_ordinal_t row) const;
140 
141  size_t getGlobalColNNZ_impl(global_ordinal_t col) const;
142 
143  size_t getLocalColNNZ_impl(local_ordinal_t col) const;
144 
145  global_size_t getGlobalNumRows_impl() const;
146 
147  global_size_t getGlobalNumCols_impl() const;
148 
149  // Brunt of the work is put on the implementation for converting
150  // their maps to a Tpetra::Map
151  const RCP<const Tpetra::Map<local_ordinal_t,
152  global_ordinal_t,
153  node_t> >
154  getMap_impl() const;
155 
156  const RCP<const Tpetra::Map<local_ordinal_t,
157  global_ordinal_t,
158  node_t> >
159  getRowMap_impl() const;
160 
161  const RCP<const Tpetra::Map<local_ordinal_t,
162  global_ordinal_t,
163  node_t> >
164  getColMap_impl() const;
165 
166  const RCP<const Teuchos::Comm<int> > getComm_impl() const;
167 
168  bool isLocallyIndexed_impl() const;
169 
170  bool isGloballyIndexed_impl() const;
171 
172  // Because instantiation of the subclasses could be wildly
173  // different (cf subclasses of Tpetra::CrsMatrix), this method
174  // hands off implementation to the adapter for the subclass
175  RCP<const super_t> get_impl(const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map, EDistribution distribution = ROOTED) const;
176 
177  typename super_t::spmtx_ptr_t getSparseRowPtr() const;
178 
179  typename super_t::spmtx_idx_t getSparseColInd() const;
180 
181  typename super_t::spmtx_vals_t getSparseValues() const;
182 
183  };
184 
185 } // end namespace Amesos2
186 
187 #endif // AMESOS2_TPETRAROWMATRIX_MATRIXADAPTER_DECL_HPP
Utility functions for Amesos2.
Indicates that the object of an adapter provides row access to its data.
Definition: Amesos2_TypeDecl.hpp:100
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:89
Indicates that the concrete class can use the generic getC{c|r}s methods implemented in MatrixAdapter...
Definition: Amesos2_TypeDecl.hpp:91
EDistribution
Definition: Amesos2_TypeDecl.hpp:123