Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_Superlu_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 
19 #ifndef AMESOS2_SUPERLU_FUNCTIONMAP_HPP
20 #define AMESOS2_SUPERLU_FUNCTIONMAP_HPP
21 
22 #ifdef HAVE_TEUCHOS_COMPLEX
23 #include <complex>
24 #endif
25 
26 #include "Amesos2_FunctionMap.hpp"
28 
29 
30 /* External definitions of the Superlu functions
31  *
32  * Note that we do include the "slu_*defs.h" files provided for each
33  * data-type. This produces linker warnings, but keeps us from
34  * including SuperLU code in our own code (even if only extern
35  * declarations, which would eliminate linker warnings). This is
36  * because there are several declarations (as of SuperLU 4.1) across
37  * these headers which conflict with each other in C linkage. All of
38  * the conflicting functions, on the other hand, we do not care about.
39  */
40 namespace SLU {
41 
42  extern "C" {
43  typedef int int_t;
44 #include "supermatrix.h"
45 #include "slu_util.h"
46 #include "superlu_enum_consts.h"
47 
48 void
49 at_plus_a(
50  const int n, /* number of columns in matrix A. */
51  const int nz, /* number of nonzeros in matrix A */
52  int *colptr, /* column pointer of size n+1 for matrix A. */
53  int *rowind, /* row indices of size nz for matrix A. */
54  int *bnz, /* out - on exit, returns the actual number of
55  nonzeros in matrix A'*A. */
56  int **b_colptr, /* out - size n+1 */
57  int **b_rowind /* out - size *bnz */
58  );
59 
60 
61  namespace S { // single-precision real definitions
62 
63  extern float slangs (char *, SLU::SuperMatrix *);
64 
65  extern void sgscon (char *, SuperMatrix *, SuperMatrix *,
66  float, float *, SuperLUStat_t*, int *);
67 
68  extern void
69  sCompRow_to_CompCol(int, int, int, float*, int*, int*,
70  float **, int **, int **);
71  extern void
72  sgssvx(SLU::superlu_options_t *, SLU::SuperMatrix *, int *, int *, int *,
73  char *, float *, float *, SLU::SuperMatrix *, SLU::SuperMatrix *,
74  void *, int, SLU::SuperMatrix *, SLU::SuperMatrix *,
75  float *, float *, float *, float *,
76 #ifdef HAVE_AMESOS2_SUPERLU5_API
77  SLU::GlobalLU_t*,
78 #endif
79  SLU::mem_usage_t *, SLU::SuperLUStat_t *, int *);
80  extern void
81  sgstrf (SLU::superlu_options_t*, SLU::SuperMatrix*,
82  int, int, int*, void *, int, int *, int *,
83  SLU::SuperMatrix *, SLU::SuperMatrix *,
84 #ifdef HAVE_AMESOS2_SUPERLU5_API
85  SLU::GlobalLU_t*,
86 #endif
87  SLU::SuperLUStat_t*, int *);
88  extern void
89  sgsisx(SLU::superlu_options_t *, SLU::SuperMatrix *, int *, int *, int *,
90  char *, float *, float *, SLU::SuperMatrix *, SLU::SuperMatrix *,
91  void *, int, SLU::SuperMatrix *, SLU::SuperMatrix *,
92  float *, float *,
93 #ifdef HAVE_AMESOS2_SUPERLU5_API
94  SLU::GlobalLU_t*,
95 #endif
96  SLU::mem_usage_t *, SLU::SuperLUStat_t *, int *);
97  extern void
98  sgsitrf (SLU::superlu_options_t*, SLU::SuperMatrix*,
99  int, int, int*, void *, int, int *, int *,
100  SLU::SuperMatrix *, SLU::SuperMatrix *,
101 #ifdef HAVE_AMESOS2_SUPERLU5_API
102  SLU::GlobalLU_t*,
103 #endif
104  SLU::SuperLUStat_t*, int *);
105  extern void
106  sCreate_CompCol_Matrix(SLU::SuperMatrix *, int, int, int, float *,
107  int *, int *, SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
108  extern void
109  sCreate_CompRow_Matrix(SLU::SuperMatrix *, int, int, int, float *,
110  int *, int *, SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
111  extern void
112  sCreate_Dense_Matrix(SLU::SuperMatrix *, int, int, float *, int,
113  SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
114 
115  extern void
116  sgsequ (SLU::SuperMatrix *, float *, float *, float *,
117  float *, float *, int *);
118 
119  extern void
120  slaqgs (SLU::SuperMatrix *, float *, float *, float,
121  float, float, char *);
122 
123 //#include "slu_sdefs.h"
124  }
125 
126  namespace D { // double-precision real definitions
127 
128  extern double dlangs (char *, SLU::SuperMatrix *);
129 
130  extern void dgscon (char *, SuperMatrix *, SuperMatrix *,
131  double, double *, SuperLUStat_t*, int *);
132 
133  extern void
134  dCompRow_to_CompCol(int, int, int, double*, int*, int*,
135  double **, int **, int **);
136  extern void
137  dgssvx(SLU::superlu_options_t *, SLU::SuperMatrix *, int *, int *, int *,
138  char *, double *, double *, SLU::SuperMatrix *, SLU::SuperMatrix *,
139  void *, int, SLU::SuperMatrix *, SLU::SuperMatrix *,
140  double *, double *, double *, double *,
141 #ifdef HAVE_AMESOS2_SUPERLU5_API
142  SLU::GlobalLU_t*,
143 #endif
144  SLU::mem_usage_t *, SLU::SuperLUStat_t *, int *);
145  extern void
146  dgstrf (SLU::superlu_options_t*, SLU::SuperMatrix*,
147  int, int, int*, void *, int, int *, int *,
148  SLU::SuperMatrix *, SLU::SuperMatrix *,
149 #ifdef HAVE_AMESOS2_SUPERLU5_API
150  SLU::GlobalLU_t*,
151 #endif
152  SLU::SuperLUStat_t*, int *);
153  extern void
154  dgsisx(SLU::superlu_options_t *, SLU::SuperMatrix *, int *, int *, int *,
155  char *, double *, double *, SLU::SuperMatrix *, SLU::SuperMatrix *,
156  void *, int, SLU::SuperMatrix *, SLU::SuperMatrix *,
157  double *, double *,
158 #ifdef HAVE_AMESOS2_SUPERLU5_API
159  SLU::GlobalLU_t*,
160 #endif
161  SLU::mem_usage_t *, SLU::SuperLUStat_t *, int *);
162  extern void
163  dgsitrf (SLU::superlu_options_t*, SLU::SuperMatrix*,
164  int, int, int*, void *, int, int *, int *,
165  SLU::SuperMatrix *, SLU::SuperMatrix *,
166 #ifdef HAVE_AMESOS2_SUPERLU5_API
167  SLU::GlobalLU_t*,
168 #endif
169  SLU::SuperLUStat_t*, int *);
170  extern void
171  dCreate_CompCol_Matrix(SLU::SuperMatrix *, int, int, int, double *,
172  int *, int *, SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
173  extern void
174  dCreate_CompRow_Matrix(SLU::SuperMatrix *, int, int, int, double *,
175  int *, int *, SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
176  extern void
177  dCreate_Dense_Matrix(SLU::SuperMatrix *, int, int, double *, int,
178  SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
179 
180  extern void
181  dlaqgs (SLU::SuperMatrix *, double *, double *, double,
182  double, double, char *);
183 
184  extern void
185  dgsequ (SLU::SuperMatrix *, double *, double *, double *,
186  double *, double *, int *);
187 
188 //#include "slu_ddefs.h"
189  }
190 
191 #ifdef HAVE_TEUCHOS_COMPLEX
192  namespace C { // single-precision complex definitions
193 
194  extern float clangs (char *, SLU::SuperMatrix *);
195 
196  extern void cgscon (char *, SuperMatrix *, SuperMatrix *,
197  float, float *, SuperLUStat_t*, int *);
198 
199  extern void
200  cCompRow_to_CompCol(int, int, int, complex*, int*, int*,
201  complex **, int **, int **);
202  extern void
203  cgssvx(SLU::superlu_options_t *, SLU::SuperMatrix *, int *, int *, int *,
204  char *, float *, float *, SLU::SuperMatrix *, SLU::SuperMatrix *,
205  void *, int, SLU::SuperMatrix *, SLU::SuperMatrix *,
206  float *, float *, float *, float *,
207 #ifdef HAVE_AMESOS2_SUPERLU5_API
208  SLU::GlobalLU_t*,
209 #endif
210  SLU::mem_usage_t *, SLU::SuperLUStat_t *, int *);
211  extern void
212  cgstrf (SLU::superlu_options_t*, SLU::SuperMatrix*,
213  int, int, int*, void *, int, int *, int *,
214  SLU::SuperMatrix *, SLU::SuperMatrix *,
215 #ifdef HAVE_AMESOS2_SUPERLU5_API
216  SLU::GlobalLU_t*,
217 #endif
218  SLU::SuperLUStat_t*, int *);
219  extern void
220  cgsisx(SLU::superlu_options_t *, SLU::SuperMatrix *, int *, int *, int *,
221  char *, float *, float *, SLU::SuperMatrix *, SLU::SuperMatrix *,
222  void *, int, SLU::SuperMatrix *, SLU::SuperMatrix *,
223  float *, float *,
224 #ifdef HAVE_AMESOS2_SUPERLU5_API
225  SLU::GlobalLU_t*,
226 #endif
227  SLU::mem_usage_t *, SLU::SuperLUStat_t *, int *);
228  extern void
229  cgsitrf (SLU::superlu_options_t*, SLU::SuperMatrix*,
230  int, int, int*, void *, int, int *, int *,
231  SLU::SuperMatrix *, SLU::SuperMatrix *,
232 #ifdef HAVE_AMESOS2_SUPERLU5_API
233  SLU::GlobalLU_t*,
234 #endif
235  SLU::SuperLUStat_t*, int *);
236  extern void
237  cCreate_CompCol_Matrix(SLU::SuperMatrix *, int, int, int, complex *,
238  int *, int *, SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
239  extern void
240  cCreate_CompRow_Matrix(SLU::SuperMatrix *, int, int, int, complex *,
241  int *, int *, SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
242  extern void
243  cCreate_Dense_Matrix(SLU::SuperMatrix *, int, int, complex *, int,
244  SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
245 
246  extern void
247  cgsequ (SLU::SuperMatrix *, float *, float *, float *,
248  float *, float *, int *);
249 
250  extern void
251  claqgs (SLU::SuperMatrix *, float *, float *, float,
252  float, float, char *);
253 
254 //#include "slu_cdefs.h"
255  }
256 
257  namespace Z { // double-precision complex definitions
258 
259  extern double zlangs (char *, SLU::SuperMatrix *);
260 
261  extern void zgscon (char *, SuperMatrix *, SuperMatrix *,
262  double, double *, SuperLUStat_t*, int *);
263 
264  extern void
265  zCompRow_to_CompCol(int, int, int, doublecomplex*, int*, int*,
266  doublecomplex **, int **, int **);
267  extern void
268  zgssvx(SLU::superlu_options_t *, SLU::SuperMatrix *, int *, int *, int *,
269  char *, double *, double *, SLU::SuperMatrix *, SLU::SuperMatrix *,
270  void *, int, SLU::SuperMatrix *, SLU::SuperMatrix *,
271  double *, double *, double *, double *,
272 #ifdef HAVE_AMESOS2_SUPERLU5_API
273  SLU::GlobalLU_t*,
274 #endif
275  SLU::mem_usage_t *, SLU::SuperLUStat_t *, int *);
276  extern void
277  zgstrf (SLU::superlu_options_t*, SLU::SuperMatrix*,
278  int, int, int*, void *, int, int *, int *,
279  SLU::SuperMatrix *, SLU::SuperMatrix *,
280 #ifdef HAVE_AMESOS2_SUPERLU5_API
281  SLU::GlobalLU_t*,
282 #endif
283  SLU::SuperLUStat_t*, int *);
284  extern void
285  zgsisx(SLU::superlu_options_t *, SLU::SuperMatrix *, int *, int *, int *,
286  char *, double *, double *, SLU::SuperMatrix *, SLU::SuperMatrix *,
287  void *, int, SLU::SuperMatrix *, SLU::SuperMatrix *,
288  double *, double *,
289 #ifdef HAVE_AMESOS2_SUPERLU5_API
290  SLU::GlobalLU_t*,
291 #endif
292  SLU::mem_usage_t *, SLU::SuperLUStat_t *, int *);
293  extern void
294  zgsitrf (SLU::superlu_options_t*, SLU::SuperMatrix*,
295  int, int, int*, void *, int, int *, int *,
296  SLU::SuperMatrix *, SLU::SuperMatrix *,
297 #ifdef HAVE_AMESOS2_SUPERLU5_API
298  SLU::GlobalLU_t*,
299 #endif
300  SLU::SuperLUStat_t*, int *);
301  extern void
302  zCreate_CompCol_Matrix(SLU::SuperMatrix *, int, int, int, doublecomplex *,
303  int *, int *, SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
304  extern void
305  zCreate_CompRow_Matrix(SLU::SuperMatrix *, int, int, int, doublecomplex *,
306  int *, int *, SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
307  extern void
308  zCreate_Dense_Matrix(SLU::SuperMatrix *, int, int, doublecomplex *, int,
309  SLU::Stype_t, SLU::Dtype_t, SLU::Mtype_t);
310 
311  extern void
312  zgsequ (SLU::SuperMatrix *, double *, double *, double *,
313  double *, double *, int *);
314 
315  extern void
316  zlaqgs (SLU::SuperMatrix *, double *, double *, double,
317  double, double, char *);
318 
319 //#include "slu_zdefs.h"
320  }
321 #endif // HAVE_TEUCHOS_COMPLEX
322 
323  } // end extern "C"
324 
325 } // end namespace SLU
326 
327 
328 namespace Amesos2 {
329 
330  /* ==================== Specializations ====================
331  *
332  * \cond Superlu_function_specializations
333  */
334 
358  template <>
359  struct FunctionMap<Superlu,float>
360  {
361  typedef TypeMap<Superlu,float> type_map;
362 
363  static float langs(char *norm, SLU::SuperMatrix *A)
364  {
365  return SLU::S::slangs(norm, A);
366  }
367 
368  static void gscon (char *norm, SLU::SuperMatrix *L, SLU::SuperMatrix *U,
369  float anorm, float *rcond, SLU::SuperLUStat_t *stat, int *info)
370  {
371  SLU::S::sgscon (norm, L, U, anorm, rcond, stat, info);
372  }
373 
377  static void gssvx(SLU::superlu_options_t* options, SLU::SuperMatrix* A,
378  int* perm_c, int* perm_r, int* etree, char* equed, float* R, float* C,
379  SLU::SuperMatrix* L, SLU::SuperMatrix* U, void* work, int lwork,
380  SLU::SuperMatrix* B, SLU::SuperMatrix* X, float* recip_pivot_growth,
381  float* rcond, float* ferr, float* berr,
382 #ifdef HAVE_AMESOS2_SUPERLU5_API
383  SLU::GlobalLU_t* lu,
384 #endif
385  SLU::mem_usage_t* mem_usage,
386  SLU::SuperLUStat_t* stat, int* info)
387  {
388  SLU::S::sgssvx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work,
389  lwork, B, X, recip_pivot_growth, rcond, ferr, berr,
390 #ifdef HAVE_AMESOS2_SUPERLU5_API
391  lu,
392 #endif
393  mem_usage, stat, info);
394  }
395 
396  static void gsisx(SLU::superlu_options_t* options, SLU::SuperMatrix* A,
397  int* perm_c, int* perm_r, int* etree, char* equed, float* R, float* C,
398  SLU::SuperMatrix* L, SLU::SuperMatrix* U, void* work, int lwork,
399  SLU::SuperMatrix* B, SLU::SuperMatrix* X, float* recip_pivot_growth,
400  float* rcond,
401 #ifdef HAVE_AMESOS2_SUPERLU5_API
402  SLU::GlobalLU_t* lu,
403 #endif
404  SLU::mem_usage_t* mem_usage,
405  SLU::SuperLUStat_t* stat, int* info)
406  {
407  SLU::S::sgsisx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work,
408  lwork, B, X, recip_pivot_growth, rcond,
409 #ifdef HAVE_AMESOS2_SUPERLU5_API
410  lu,
411 #endif
412  mem_usage, stat, info);
413  }
414 
434  static void gstrf(SLU::superlu_options_t* options, SLU::SuperMatrix* AC,
435  int relax, int panel_size, int* etree, void* work,
436  int lwork, int* perm_c, int* perm_r, SLU::SuperMatrix* L,
437  SLU::SuperMatrix* U,
438 #ifdef HAVE_AMESOS2_SUPERLU5_API
439  SLU::GlobalLU_t* lu,
440 #endif
441  SLU::SuperLUStat_t* stat, int* info)
442  {
443  SLU::S::sgstrf(options, AC, relax, panel_size, etree,
444  work, lwork, perm_c, perm_r, L, U,
445 #ifdef HAVE_AMESOS2_SUPERLU5_API
446  lu,
447 #endif
448  stat, info);
449  }
450 
451  static void gsitrf(SLU::superlu_options_t* options, SLU::SuperMatrix* AC,
452  int relax, int panel_size, int* etree, void* work,
453  int lwork, int* perm_c, int* perm_r, SLU::SuperMatrix* L,
454  SLU::SuperMatrix* U,
455 #ifdef HAVE_AMESOS2_SUPERLU5_API
456  SLU::GlobalLU_t* lu,
457 #endif
458  SLU::SuperLUStat_t* stat, int* info)
459  {
460  SLU::S::sgsitrf(options, AC, relax, panel_size, etree,
461  work, lwork, perm_c, perm_r, L, U,
462 #ifdef HAVE_AMESOS2_SUPERLU5_API
463  lu,
464 #endif
465  stat, info);
466  }
467 
471  template<class view_t>
472  static void create_CompCol_Matrix(SLU::SuperMatrix* A, int m, int n, int nnz,
473  Teuchos::Array<float> & convert_nzval, view_t & nzval,
474  int* rowind, int* colptr,
475  SLU::Stype_t stype, SLU::Dtype_t dtype, SLU::Mtype_t mtype)
476  {
477  // conversion not necessay - pass view data directly
478  SLU::S::sCreate_CompCol_Matrix(A, m, n, nnz, nzval.data(), rowind, colptr,
479  stype, dtype, mtype);
480  }
481 
485  static void create_CompRow_Matrix(SLU::SuperMatrix* A, int m, int n,
486  int nnz, float* nzval, int* rowind, int* colptr,
487  SLU::Stype_t stype, SLU::Dtype_t dtype, SLU::Mtype_t mtype)
488  {
489  SLU::S::sCreate_CompRow_Matrix(A, m, n, nnz, nzval, rowind, colptr,
490  stype, dtype, mtype);
491  }
492 
493 
502  template<class view_t>
503  static void create_Dense_Matrix(SLU::SuperMatrix* X, int m, int n,
504  Teuchos::Array<float> & convert_x, view_t & x,
505  int ldx, SLU::Stype_t stype,
506  SLU::Dtype_t dtype, SLU::Mtype_t mtype)
507  {
508  // conversion not necessay - pass view data directly
509  SLU::S::sCreate_Dense_Matrix(X, m, n, x.data(), ldx, stype, dtype, mtype);
510  }
511 
512  template<class view_t>
513  static void convert_back_Dense_Matrix(
514  Teuchos::Array<float> & convert_x, view_t & x)
515  {
516  // conversion not necessay - pass view data directly
517  }
518 
522  static void gsequ(SLU::SuperMatrix* A, float* R, float* C,
523  float* rowcnd, float* colcnd, float* amax, int* info)
524  {
525  SLU::S::sgsequ(A, R, C, rowcnd, colcnd, amax, info);
526  }
527 
542  static void laqgs(SLU::SuperMatrix* A, float* R, float* C,
543  float rowcnd, float colcnd, float amax, char* equed)
544  {
545  SLU::S::slaqgs(A, R, C, rowcnd, colcnd, amax, equed);
546  }
547  };
548 
549 
550  template <>
551  struct FunctionMap<Superlu,double>
552  {
553  typedef TypeMap<Superlu,double> type_map;
554 
555  static double langs(char *norm, SLU::SuperMatrix *A)
556  {
557  return SLU::D::dlangs(norm, A);
558  }
559 
560  static void gscon (char *norm, SLU::SuperMatrix *L, SLU::SuperMatrix *U,
561  double anorm, double *rcond, SLU::SuperLUStat_t *stat, int *info)
562  {
563  SLU::D::dgscon (norm, L, U, anorm, rcond, stat, info);
564  }
565 
566  static void gssvx(SLU::superlu_options_t* options, SLU::SuperMatrix* A,
567  int* perm_c, int* perm_r, int* etree, char* equed, double* R, double* C,
568  SLU::SuperMatrix* L, SLU::SuperMatrix* U, void* work, int lwork,
569  SLU::SuperMatrix* B, SLU::SuperMatrix* X, double* recip_pivot_growth,
570  double* rcond, double* ferr, double* berr,
571 #ifdef HAVE_AMESOS2_SUPERLU5_API
572  SLU::GlobalLU_t* lu,
573 #endif
574  SLU::mem_usage_t* mem_usage,
575  SLU::SuperLUStat_t* stat, int* info)
576  {
577  SLU::D::dgssvx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work,
578  lwork, B, X, recip_pivot_growth, rcond, ferr, berr,
579 #ifdef HAVE_AMESOS2_SUPERLU5_API
580  lu,
581 #endif
582  mem_usage, stat, info);
583  }
584 
585  static void gstrf(SLU::superlu_options_t* options, SLU::SuperMatrix* AC,
586  int relax, int panel_size, int* etree, void* work, int lwork, int* perm_c,
587  int* perm_r, SLU::SuperMatrix* L, SLU::SuperMatrix* U,
588 #ifdef HAVE_AMESOS2_SUPERLU5_API
589  SLU::GlobalLU_t* lu,
590 #endif
591  SLU::SuperLUStat_t* stat, int* info)
592  {
593  SLU::D::dgstrf(options, AC, relax, panel_size, etree,
594  work, lwork, perm_c, perm_r, L, U,
595 #ifdef HAVE_AMESOS2_SUPERLU5_API
596  lu,
597 #endif
598  stat, info);
599  }
600 
601  static void gsisx(SLU::superlu_options_t* options, SLU::SuperMatrix* A,
602  int* perm_c, int* perm_r, int* etree, char* equed, double* R, double* C,
603  SLU::SuperMatrix* L, SLU::SuperMatrix* U, void* work, int lwork,
604  SLU::SuperMatrix* B, SLU::SuperMatrix* X, double* recip_pivot_growth,
605  double* rcond,
606 #ifdef HAVE_AMESOS2_SUPERLU5_API
607  SLU::GlobalLU_t* lu,
608 #endif
609  SLU::mem_usage_t* mem_usage,
610  SLU::SuperLUStat_t* stat, int* info)
611  {
612  SLU::D::dgsisx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work,
613  lwork, B, X, recip_pivot_growth, rcond,
614 #ifdef HAVE_AMESOS2_SUPERLU5_API
615  lu,
616 #endif
617  mem_usage, stat, info);
618  }
619 
620  static void gsitrf(SLU::superlu_options_t* options, SLU::SuperMatrix* AC,
621  int relax, int panel_size, int* etree, void* work, int lwork, int* perm_c,
622  int* perm_r, SLU::SuperMatrix* L, SLU::SuperMatrix* U,
623 #ifdef HAVE_AMESOS2_SUPERLU5_API
624  SLU::GlobalLU_t* lu,
625 #endif
626  SLU::SuperLUStat_t* stat, int* info)
627  {
628  SLU::D::dgsitrf(options, AC, relax, panel_size, etree,
629  work, lwork, perm_c, perm_r, L, U,
630 #ifdef HAVE_AMESOS2_SUPERLU5_API
631  lu,
632 #endif
633  stat, info);
634  }
635 
636  template<class view_t>
637  static void create_CompCol_Matrix(SLU::SuperMatrix* A, int m, int n, int nnz,
638  Teuchos::Array<double> & convert_nzval, view_t & nzval,
639  int* rowind, int* colptr,
640  SLU::Stype_t stype, SLU::Dtype_t dtype, SLU::Mtype_t mtype)
641  {
642  // conversion not necessay - pass view data directly
643  SLU::D::dCreate_CompCol_Matrix(A, m, n, nnz, nzval.data(), rowind, colptr,
644  stype, dtype, mtype);
645  }
646 
647  static void create_CompRow_Matrix(SLU::SuperMatrix* A, int m, int n,
648  int nnz, double* nzval, int* rowind, int* colptr,
649  SLU::Stype_t stype, SLU::Dtype_t dtype, SLU::Mtype_t mtype)
650  {
651  SLU::D::dCreate_CompRow_Matrix(A, m, n, nnz, nzval, rowind, colptr,
652  stype, dtype, mtype);
653  }
654 
655  template<class view_t>
656  static void create_Dense_Matrix(SLU::SuperMatrix* X, int m, int n,
657  Teuchos::Array<double> & convert_x, view_t & x,
658  int ldx, SLU::Stype_t stype,
659  SLU::Dtype_t dtype, SLU::Mtype_t mtype)
660  {
661  // conversion not necessay - pass view data directly
662  SLU::D::dCreate_Dense_Matrix(X, m, n, x.data(), ldx, stype, dtype, mtype);
663  }
664 
665  template<class view_t>
666  static void convert_back_Dense_Matrix(
667  Teuchos::Array<double> & convert_x, view_t & x)
668  {
669  // conversion not necessay - pass view data directly
670  }
671 
672  static void gsequ(SLU::SuperMatrix* A, double* R, double* C,
673  double* rowcnd, double* colcnd, double* amax, int* info)
674  {
675  SLU::D::dgsequ(A, R, C, rowcnd, colcnd, amax, info);
676  }
677 
678  static void laqgs(SLU::SuperMatrix* A, double* R, double* C,
679  double rowcnd, double colcnd, double amax, char* equed)
680  {
681  SLU::D::dlaqgs(A, R, C, rowcnd, colcnd, amax, equed);
682  }
683 
684  };
685 
686 
687 #ifdef HAVE_TEUCHOS_COMPLEX
688 
689  template <>
690  struct FunctionMap<Superlu, Kokkos::complex<float>>
691  {
692 
693  static float langs(char *norm, SLU::SuperMatrix *A)
694  {
695  return SLU::C::clangs(norm, A);
696  }
697 
698  static void gscon (char *norm, SLU::SuperMatrix *L, SLU::SuperMatrix *U,
699  float anorm, float *rcond, SLU::SuperLUStat_t *stat, int *info)
700  {
701  SLU::C::cgscon (norm, L, U, anorm, rcond, stat, info);
702  }
703 
704  static void gssvx(SLU::superlu_options_t* options, SLU::SuperMatrix* A,
705  int* perm_c, int* perm_r, int* etree, char* equed, float* R, float* C,
706  SLU::SuperMatrix* L, SLU::SuperMatrix* U, void* work, int lwork,
707  SLU::SuperMatrix* B, SLU::SuperMatrix* X, float* recip_pivot_growth,
708  float* rcond, float* ferr, float* berr,
709 #ifdef HAVE_AMESOS2_SUPERLU5_API
710  SLU::GlobalLU_t* lu,
711 #endif
712  SLU::mem_usage_t* mem_usage,
713  SLU::SuperLUStat_t* stat, int* info)
714  {
715  SLU::C::cgssvx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work,
716  lwork, B, X, recip_pivot_growth, rcond, ferr, berr,
717 #ifdef HAVE_AMESOS2_SUPERLU5_API
718  lu,
719 #endif
720  mem_usage, stat, info);
721  }
722 
723  static void gstrf(SLU::superlu_options_t* options, SLU::SuperMatrix* AC,
724  int relax, int panel_size, int* etree, void* work, int lwork, int* perm_c,
725  int* perm_r, SLU::SuperMatrix* L, SLU::SuperMatrix* U,
726 #ifdef HAVE_AMESOS2_SUPERLU5_API
727  SLU::GlobalLU_t* lu,
728 #endif
729  SLU::SuperLUStat_t* stat, int* info)
730  {
731  SLU::C::cgstrf(options, AC, relax, panel_size, etree,
732  work, lwork, perm_c, perm_r, L, U,
733 #ifdef HAVE_AMESOS2_SUPERLU5_API
734  lu,
735 #endif
736  stat, info);
737  }
738 
739  static void gsisx(SLU::superlu_options_t* options, SLU::SuperMatrix* A,
740  int* perm_c, int* perm_r, int* etree, char* equed, float* R, float* C,
741  SLU::SuperMatrix* L, SLU::SuperMatrix* U, void* work, int lwork,
742  SLU::SuperMatrix* B, SLU::SuperMatrix* X, float* recip_pivot_growth,
743  float* rcond,
744 #ifdef HAVE_AMESOS2_SUPERLU5_API
745  SLU::GlobalLU_t* lu,
746 #endif
747  SLU::mem_usage_t* mem_usage,
748  SLU::SuperLUStat_t* stat, int* info)
749  {
750  SLU::C::cgsisx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work,
751  lwork, B, X, recip_pivot_growth, rcond,
752 #ifdef HAVE_AMESOS2_SUPERLU5_API
753  lu,
754 #endif
755  mem_usage, stat, info);
756  }
757 
758  static void gsitrf(SLU::superlu_options_t* options, SLU::SuperMatrix* AC,
759  int relax, int panel_size, int* etree, void* work, int lwork, int* perm_c,
760  int* perm_r, SLU::SuperMatrix* L, SLU::SuperMatrix* U,
761 #ifdef HAVE_AMESOS2_SUPERLU5_API
762  SLU::GlobalLU_t* lu,
763 #endif
764  SLU::SuperLUStat_t* stat, int* info)
765  {
766  SLU::C::cgsitrf(options, AC, relax, panel_size, etree,
767  work, lwork, perm_c, perm_r, L, U,
768 #ifdef HAVE_AMESOS2_SUPERLU5_API
769  lu,
770 #endif
771  stat, info);
772  }
773 
774  template<class view_t>
775  static void create_CompCol_Matrix(SLU::SuperMatrix* A, int m, int n, int nnz,
776  Teuchos::Array<SLU::C::complex> & convert_nzval, view_t & nzval,
777  int* rowind, int* colptr,
778  SLU::Stype_t stype, SLU::Dtype_t dtype, SLU::Mtype_t mtype)
779  {
780  convert_nzval.resize(nnz);
781  for(int i = 0; i < nnz; ++i) {
782  convert_nzval[i] = Teuchos::as<SLU::C::complex>(nzval(i));
783  }
784  SLU::C::cCreate_CompCol_Matrix(A, m, n, nnz, convert_nzval.data(), rowind, colptr,
785  stype, dtype, mtype);
786  }
787 
788  static void create_CompRow_Matrix(SLU::SuperMatrix* A, int m, int n, int nnz,
789  SLU::C::complex* nzval, int* rowind, int* colptr,
790  SLU::Stype_t stype, SLU::Dtype_t dtype, SLU::Mtype_t mtype)
791  {
792  SLU::C::cCreate_CompRow_Matrix(A, m, n, nnz, nzval, rowind, colptr,
793  stype, dtype, mtype);
794  }
795 
796  template<class view_t>
797  static void create_Dense_Matrix(SLU::SuperMatrix* X, int m, int n,
798  Teuchos::Array<SLU::C::complex> & convert_x, view_t & x,
799  int ldx, SLU::Stype_t stype,
800  SLU::Dtype_t dtype, SLU::Mtype_t mtype)
801  {
802  convert_x.resize(m * n);
803  int write_index = 0;
804  for(int j = 0; j < n; ++j) {
805  for(int i = 0; i < m; ++i) { // layout left
806  convert_x[write_index++] = Teuchos::as<SLU::C::complex>(x(i,j));
807  }
808  }
809  SLU::C::cCreate_Dense_Matrix(X, m, n, convert_x.data(), ldx, stype, dtype, mtype);
810  }
811 
812  template<class view_t>
813  static void convert_back_Dense_Matrix(
814  Teuchos::Array<SLU::C::complex> & convert_x, view_t & x)
815  {
816  int read_index = 0;
817  for(int j = 0; j < static_cast<int>(x.extent(1)); ++j) {
818  for(int i = 0; i < static_cast<int>(x.extent(0)); ++i) { // layout left
819  x(i,j) = Teuchos::as<Kokkos::complex<float>>(convert_x[read_index++]);
820  }
821  }
822  }
823 
824  static void gsequ(SLU::SuperMatrix* A, float* R, float* C,
825  float* rowcnd, float* colcnd, float* amax, int* info)
826  {
827  SLU::C::cgsequ(A, R, C, rowcnd, colcnd, amax, info);
828  }
829 
830  static void laqgs(SLU::SuperMatrix* A, float* R, float* C,
831  float rowcnd, float colcnd, float amax, char* equed)
832  {
833  SLU::C::claqgs(A, R, C, rowcnd, colcnd, amax, equed);
834  }
835  };
836 
837 
838  template <>
839  struct FunctionMap<Superlu,Kokkos::complex<double>>
840  {
841 
842  static double langs(char *norm, SLU::SuperMatrix *A)
843  {
844  return SLU::Z::zlangs(norm, A);
845  }
846 
847  static void gscon (char *norm, SLU::SuperMatrix *L, SLU::SuperMatrix *U,
848  double anorm, double *rcond, SLU::SuperLUStat_t *stat, int *info)
849  {
850  SLU::Z::zgscon (norm, L, U, anorm, rcond, stat, info);
851  }
852 
853  static void gssvx(SLU::superlu_options_t* options, SLU::SuperMatrix* A,
854  int* perm_c, int* perm_r, int* etree, char* equed, double* R, double* C,
855  SLU::SuperMatrix* L, SLU::SuperMatrix* U, void* work, int lwork,
856  SLU::SuperMatrix* B, SLU::SuperMatrix* X, double* recip_pivot_growth,
857  double* rcond, double* ferr, double* berr,
858 #ifdef HAVE_AMESOS2_SUPERLU5_API
859  SLU::GlobalLU_t* lu,
860 #endif
861  SLU::mem_usage_t* mem_usage,
862  SLU::SuperLUStat_t* stat, int* info)
863  {
864  SLU::Z::zgssvx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work,
865  lwork, B, X, recip_pivot_growth, rcond, ferr, berr,
866 #ifdef HAVE_AMESOS2_SUPERLU5_API
867  lu,
868 #endif
869  mem_usage, stat, info);
870  }
871 
872  static void gstrf(SLU::superlu_options_t* options, SLU::SuperMatrix* AC,
873  int relax, int panel_size, int* etree, void* work, int lwork, int* perm_c,
874  int* perm_r, SLU::SuperMatrix* L, SLU::SuperMatrix* U,
875 #ifdef HAVE_AMESOS2_SUPERLU5_API
876  SLU::GlobalLU_t* lu,
877 #endif
878  SLU::SuperLUStat_t* stat, int* info)
879  {
880  SLU::Z::zgstrf(options, AC, relax, panel_size, etree,
881  work, lwork, perm_c, perm_r, L, U,
882 #ifdef HAVE_AMESOS2_SUPERLU5_API
883  lu,
884 #endif
885  stat, info);
886  }
887 
888  static void gsisx(SLU::superlu_options_t* options, SLU::SuperMatrix* A,
889  int* perm_c, int* perm_r, int* etree, char* equed, double* R, double* C,
890  SLU::SuperMatrix* L, SLU::SuperMatrix* U, void* work, int lwork,
891  SLU::SuperMatrix* B, SLU::SuperMatrix* X, double* recip_pivot_growth,
892  double* rcond,
893 #ifdef HAVE_AMESOS2_SUPERLU5_API
894  SLU::GlobalLU_t* lu,
895 #endif
896  SLU::mem_usage_t* mem_usage,
897  SLU::SuperLUStat_t* stat, int* info)
898  {
899  SLU::Z::zgsisx(options, A, perm_c, perm_r, etree, equed, R, C, L, U, work,
900  lwork, B, X, recip_pivot_growth, rcond,
901 #ifdef HAVE_AMESOS2_SUPERLU5_API
902  lu,
903 #endif
904  mem_usage, stat, info);
905  }
906 
907  static void gsitrf(SLU::superlu_options_t* options, SLU::SuperMatrix* AC,
908  int relax, int panel_size, int* etree, void* work, int lwork, int* perm_c,
909  int* perm_r, SLU::SuperMatrix* L, SLU::SuperMatrix* U,
910 #ifdef HAVE_AMESOS2_SUPERLU5_API
911  SLU::GlobalLU_t* lu,
912 #endif
913  SLU::SuperLUStat_t* stat, int* info)
914  {
915  SLU::Z::zgsitrf(options, AC, relax, panel_size, etree,
916  work, lwork, perm_c, perm_r, L, U,
917 #ifdef HAVE_AMESOS2_SUPERLU5_API
918  lu,
919 #endif
920  stat, info);
921  }
922 
923  template<class view_t>
924  static void create_CompCol_Matrix(SLU::SuperMatrix* A, int m, int n, int nnz,
925  Teuchos::Array<SLU::Z::doublecomplex> & convert_nzval, view_t & nzval,
926  int* rowind, int* colptr,
927  SLU::Stype_t stype, SLU::Dtype_t dtype, SLU::Mtype_t mtype)
928  {
929  convert_nzval.resize(nnz);
930  for(int i = 0; i < nnz; ++i) {
931  convert_nzval[i] = Teuchos::as<SLU::Z::doublecomplex>(nzval(i));
932  }
933  SLU::Z::zCreate_CompCol_Matrix(A, m, n, nnz, convert_nzval.data(), rowind, colptr,
934  stype, dtype, mtype);
935 
936  TEUCHOS_TEST_FOR_EXCEPTION( A == NULL,
937  std::runtime_error,
938  "Supermatrix A not initialized properly!");
939  }
940 
941 
942  static void create_CompRow_Matrix(SLU::SuperMatrix* A, int m, int n, int nnz,
943  SLU::Z::doublecomplex* nzval, int* rowind, int* colptr,
944  SLU::Stype_t stype, SLU::Dtype_t dtype, SLU::Mtype_t mtype)
945  {
946  SLU::Z::zCreate_CompRow_Matrix(A, m, n, nnz, nzval, rowind, colptr,
947  stype, dtype, mtype);
948 
949  TEUCHOS_TEST_FOR_EXCEPTION( A == NULL,
950  std::runtime_error,
951  "Supermatrix A not initialized properly!");
952  }
953 
954  template<class view_t>
955  static void create_Dense_Matrix(SLU::SuperMatrix* X, int m, int n,
956  Teuchos::Array<SLU::Z::doublecomplex> & convert_x, view_t & x,
957  int ldx, SLU::Stype_t stype,
958  SLU::Dtype_t dtype, SLU::Mtype_t mtype)
959  {
960  convert_x.resize(m * n);
961  int write_index = 0;
962  for(int j = 0; j < n; ++j) {
963  for(int i = 0; i < m; ++i) { // layout left
964  convert_x[write_index++] = Teuchos::as<SLU::Z::doublecomplex>(x(i,j));
965  }
966  }
967  SLU::Z::zCreate_Dense_Matrix(X, m, n, convert_x.data(), ldx, stype, dtype, mtype);
968  }
969 
970  template<class view_t>
971  static void convert_back_Dense_Matrix(
972  Teuchos::Array<SLU::Z::doublecomplex> & convert_x, view_t & x)
973  {
974  int read_index = 0;
975  for(int j = 0; j < static_cast<int>(x.extent(1)); ++j) {
976  for(int i = 0; i < static_cast<int>(x.extent(0)); ++i) { // layout left
977  x(i,j) = Teuchos::as<Kokkos::complex<double>>(convert_x[read_index++]);
978  }
979  }
980  }
981 
982  static void gsequ(SLU::SuperMatrix* A, double* R, double* C,
983  double* rowcnd, double* colcnd, double* amax, int* info)
984  {
985  SLU::Z::zgsequ(A, R, C, rowcnd, colcnd, amax, info);
986  }
987 
988  static void laqgs(SLU::SuperMatrix* A, double* R, double* C,
989  double rowcnd, double colcnd, double amax, char* equed)
990  {
991  SLU::Z::zlaqgs(A, R, C, rowcnd, colcnd, amax, equed);
992  }
993  };
994 #endif // HAVE_TEUCHOS_COMPLEX
995 
996  /* \endcond Superlu_function_specializations */
997 
998 
999 } // end namespace Amesos2
1000 
1001 #endif // AMESOS2_SUPERLU_FUNCTIONMAP_HPP
Declaration of Function mapping class for Amesos2.
Provides definition of SuperLU types as well as conversions and type traits.