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