22 #ifndef __HERMES_COMMON_SUPERLU_SOLVER_H_
23 #define __HERMES_COMMON_SUPERLU_SOLVER_H_
31 #include <supermatrix.h>
37 template <
typename Scalar>
class SuperLUSolver;
39 template <
typename Scalar>
43 void gsequ(SuperMatrix *A,
double *r,
double *c,
double *rowcnd,
double *colcnd,
double *amax,
int *info);
44 void laqgs(SuperMatrix *A,
float *r,
float *c,
float rowcnd,
float colcnd,
float amax,
char *equed);
45 int gstrf(superlu_options_t *options,
int m,
int n,
double anorm, LUstruct_t *LUstruct, gridinfo_t *grid, SuperLUStat_t *stat,
int *info);
46 float pivotGrowth(
int ncols, SuperMatrix *A,
int *perm_c, SuperMatrix *L, SuperMatrix *U);
47 float langs(
char *norm, SuperMatrix *A);
48 void gscon(
char *norm, SuperMatrix *L, SuperMatrix *U,
float anorm,
float *rcond, SuperLUStat_t *stat,
int *info);
49 void gstrs(trans_t trans, SuperMatrix *L, SuperMatrix *U,
int *perm_c,
int *perm_r, SuperMatrix *B, SuperLUStat_t *stat,
int *info);
50 double lamch_(
char *cmach);
51 int querySpace(SuperMatrix *, SuperMatrix *, slu_memusage_t *);
55 typedef superlu_options_t slu_options_t;
56 typedef SuperLUStat_t slu_stat_t;
62 #define SLU_DESTROY_L Destroy_SuperNode_Matrix
63 #define SLU_DESTROY_U Destroy_CompCol_Matrix
64 #define SLU_INIT_STAT(stat_ptr) StatInit(stat_ptr)
65 #define SLU_PRINT_STAT(stat_ptr) StatPrint(stat_ptr)
67 #define SLU_DTYPE SLU_D
69 #define SLU_PRINT_CSC_MATRIX zPrint_CompCol_Matrix
70 #define Scalar_MALLOC doublecomplexMalloc
73 template<
typename Scalar>
struct SuperLuType;
77 struct SuperLuType < double >
80 typedef double Scalar;
85 struct SuperLuType <
std::complex<double> >
88 typedef struct {
double r, i; } Scalar;
100 template <
typename Scalar>
101 class HERMES_API SuperLUSolver :
public DirectSolver < Scalar >
107 SuperLUSolver(CSCMatrix<Scalar> *m, SimpleVector<Scalar> *rhs);
108 virtual ~SuperLUSolver();
110 virtual void solve();
111 virtual int get_matrix_size();
116 CSCMatrix<Scalar> *m;
119 SimpleVector<Scalar> *rhs;
132 bool check_status(
unsigned int info);
136 int *local_Ai, *local_Ap;
137 typename SuperLuType<Scalar>::Scalar *local_Ax, *local_rhs;
139 bool setup_factorization();
140 void free_factorization_data();
157 slu_options_t options;
161 void create_csc_matrix(SuperMatrix *A,
int m,
int n,
int nnz,
typename SuperLuType<Scalar>::Scalar *nzval,
int *rowind,
int *colptr,
162 Stype_t stype, Dtype_t dtype, Mtype_t mtype);
163 void solver_driver(superlu_options_t *options, SuperMatrix *A,
int *perm_c,
int *perm_r,
int *etree,
char *equed,
double *R,
164 double *C, SuperMatrix *L, SuperMatrix *U,
void *work,
int lwork, SuperMatrix *B, SuperMatrix *X,
double *recip_pivot_growth,
165 double *rcond,
double *ferr,
double *berr, slu_memusage_t *mem_usage, SuperLUStat_t *stat,
int *info);
166 void create_dense_matrix(SuperMatrix *X,
int m,
int n,
typename SuperLuType<Scalar>::Scalar *x,
int ldx, Stype_t stype, Dtype_t dtype, Mtype_t mtype);
178 template<
typename T>
friend LinearMatrixSolver<T>*
create_linear_solver(Matrix<T>* matrix, Vector<T>* rhs,
bool use_direct_solver =
false);
General namespace for the Hermes library.
Linear matrix solver functionality.
Basic cs (Compressed sparse) matrix classes and operations.
HERMES_API LinearMatrixSolver< Scalar > * create_linear_solver(Matrix< Scalar > *matrix, Vector< Scalar > *rhs, bool use_direct_solver=false)
Function returning a solver according to the users's choice.