53 #ifndef AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
54 #define AMESOS2_SUPERLUDIST_FUNCTIONMAP_HPP
56 #ifdef HAVE_TEUCHOS_COMPLEX
61 #include "Amesos2_MatrixAdapter.hpp"
68 #define AMESOS2_SLUD_GET_DIAG_SCALE(eq) (((eq)=='N') ? SLUD::NOEQUIL : ((eq)=='R') ? SLUD::ROW : ((eq)=='C') ? SLUD::COL : SLUD::BOTH)
70 #define AMESOS2_SLUD_GET_EQUED(ds) (((ds)==SLUD::NOEQUIL) ? 'N' : ((ds)==SLUD::ROW) ? 'R' : ((ds)=='C') ? SLUD::COL : SLUD::BOTH)
74 template <
class Matrix,
class Vector>
class Superludist;
76 SLUD::DiagScale_t get_diag_scale(
char eq);
77 char get_equed(SLUD::DiagScale_t ds);
108 struct FunctionMap<Superludist,double>
110 typedef TypeMap<Superludist,double> type_map;
125 static void gstrf(SLUD::superlu_options_t* options,
int m,
int n,
double anorm,
126 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid, SLUD::SuperLUStat_t* stat,
129 SLUD::D::pdgstrf(options, m, n, anorm, LU, grid, stat, info);
136 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
137 SLUD::ScalePermstruct_t* scale_perm_struct, SLUD::gridinfo_t* grid,
138 type_map::type* B, SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
139 SLUD::int_t ldb,
int nrhs, type_map::SOLVEstruct_t* solve_struct,
140 SLUD::SuperLUStat_t* stat,
int* info)
142 SLUD::D::pdgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
143 fst_global_row, ldb, nrhs, solve_struct, stat, info);
153 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
154 SLUD::gridinfo_t* grid, type_map::type* B,
155 SLUD::int_t ldb,
int nrhs,
156 SLUD::SuperLUStat_t* stat,
int* info)
158 SLUD::D::pdgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
164 static void gsrfs(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
165 type_map::LUstruct_t* lu_struct,
166 SLUD::ScalePermstruct_t* scale_perm,
167 SLUD::gridinfo_t* grid, type_map::type* B, SLUD::int_t ldb,
168 type_map::type* X, SLUD::int_t ldx,
int nrhs,
169 type_map::SOLVEstruct_t* solve_struct,
double* berr,
170 SLUD::SuperLUStat_t* stat,
int* info)
172 SLUD::D::pdgsrfs(n, A, anorm, lu_struct, scale_perm, grid, B, ldb,
173 X, ldx, nrhs, solve_struct, berr, stat, info);
183 static void gsrfs_ABXglobal(SLUD::int_t n, SLUD::SuperMatrix* A,
double anorm,
184 type_map::LUstruct_t* lu_struct, SLUD::gridinfo_t* grid,
185 type_map::type* B, SLUD::int_t ldb, type_map::type* X,
186 SLUD::int_t ldx,
int nrhs,
double* berr,
187 SLUD::SuperLUStat_t* stat,
int* info)
189 SLUD::D::pdgsrfs_ABXglobal(n, A, anorm, lu_struct, grid, B, ldb,
190 X, ldx, nrhs, berr, stat, info);
197 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
198 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
199 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
200 type_map::type* nzval, SLUD::int_t* colind,
201 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
202 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
204 SLUD::D::dCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
205 l_numrows, fst_global_row,
206 nzval, colind, rowptr,
207 storage_t, data_t, mat_t);
217 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
218 SLUD::int_t numcols, SLUD::int_t nnz,
219 type_map::type* nzval, SLUD::int_t* rowind,
220 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
221 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
223 SLUD::D::dCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
224 nzval, rowind, colptr,
225 storage_t, data_t, mat_t);
236 static void create_Dense_Matrix(SLUD::SuperMatrix* X,
int m,
int n,
237 type_map::type* x,
int ldx, SLUD::Stype_t stype,
238 SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
240 SLUD::D::dCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
243 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
244 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
245 type_map::type* X,
int ldx, type_map::type* B,
246 int ldb,
int nrhs, SLUD::gridinfo_t* grid)
248 SLUD::D::pdPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
249 X, ldx, B, ldb, nrhs, grid);
260 static void gsequ_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
261 double* rowcnd,
double* colcnd,
double* amax,
int* info,
262 SLUD::gridinfo_t* grid)
264 SLUD::D::pdgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
271 static void gsequ(SLUD::SuperMatrix* A,
double* r,
double* c,
272 double* rowcnd,
double* colcnd,
double* amax,
int* info)
274 SLUD::D::dgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
280 static void laqgs_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
281 double rowcnd,
double colcnd,
double amax,
282 SLUD::DiagScale_t* equed)
284 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
285 SLUD::D::pdlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
286 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
302 static void laqgs(SLUD::SuperMatrix* A,
double* r,
double* c,
303 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
305 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
306 SLUD::D::dlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
307 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
313 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
314 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
315 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
317 SLUD::D::ddistribute(fact, n, A, glu_freeable, lu, grid);
327 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
328 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
329 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
330 SLUD::gridinfo_t* grid)
332 SLUD::D::pddistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
343 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n, SLUD::SuperMatrix* A,
344 SLUD::ScalePermstruct_t* scale_perm,
345 SLUD::Pslu_freeable_t* pslu_freeable,
346 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
348 SLUD::D::ddist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
358 static double plangs(
char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
360 return SLUD::D::pdlangs(norm, A, grid);
363 static void SolveInit(SLUD::superlu_options_t* options, SLUD::SuperMatrix* A,
364 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
365 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
366 type_map::SOLVEstruct_t* solve_struct)
368 SLUD::D::dSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
371 static void LUstructInit(SLUD::int_t m, SLUD::int_t n,
372 type_map::LUstruct_t* lu)
374 SLUD::D::LUstructInit(m, n, lu);
377 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid,
378 type_map::LUstruct_t* lu)
380 SLUD::D::Destroy_LU(m, grid, lu);
383 static void LUstructFree(type_map::LUstruct_t* lu)
385 SLUD::D::LUstructFree(lu);
388 static void SolveFinalize(SLUD::superlu_options_t* options,
389 type_map::SOLVEstruct_t* solve_struct)
391 SLUD::D::dSolveFinalize(options, solve_struct);
396 #ifdef HAVE_TEUCHOS_COMPLEX
401 struct FunctionMap<Superludist,SLUD::Z::doublecomplex>
403 typedef TypeMap<Superludist,std::complex<double> > type_map;
405 static void gstrf(SLUD::superlu_options_t* options,
int m,
int n,
double anorm,
406 type_map::LUstruct_t* LU, SLUD::gridinfo_t* grid,
407 SLUD::SuperLUStat_t* stat,
int* info)
409 SLUD::Z::pzgstrf(options, m, n, anorm, LU, grid, stat, info);
412 static void gstrs(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
413 SLUD::ScalePermstruct_t* scale_perm_struct,
414 SLUD::gridinfo_t* grid, type_map::type* B,
415 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
416 SLUD::int_t ldb,
int nrhs,
417 type_map::SOLVEstruct_t* solve_struct,
418 SLUD::SuperLUStat_t* stat,
int* info)
420 SLUD::Z::pzgstrs(n, lu_struct, scale_perm_struct, grid, B, l_numrows,
421 fst_global_row, ldb, nrhs, solve_struct, stat, info);
424 static void gstrs_Bglobal(SLUD::int_t n, type_map::LUstruct_t* lu_struct,
425 SLUD::gridinfo_t* grid, type_map::type* B,
426 SLUD::int_t ldb,
int nrhs, SLUD::SuperLUStat_t* stat,
int* info)
428 SLUD::Z::pzgstrs_Bglobal(n, lu_struct, grid, B, ldb, nrhs, stat, info);
431 static void create_CompRowLoc_Matrix(SLUD::SuperMatrix* A, SLUD::int_t g_numrows,
432 SLUD::int_t g_numcols, SLUD::int_t l_nnz,
433 SLUD::int_t l_numrows, SLUD::int_t fst_global_row,
434 type_map::type* nzval, SLUD::int_t* colind,
435 SLUD::int_t* rowptr, SLUD::Stype_t storage_t,
436 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
438 SLUD::Z::zCreate_CompRowLoc_Matrix_dist(A, g_numrows, g_numcols, l_nnz,
439 l_numrows, fst_global_row,
440 nzval, colind, rowptr,
441 storage_t, data_t, mat_t);
444 static void create_CompCol_Matrix(SLUD::SuperMatrix* A, SLUD::int_t numrows,
445 SLUD::int_t numcols, SLUD::int_t nnz,
446 type_map::type* nzval, SLUD::int_t* rowind,
447 SLUD::int_t* colptr, SLUD::Stype_t storage_t,
448 SLUD::Dtype_t data_t, SLUD::Mtype_t mat_t)
450 SLUD::Z::zCreate_CompCol_Matrix_dist(A, numrows, numcols, nnz,
451 nzval, rowind, colptr,
452 storage_t, data_t, mat_t);
455 static void create_Dense_Matrix(SLUD::SuperMatrix* X,
int m,
int n,
456 TypeMap<Superludist,std::complex<double> >::type* x,
int ldx,
457 SLUD::Stype_t stype, SLUD::Dtype_t dtype, SLUD::Mtype_t mtype)
459 SLUD::Z::zCreate_Dense_Matrix_dist(X, m, n, x, ldx, stype, dtype, mtype);
462 static void permute_Dense_Matrix(SLUD::int_t fst_row, SLUD::int_t m_loc,
463 SLUD::int_t* row_to_proc, SLUD::int_t* perm,
464 type_map::type* X,
int ldx,
465 type_map::type* B,
int ldb,
466 int nrhs, SLUD::gridinfo_t* grid)
468 SLUD::Z::pzPermute_Dense_Matrix(fst_row, m_loc, row_to_proc, perm,
469 X, ldx, B, ldb, nrhs, grid);
472 static void gsequ_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
473 double* rowcnd,
double* colcnd,
double* amax,
int* info,
474 SLUD::gridinfo_t* grid)
476 SLUD::Z::pzgsequ(A, r, c, rowcnd, colcnd, amax, info, grid);
479 static void gsequ(SLUD::SuperMatrix* A,
double* r,
double* c,
480 double* rowcnd,
double* colcnd,
double* amax,
int* info)
482 SLUD::Z::zgsequ_dist(A, r, c, rowcnd, colcnd, amax, info);
485 static void laqgs_loc(SLUD::SuperMatrix* A,
double* r,
double* c,
486 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
488 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
489 SLUD::Z::pzlaqgs(A, r, c, rowcnd, colcnd, amax, &eq);
490 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
493 static void laqgs(SLUD::SuperMatrix* A,
double* r,
double* c,
494 double rowcnd,
double colcnd,
double amax, SLUD::DiagScale_t* equed)
496 char eq = AMESOS2_SLUD_GET_EQUED(*equed);
497 SLUD::Z::zlaqgs_dist(A, r, c, rowcnd, colcnd, amax, &eq);
498 *equed = AMESOS2_SLUD_GET_DIAG_SCALE(eq);
501 static void distribute(SLUD::fact_t fact, SLUD::int_t n,
502 SLUD::SuperMatrix* A, SLUD::Glu_freeable_t* glu_freeable,
503 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid)
505 SLUD::Z::zdistribute(fact, n, A, glu_freeable, lu, grid);
508 static void pdistribute(SLUD::fact_t fact, SLUD::int_t n,
509 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
510 SLUD::Glu_freeable_t* glu_freeable, type_map::LUstruct_t* lu,
511 SLUD::gridinfo_t* grid)
513 SLUD::Z::pzdistribute(fact, n, A, scale_perm, glu_freeable, lu, grid);
516 static void dist_psymbtonum(SLUD::fact_t fact, SLUD::int_t n,
517 SLUD::SuperMatrix* A, SLUD::ScalePermstruct_t* scale_perm,
518 SLUD::Pslu_freeable_t* pslu_freeable, type_map::LUstruct_t* lu,
519 SLUD::gridinfo_t* grid)
521 SLUD::Z::zdist_psymbtonum(fact, n, A, scale_perm, pslu_freeable, lu, grid);
524 static double plangs(
char* norm, SLUD::SuperMatrix* A, SLUD::gridinfo_t* grid)
526 return SLUD::Z::pzlangs(norm, A, grid);
529 static void SolveInit(SLUD::superlu_options_t* options, SLUD::SuperMatrix* A,
530 SLUD::int_t* perm_r, SLUD::int_t* perm_c, SLUD::int_t nrhs,
531 type_map::LUstruct_t* lu, SLUD::gridinfo_t* grid,
532 type_map::SOLVEstruct_t* solve_struct)
534 SLUD::Z::zSolveInit(options, A, perm_r, perm_c, nrhs, lu, grid, solve_struct);
537 static void LUstructInit(SLUD::int_t m, SLUD::int_t n, type_map::LUstruct_t* lu)
539 SLUD::Z::LUstructInit(m, n, lu);
542 static void Destroy_LU(SLUD::int_t m, SLUD::gridinfo_t* grid, type_map::LUstruct_t* lu)
544 SLUD::Z::Destroy_LU(m, grid, lu);
547 static void LUstructFree(type_map::LUstruct_t* lu)
549 SLUD::Z::LUstructFree(lu);
552 static void SolveFinalize(SLUD::superlu_options_t* options,
553 type_map::SOLVEstruct_t* solve_struct)
555 SLUD::Z::zSolveFinalize(options, solve_struct);
558 #endif // HAVE_TEUCHOS_COMPLEX
563 #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. ...