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