28#define cgerr(x) printf(x);
39#define CG_PRECOND_DIAG (10)
40#define CG_PRECOND_CHOL (11)
41#define CG_NO_PRECOND (12)
44#define CG_STATUS_SOLVED (100)
45#define CG_STATUS_MAXITER (101)
46#define CG_STATUS_FAILED (102)
47#define CG_STATUS_UNKNOWN (104)
48#define CG_STATUS_DIRECT (105)
52#define MIN(a, b) (((a)<(b))?(a):(b))
55#define MAX(a, b) (((a)>(b))?(a):(b))
121 void (*v_init) (
void *v);
122 cgint (*v_alloc) (
void *v, cgint n);
123 void (*v_free) (
void *v);
124 void (*v_copy) (
void *s,
void *t);
125 void (*v_reset) (
void *v);
126 void (*v_norm) (
void *v,
double *nrm);
127 void (*v_axpy) (
double a,
void *x,
void *y);
128 void (*v_axpby) (
double a,
void *x,
double b,
void *y);
129 void (*v_zaxpby) (
void *z,
double a,
void *x,
double b,
void *y);
130 void (*v_dot) (
void *x,
void *y,
double *xTy);
133 cgint (*A_chol) (
void *A);
134 cgint (*A_cond) (
void *A);
135 void (*A_getdiag) (
void *A,
void *diag);
138 cgint (*diagpcd)(
void *diag,
void *v);
139 cgint (*cholpcd)(
void *chol,
void *v,
void *aux);
140 void (*Av) (
void *A,
void *v,
void *
Av);
141 cgint (*Ainv) (
void *A,
void *v,
void *aux);
Working struct for the adaptive CG solver.
Definition: adpcg.h:84
double rnrm
Residual norm.
Definition: adpcg.h:101
void * rnew
Workspace array.
Definition: adpcg.h:88
double tol
Relative tolerance of CG.
Definition: adpcg.h:100
void * pinvr
Workspace array.
Definition: adpcg.h:90
double avgfctime
Average factorization time of previous CG solves.
Definition: adpcg.h:103
void * x
CG solution vector.
Definition: adpcg.h:92
double currenttime
Buffer of solution time in the current round.
Definition: adpcg.h:104
void * diag
Diagonal pre-conditioner.
Definition: adpcg.h:98
void * aux
CG auxiliary array.
Definition: adpcg.h:93
cgint maxiter
Maximum number of iterations.
Definition: adpcg.h:109
cgint nrounds
Number of rounds of solves.
Definition: adpcg.h:116
cgint nsolves
Number of linear systems solved.
Definition: adpcg.h:118
cgint n
Dimension of linear system.
Definition: adpcg.h:107
void * r
Residual.
Definition: adpcg.h:87
void * A
LHS data.
Definition: adpcg.h:86
void * Ad
Workspace array.
Definition: adpcg.h:91
cgint restart
Restart frequency.
Definition: adpcg.h:114
cgint nfactors
Number of factorizes performed so far.
Definition: adpcg.h:115
cgint niter
Number of iterations in most recent solve.
Definition: adpcg.h:108
cgint nsolverd
Number of solves in a round.
Definition: adpcg.h:117
void * chol
Cholesky pre-conditioner.
Definition: adpcg.h:97
cgint nmaxiter
Number of non-successfull solves.
Definition: adpcg.h:113
void(* Av)(void *A, void *v, void *Av)
Compute Av = A * v.
Definition: adpcg.h:140
cgint ptype
Pre-conditioner type.
Definition: adpcg.h:96
cgint nused
Number of rounds current Cholesky pre-conditioner is already used.
Definition: adpcg.h:112
void * d
Workspace array.
Definition: adpcg.h:89
double avgsvtime
Averate solution time of previous CG solves.
Definition: adpcg.h:102
cgint status
Solution status.
Definition: adpcg.h:110
double latesttime
Time for the latest solve.
Definition: adpcg.h:105
void * btmp
CG temporary RHS array.
Definition: adpcg.h:94
cgint reuse
Reuse Cholesky pre-conditioner.
Definition: adpcg.h:111