53 #ifndef AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
54 #define AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
56 #ifdef HAVE_TEUCHOS_COMPLEX
60 #include "Amesos2_config.h"
62 #include "Amesos2_MatrixAdapter.hpp"
69 #define AMESOS2_SLUD_GET_DIAG_SCALE(eq) (((eq)=='N') ? SLUD::NOEQUIL : ((eq)=='R') ? SLUD::ROW : ((eq)=='C') ? SLUD::COL : SLUD::BOTH)
71 #define AMESOS2_SLUD_GET_EQUED(ds) (((ds)==SLUD::NOEQUIL) ? 'N' : ((ds)==SLUD::ROW) ? 'R' : ((ds)==SLUD::COL) ? 'C' : 'B')
75 template <
class Matrix,
class Vector>
class Superludist;
77 SLUD::DiagScale_t get_diag_scale(
char eq);
78 char get_equed(SLUD::DiagScale_t ds);
109 struct FunctionMap<Superludist,double>
111 typedef TypeMap<Superludist,double> type_map;
126 static void gstrf(SLUD::amesos2_superlu_dist_options_t* options,
int m,
int n,
double anorm,
127 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid, SLUD::SuperLUStat_t* stat,
130 SLUD::D::pdgstrf(options, m, n, anorm, LU, grid, stat, info);
137 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
138 SLUD::ScalePermstruct_t* scale_perm_struct, SLUD::gridinfo_t* grid,
139 type_map::type* B, SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
140 SLUD::int_t ldb,
int nrhs, type_map::SOLVEstruct_t* solve_struct,
141 SLUD::SuperLUStat_t* stat,
int* info)
143 SLUD::D::pdgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
144 fst_global_row, ldb, nrhs, solve_struct, stat, info);
154 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
155 SLUD::gridinfo_t* grid, type_map::type* B,
156 SLUD::int_t ldb,
int nrhs,
157 SLUD::SuperLUStat_t* stat,
int* info)
159 SLUD::D::pdgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
165 static void gsrfs(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
166 type_map::LUstruct_t* lu_struct,
167 SLUD::ScalePermstruct_t* scale_perm,
168 SLUD::gridinfo_t* grid, type_map::type* B, SLUD::int_t ldb,
169 type_map::type* X, SLUD::int_t ldx,
int nrhs,
170 type_map::SOLVEstruct_t* solve_struct,
double* berr,
171 SLUD::SuperLUStat_t* stat,
int* info)
173 SLUD::D::pdgsrfs(n, A, anorm, lu_struct, scale_perm, grid, B, ldb,
174 X, ldx, nrhs, solve_struct, berr, stat, info);
184 static void gsrfs_ABXglobal(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
185 type_map::LUstruct_t* lu_struct, SLUD::gridinfo_t* grid,
186 type_map::type* B, SLUD::int_t ldb, type_map::type* X,
187 SLUD::int_t ldx,
int nrhs,
double* berr,
188 SLUD::SuperLUStat_t* stat,
int* info)
190 SLUD::D::pdgsrfs_ABXglobal(n, A, anorm, lu_struct, grid, B, ldb,
191 X, ldx, nrhs, berr, stat, info);
198 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
199 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
200 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
201 type_map::type* nzval, SLUD::int_t* colind,
202 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
203 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
205 SLUD::D::dCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
206 l_numrows, fst_global_row,
207 nzval, colind, rowptr,
208 storage_t, data_t, mat_t);
218 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
219 SLUD::int_t numcols, SLUD::int_t nnz,
220 type_map::type* nzval, SLUD::int_t* rowind,
221 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
222 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
224 SLUD::D::dCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
225 nzval, rowind, colptr,
226 storage_t, data_t, mat_t);
237 static void create_Dense_Matrix(SLUD::SuperMatrix* X,
int m,
int n,
238 type_map::type* x,
int ldx, SLUD::Stype_t stype,
239 SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
241 SLUD::D::dCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
244 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
245 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
246 type_map::type* X,
int ldx, type_map::type* B,
247 int ldb,
int nrhs, SLUD::gridinfo_t* grid)
249 SLUD::D::pdPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
250 X, ldx, B, ldb, nrhs, grid);
261 static void gsequ_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
262 double* rowcnd,
double* colcnd,
double* amax,
int* info,
263 SLUD::gridinfo_t* grid)
265 SLUD::D::pdgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
272 static void gsequ(SLUD::SuperMatrix* A,
double* r,
double* c,
273 double* rowcnd,
double* colcnd,
double* amax,
int* info)
275 SLUD::D::dgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
281 static void laqgs_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
282 double rowcnd,
double colcnd,
double amax,
283 SLUD::DiagScale_t* equed)
285 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
286 SLUD::D::pdlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
287 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
303 static void laqgs(SLUD::SuperMatrix* A,
double* r,
double* c,
304 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
306 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
307 SLUD::D::dlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
308 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
314 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
315 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
316 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
318 SLUD::D::ddistribute(fact, n, A, glu_freeable, lu, grid);
328 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
329 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
330 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
331 SLUD::gridinfo_t* grid)
333 SLUD::D::pddistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
344 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n, SLUD::SuperMatrix* A,
345 SLUD::ScalePermstruct_t* scale_perm,
346 SLUD::Pslu_freeable_t* pslu_freeable,
347 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
349 SLUD::D::ddist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
359 static double plangs(
char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
361 return SLUD::D::pdlangs(norm, A, grid);
364 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
365 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
366 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
367 type_map::SOLVEstruct_t* solve_struct)
369 SLUD::D::dSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
372 static void LUstructInit(SLUD::int_t m, SLUD::int_t n,
373 type_map::LUstruct_t* lu)
375 #ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
376 SLUD::D::LUstructInit(n, lu);
378 SLUD::D::LUstructInit(m, n, lu);
382 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid,
383 type_map::LUstruct_t* lu)
385 SLUD::D::Destroy_LU(m, grid, lu);
388 static void LUstructFree(type_map::LUstruct_t* lu)
390 SLUD::D::LUstructFree(lu);
393 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
394 type_map::SOLVEstruct_t* solve_struct)
396 SLUD::D::dSolveFinalize(options, solve_struct);
401 #if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
406 struct FunctionMap<Superludist,SLUD::Z::doublecomplex>
408 typedef TypeMap<Superludist,std::complex<double> > type_map;
410 static void gstrf(SLUD::amesos2_superlu_dist_options_t* options,
int m,
int n,
double anorm,
411 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid,
412 SLUD::SuperLUStat_t* stat,
int* info)
414 SLUD::Z::pzgstrf(options, m, n, anorm, LU, grid, stat, info);
417 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
418 SLUD::ScalePermstruct_t* scale_perm_struct,
419 SLUD::gridinfo_t* grid, type_map::type* B,
420 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
421 SLUD::int_t ldb,
int nrhs,
422 type_map::SOLVEstruct_t* solve_struct,
423 SLUD::SuperLUStat_t* stat,
int* info)
425 SLUD::Z::pzgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
426 fst_global_row, ldb, nrhs, solve_struct, stat, info);
429 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
430 SLUD::gridinfo_t* grid, type_map::type* B,
431 SLUD::int_t ldb,
int nrhs, SLUD::SuperLUStat_t* stat,
int* info)
433 SLUD::Z::pzgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
436 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
437 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
438 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
439 type_map::type* nzval, SLUD::int_t* colind,
440 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
441 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
443 SLUD::Z::zCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
444 l_numrows, fst_global_row,
445 nzval, colind, rowptr,
446 storage_t, data_t, mat_t);
449 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
450 SLUD::int_t numcols, SLUD::int_t nnz,
451 type_map::type* nzval, SLUD::int_t* rowind,
452 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
453 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
455 SLUD::Z::zCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
456 nzval, rowind, colptr,
457 storage_t, data_t, mat_t);
460 static void create_Dense_Matrix(SLUD::SuperMatrix* X,
int m,
int n,
461 TypeMap<Superludist,std::complex<double> >::type* x,
int ldx,
462 SLUD::Stype_t stype, SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
464 SLUD::Z::zCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
467 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
468 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
469 type_map::type* X,
int ldx,
470 type_map::type* B,
int ldb,
471 int nrhs, SLUD::gridinfo_t* grid)
473 SLUD::Z::pzPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
474 X, ldx, B, ldb, nrhs, grid);
477 static void gsequ_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
478 double* rowcnd,
double* colcnd,
double* amax,
int* info,
479 SLUD::gridinfo_t* grid)
481 SLUD::Z::pzgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
484 static void gsequ(SLUD::SuperMatrix* A,
double* r,
double* c,
485 double* rowcnd,
double* colcnd,
double* amax,
int* info)
487 SLUD::Z::zgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
490 static void laqgs_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
491 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
493 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
494 SLUD::Z::pzlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
495 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
498 static void laqgs(SLUD::SuperMatrix* A,
double* r,
double* c,
499 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
501 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
502 SLUD::Z::zlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
503 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
506 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
507 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
508 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
510 SLUD::Z::zdistribute(fact, n, A, glu_freeable, lu, grid);
513 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
514 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
515 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
516 SLUD::gridinfo_t* grid)
518 SLUD::Z::pzdistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
521 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
522 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
523 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
524 SLUD::gridinfo_t* grid)
526 SLUD::Z::zdist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
529 static double plangs(
char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
531 return SLUD::Z::pzlangs(norm, A, grid);
534 static void SolveInit(SLUD::amesos2_superlu_dist_options_t* options, SLUD::SuperMatrix* A,
535 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
536 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
537 type_map::SOLVEstruct_t* solve_struct)
539 SLUD::Z::zSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
542 static void LUstructInit(SLUD::int_t m, SLUD::int_t n, type_map::LUstruct_t* lu)
544 #ifdef HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG
545 SLUD::Z::LUstructInit(n, lu);
547 SLUD::Z::LUstructInit(m, n, lu);
551 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid, type_map::LUstruct_t* lu)
553 SLUD::Z::Destroy_LU(m, grid, lu);
556 static void LUstructFree(type_map::LUstruct_t* lu)
558 SLUD::Z::LUstructFree(lu);
561 static void SolveFinalize(SLUD::amesos2_superlu_dist_options_t* options,
562 type_map::SOLVEstruct_t* solve_struct)
564 SLUD::Z::zSolveFinalize(options, solve_struct);
567 #endif // HAVE_TEUCHOS_COMPLEX
572 #endif // AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
Declaration of Function mapping class for Amesos2.
Provides definition of SuperLU_DIST types as well as conversions and type traits. ...