Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_MatrixTraits.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_MATRIXTRAITS_HPP
46 #define AMESOS2_MATRIXTRAITS_HPP
47 
48 #include "Amesos2_config.h"
49 
50 #include <Tpetra_CrsMatrix.hpp>
51 
52 
53 #ifdef HAVE_TPETRA_INST_INT_INT
54 #ifdef HAVE_AMESOS2_EPETRA
55 # include <Tpetra_DefaultPlatform.hpp>
56 # include <Epetra_RowMatrix.h>
57 # include <Epetra_CrsMatrix.h>
58 // # include <Epetra_MsrMatrix.h>
59 # include <Epetra_VbrMatrix.h>
60 // and perhaps some others later...
61 #endif
62 #endif
63 
64 #include "Amesos2_Util.hpp"
65 
66 namespace Amesos2 {
67 
68  // The declaration
69  template <class Matrix>
70  struct MatrixTraits {};
71 
72  /*******************
73  * Specializations *
74  *******************/
75 
76  template < typename Scalar,
77  typename LocalOrdinal,
78  typename GlobalOrdinal,
79  typename Node >
80  struct MatrixTraits<
81  Tpetra::RowMatrix<Scalar,
82  LocalOrdinal,
83  GlobalOrdinal,
84  Node> > {
85  typedef Scalar scalar_t;
86  typedef LocalOrdinal local_ordinal_t;
87  typedef GlobalOrdinal global_ordinal_t;
88  typedef Node node_t;
89 
90  typedef Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> matrix_type;
91  typedef typename matrix_type::local_matrix_type local_matrix_t;
92  typedef typename matrix_type::local_matrix_type::row_map_type::pointer_type sparse_ptr_type;
93  typedef typename matrix_type::local_matrix_type::index_type::pointer_type sparse_idx_type;
94  typedef typename matrix_type::local_matrix_type::values_type::pointer_type sparse_values_type;
95 
96  typedef row_access major_access;
97  };
98 
99  template < typename Scalar,
100  typename LocalOrdinal,
101  typename GlobalOrdinal,
102  typename Node >
103  struct MatrixTraits<
104  Tpetra::CrsMatrix<Scalar,
105  LocalOrdinal,
106  GlobalOrdinal,
107  Node> > {
108  typedef Scalar scalar_t;
109  typedef LocalOrdinal local_ordinal_t;
110  typedef GlobalOrdinal global_ordinal_t;
111  typedef Node node_t;
112 
113  typedef Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> matrix_type;
114  typedef typename matrix_type::local_matrix_type local_matrix_t;
115  typedef typename matrix_type::local_matrix_type::row_map_type::pointer_type sparse_ptr_type;
116  typedef typename matrix_type::local_matrix_type::index_type::pointer_type sparse_idx_type;
117  typedef typename matrix_type::local_matrix_type::values_type::pointer_type sparse_values_type;
118 
119  typedef row_access major_access;
120  };
121 
122 
123 #ifdef HAVE_TPETRA_INST_INT_INT
124 #ifdef HAVE_AMESOS2_EPETRA
125 
126  template <>
127  struct MatrixTraits<Epetra_RowMatrix> {
128  typedef double scalar_t;
129  typedef int local_ordinal_t;
130  typedef int global_ordinal_t;
131  typedef Tpetra::DefaultPlatform::DefaultPlatformType::NodeType node_t;
132 
133  typedef Epetra_RowMatrix matrix_type;
134  typedef matrix_type local_matrix_t;
135  typedef int* sparse_ptr_type;
136  typedef int* sparse_idx_type;
137  typedef double* sparse_values_type;
138 
139  typedef row_access major_access;
140  };
141 
142  template <>
143  struct MatrixTraits<Epetra_CrsMatrix> {
144  typedef double scalar_t;
145  typedef int local_ordinal_t;
146  typedef int global_ordinal_t;
147  typedef Tpetra::DefaultPlatform::DefaultPlatformType::NodeType node_t;
148 
149  typedef Epetra_CrsMatrix matrix_type;
150  typedef matrix_type local_matrix_t;
151  typedef int* sparse_ptr_type;
152  typedef int* sparse_idx_type;
153  typedef double* sparse_values_type;
154 
155  typedef row_access major_access;
156  };
157 
158  // template <>
159  // struct MatrixTraits<Epetra_MsrMatrix> {
160  // typedef double scalar_t;
161  // typedef int local_ordinal_t;
162  // typedef int global_ordinal_t;
163  // typedef Tpetra::DefaultPlatform::DefaultPlatformType::NodeType node_t;
164 
165  // typedef row_access major_access;
166  // };
167 
168  template <>
169  struct MatrixTraits<Epetra_VbrMatrix> {
170  typedef double scalar_t;
171  typedef int local_ordinal_t;
172  typedef int global_ordinal_t;
173  typedef Tpetra::DefaultPlatform::DefaultPlatformType::NodeType node_t;
174 
175  typedef Epetra_VbrMatrix matrix_type;
176  typedef matrix_type local_matrix_t;
177  typedef int* sparse_ptr_type;
178  typedef int* sparse_idx_type;
179  typedef double* sparse_values_type;
180 
181  typedef row_access major_access;
182  };
183 
184 #endif
185 #endif
186 
187 }
188 
189 #endif // AMESOS2_MATRIXTRAITS_HPP
Utility functions for Amesos2.
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48