Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_Umfpack_FunctionMap.hpp
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 #ifndef AMESOS2_UMFPACK_FUNCTIONMAP_HPP
11 #define AMESOS2_UMFPACK_FUNCTIONMAP_HPP
12 
13 #ifdef HAVE_TEUCHOS_COMPLEX
14 #include <complex>
15 #endif
16 
17 #include "Amesos2_FunctionMap.hpp"
18 #include "Amesos2_Umfpack_TypeMap.hpp"
19 
20 extern "C"
21 {
22  #include "umfpack.h"
23 }
24 
25 namespace Amesos2 {
26 
27  /* ==================== Specializations ====================
28  *
29  * \cond Umfpack_function_specializations
30  */
31 
32  template <>
33  struct FunctionMap<Umfpack,double>
34  {
35  typedef TypeMap<Umfpack,double> type_map;
36 
41  static int umfpack_solve(
42  int sys,
43  const int Ap [ ],
44  const int Ai [ ],
45  const double Ax [ ],
46  double X [ ],
47  const double B [ ],
48  void *Numeric,
49  const double Control [UMFPACK_CONTROL],
50  double Info [UMFPACK_INFO])
51  {
52  return ::umfpack_di_solve(sys, Ap, Ai, Ax, X, B, Numeric, Control, Info);
53  }
54 
55  static int umfpack_numeric(
56  const int Ap [ ],
57  const int Ai [ ],
58  const double Ax [ ],
59  void *Symbolic,
60  void **Numeric,
61  const double Control [UMFPACK_CONTROL],
62  double Info [UMFPACK_INFO])
63  {
64  return ::umfpack_di_numeric(Ap, Ai, Ax, Symbolic, Numeric, Control, Info);
65  }
66 
67  static int umfpack_symbolic(
68  int n_row,
69  int n_col,
70  const int Ap [ ],
71  const int Ai [ ],
72  const double Ax [ ],
73  void **Symbolic,
74  const double Control [UMFPACK_CONTROL],
75  double Info [UMFPACK_INFO])
76  {
77  return ::umfpack_di_symbolic(n_row, n_col, Ap, Ai, Ax, Symbolic, Control, Info);
78  }
79 
80  static void umfpack_defaults(
81  double Control [UMFPACK_CONTROL])
82  {
83  ::umfpack_di_defaults(Control);
84  }
85 
86  static void umfpack_free_numeric(void **Numeric)
87  {
88  return ::umfpack_di_free_numeric(Numeric);
89  }
90 
91  static void umfpack_free_symbolic(void **Symbolic)
92  {
93  return ::umfpack_di_free_symbolic(Symbolic);
94  }
95  };
96 
97 
98 #ifdef HAVE_TEUCHOS_COMPLEX
99 
100  template <>
101  struct FunctionMap<Umfpack,Kokkos::complex<double>>
102  {
103  typedef TypeMap<Umfpack,Kokkos::complex<double>> type_map;
104 
109  static double * stdComplexToUmfpackDoubleConversion(
110  const Kokkos::complex<double> v [ ])
111  {
112  return (double*)(&v[0]);
113  }
114 
115  static int umfpack_solve(
116  int sys,
117  const int Ap [ ],
118  const int Ai [ ],
119  const Kokkos::complex<double> Ax [ ],
120  Kokkos::complex<double> X [ ],
121  const Kokkos::complex<double> B [ ],
122  void *Numeric,
123  const double Control [UMFPACK_CONTROL],
124  double Info [UMFPACK_INFO])
125  {
126  return ::umfpack_zi_solve(sys, Ap, Ai,
127  stdComplexToUmfpackDoubleConversion(Ax), NULL,
128  stdComplexToUmfpackDoubleConversion(X), NULL,
129  stdComplexToUmfpackDoubleConversion(B), NULL,
130  Numeric, Control, Info);
131  }
132 
133  static int umfpack_numeric(
134  const int Ap [ ],
135  const int Ai [ ],
136  const Kokkos::complex<double> Ax [ ],
137  void *Symbolic,
138  void **Numeric,
139  const double Control[UMFPACK_CONTROL],
140  double Info[UMFPACK_INFO])
141  {
142  return ::umfpack_zi_numeric(Ap, Ai, stdComplexToUmfpackDoubleConversion(Ax), NULL, Symbolic, Numeric, Control, Info);
143  }
144 
145  static int umfpack_symbolic(
146  int n_row,
147  int n_col,
148  const int Ap [ ],
149  const int Ai [ ],
150  const Kokkos::complex<double> Ax [ ],
151  void **Symbolic,
152  const double Control [UMFPACK_CONTROL],
153  double Info [UMFPACK_INFO])
154  {
155  return ::umfpack_zi_symbolic(n_row, n_col, Ap, Ai, stdComplexToUmfpackDoubleConversion(Ax), NULL, Symbolic, Control, Info);
156  }
157 
158  static void umfpack_defaults(double Control [UMFPACK_CONTROL])
159  {
160  ::umfpack_zi_defaults(Control);
161  }
162 
163  static void umfpack_free_numeric(void **Numeric)
164  {
165  ::umfpack_zi_free_numeric(Numeric);
166  }
167 
168  static void umfpack_free_symbolic(void **Symbolic)
169  {
170  ::umfpack_zi_free_symbolic(Symbolic);
171  }
172  };
173 
174 #endif // HAVE_TEUCHOS_COMPLEX
175 
176  /* \endcond Umfpack_function_specializations */
177 
178 
179 } // end namespace Amesos2
180 
181 #endif // AMESOS2_UMFPACK_FUNCTIONMAP_HPP
int Ap[]
Column offsets.
Definition: klu2_simple.cpp:52
Declaration of Function mapping class for Amesos2.
int Ai[]
Row values.
Definition: klu2_simple.cpp:54