Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_Cholmod_FunctionMap.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Amesos2: Templated Direct Sparse Solver Package
4 //
5 // Copyright 2011 NTESS and the Amesos2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 
21 #ifndef AMESOS2_CHOLMOD_FUNCTIONMAP_HPP
22 #define AMESOS2_CHOLMOD_FUNCTIONMAP_HPP
23 
24 #ifdef HAVE_TEUCHOS_COMPLEX
25 #include <complex>
26 #endif
27 
28 #include "Amesos2_FunctionMap.hpp"
30 
31 #include "cholmod.h"
32 
33 namespace Amesos2 {
34 
35  template <>
36  struct FunctionMap<Cholmod,double>
37  {
38 
39  static void cholmod_init_sparse(size_t nrow, size_t ncol, size_t nzmax,
40  int sorted, void *p, void *x, void *i,
41  cholmod_sparse *sparse, int cholmod_itype)
42  {
43  sparse->nrow = nrow;
44  sparse->ncol = ncol;
45  sparse->nzmax = nzmax;
46  sparse->stype = 1;
47  sparse->itype = cholmod_itype;
48  sparse->sorted = 0;
49  sparse->packed = 1;
50  sparse->xtype = CHOLMOD_REAL;
51  sparse->dtype = CHOLMOD_DOUBLE;
52  sparse->x = x;
53  sparse->p = p;
54  sparse->i = i;
55  }
56 
57  static void cholmod_init_dense(int nrow, int ncol, int d, void *x,
58  cholmod_dense *dense)
59  {
60  dense->nrow = nrow;
61  dense->ncol = ncol;
62  dense->d = d;
63  dense->xtype = CHOLMOD_REAL;
64  dense->dtype = CHOLMOD_DOUBLE;
65  dense->x = x;
66  dense->nzmax = 0;
67  dense->z = NULL;
68  }
69  };
70 
71  template <>
72  struct FunctionMap<Cholmod,float> // Cholmod does not support float yet
73  {
74  static void cholmod_init_sparse(size_t nrow, size_t ncol, size_t nzmax,
75  int sorted, void *p, void *x, void*i,
76  cholmod_sparse* sparse, int cholmod_itype)
77  {
78  sparse->nrow = nrow;
79  sparse->ncol = ncol;
80  sparse->nzmax = nzmax;
81  sparse->stype = 1;
82  sparse->itype = cholmod_itype;
83  sparse->sorted = 0;
84  sparse->packed = 1;
85  sparse->xtype = CHOLMOD_REAL;
86  sparse->dtype = CHOLMOD_SINGLE;
87  sparse->x = x;
88  sparse->p = p;
89  sparse->i = i;
90  }
91 
92 
93  static void cholmod_init_dense(int nrow, int ncol, int d, void *x,
94  cholmod_dense *dense)
95  {
96  dense->nrow = nrow;
97  dense->ncol = ncol;
98  dense->d = d;
99  dense->xtype = CHOLMOD_REAL;
100  dense->dtype = CHOLMOD_SINGLE;
101  dense->x = x;
102  dense->nzmax = 0;
103  dense->z = NULL;
104  }
105  };
106 
107 #ifdef HAVE_TEUCHOS_COMPLEX
108  template <>
109  struct FunctionMap<Cholmod,Kokkos::complex<double>>
110  {
111 
112  static void cholmod_init_sparse(size_t nrow, size_t ncol, size_t nzmax,
113  int sorted, void *p, void *x, void *i,
114  cholmod_sparse* sparse, int cholmod_itype)
115  {
116  sparse->nrow = nrow;
117  sparse->ncol = ncol;
118  sparse->nzmax = nzmax;
119  sparse->stype = 1;
120  sparse->itype = cholmod_itype;
121  sparse->sorted = 0;
122  sparse->packed = 1;
123  sparse->xtype = CHOLMOD_COMPLEX;
124  sparse->dtype = CHOLMOD_DOUBLE;
125  sparse->x = x;
126  sparse->p = p;
127  sparse->i = i;
128 
129  }
130 
131  static void cholmod_init_dense(int nrow, int ncol, int d, void *x,
132  cholmod_dense *dense)
133  {
134  dense->nrow = nrow;
135  dense->ncol = ncol;
136  dense->d = d;
137  dense->xtype = CHOLMOD_COMPLEX;
138  dense->dtype = CHOLMOD_DOUBLE;
139  dense->x = x;
140  dense->nzmax = 0;
141  dense->z = NULL;
142  }
143  };
144 
145  template <>
146  struct FunctionMap<Cholmod,Kokkos::complex<float>>
147  {
148 
149  static void cholmod_init_sparse(size_t nrow, size_t ncol, size_t nzmax,
150  int sorted, void *p, void *x, void *i,
151  cholmod_sparse* sparse, int cholmod_itype)
152  {
153  sparse->nrow = nrow;
154  sparse->ncol = ncol;
155  sparse->nzmax = nzmax;
156  sparse->stype = 1;
157  sparse->itype = cholmod_itype;
158  sparse->sorted = 0;
159  sparse->packed = 1;
160  sparse->xtype = CHOLMOD_COMPLEX;
161  sparse->dtype = CHOLMOD_SINGLE;
162  sparse->x = x;
163  sparse->p = p;
164  sparse->i = i;
165 
166  }
167 
168  static void cholmod_init_dense(int nrow, int ncol, int d, void *x,
169  cholmod_dense *dense)
170  {
171  dense->nrow = nrow;
172  dense->ncol = ncol;
173  dense->d = d;
174  dense->xtype = CHOLMOD_COMPLEX;
175  dense->dtype = CHOLMOD_SINGLE;
176  dense->x = x;
177  dense->nzmax = 0;
178  dense->z = NULL;
179  }
180  };
181 #endif
182 
183 } // end namespace Amesos2
184 
185 #endif // AMESOS2_CHOLMOD_FUNCTIONMAP_HPP
Declaration of Function mapping class for Amesos2.
Provides definition of Cholmod types as well as conversions and type traits.