| ADPCG 1.0.0

adpcg.h
Go to the documentation of this file.
1
14#ifndef adpcg_h
15#define adpcg_h
16
17
18#include <stddef.h>
19
20#ifdef ADPCG_64
21 typedef int64_t cgint;
22#define id "%lld"
23#else
24 typedef int32_t cgint;
25#define id "%d"
26#endif
27
28#define cgerr(x) printf(x);
29
30/* Return code */
31#define CG_OK (0)
32#define CG_ERR (1)
33
34/* Boolean */
35#define CG_TRUE (1)
36#define CG_FALSE (0)
37
38/* Pre-conditioner */
39#define CG_PRECOND_DIAG (10)
40#define CG_PRECOND_CHOL (11)
41#define CG_NO_PRECOND (12)
42
43/* Solution status */
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)
49
50/* Auxiliary macros */
51#ifndef MIN
52#define MIN(a, b) (((a)<(b))?(a):(b))
53#endif /* MIN */
54#ifndef MAX
55#define MAX(a, b) (((a)>(b))?(a):(b))
56#endif /* MAX */
57
84 typedef struct {
85
86 void *A;
87 void *r;
88 void *rnew;
89 void *d;
90 void *pinvr;
91 void *Ad;
92 void *x;
93 void *aux;
94 void *btmp;
95
96 cgint ptype;
97 void *chol;
98 void *diag;
99
100 double tol;
101 double rnrm;
102 double avgsvtime;
103 double avgfctime;
104 double currenttime;
105 double latesttime;
106
107 cgint n;
108 cgint niter;
109 cgint maxiter;
110 cgint status;
111 cgint reuse;
112 cgint nused;
113 cgint nmaxiter;
114 cgint restart;
115 cgint nfactors;
116 cgint nrounds;
117 cgint nsolverd;
118 cgint nsolves;
119
120 /* Vector operations */
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);
131
132 /* Matrix operations */
133 cgint (*A_chol) (void *A);
134 cgint (*A_cond) (void *A);
135 void (*A_getdiag) (void *A, void *diag);
136
137 /* Matrix-vector operations */
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);
142
143} adpcg;
144
145
146#endif /* adpcg_h */
adpcg
Working struct for the adaptive CG solver.
Definition: adpcg.h:84
adpcg::rnrm
double rnrm
Residual norm.
Definition: adpcg.h:101
adpcg::rnew
void * rnew
Workspace array.
Definition: adpcg.h:88
adpcg::tol
double tol
Relative tolerance of CG.
Definition: adpcg.h:100
adpcg::pinvr
void * pinvr
Workspace array.
Definition: adpcg.h:90
adpcg::avgfctime
double avgfctime
Average factorization time of previous CG solves.
Definition: adpcg.h:103
adpcg::x
void * x
CG solution vector.
Definition: adpcg.h:92
adpcg::currenttime
double currenttime
Buffer of solution time in the current round.
Definition: adpcg.h:104
adpcg::diag
void * diag
Diagonal pre-conditioner.
Definition: adpcg.h:98
adpcg::aux
void * aux
CG auxiliary array.
Definition: adpcg.h:93
adpcg::maxiter
cgint maxiter
Maximum number of iterations.
Definition: adpcg.h:109
adpcg::nrounds
cgint nrounds
Number of rounds of solves.
Definition: adpcg.h:116
adpcg::nsolves
cgint nsolves
Number of linear systems solved.
Definition: adpcg.h:118
adpcg::n
cgint n
Dimension of linear system.
Definition: adpcg.h:107
adpcg::r
void * r
Residual.
Definition: adpcg.h:87
adpcg::A
void * A
LHS data.
Definition: adpcg.h:86
adpcg::Ad
void * Ad
Workspace array.
Definition: adpcg.h:91
adpcg::restart
cgint restart
Restart frequency.
Definition: adpcg.h:114
adpcg::nfactors
cgint nfactors
Number of factorizes performed so far.
Definition: adpcg.h:115
adpcg::niter
cgint niter
Number of iterations in most recent solve.
Definition: adpcg.h:108
adpcg::nsolverd
cgint nsolverd
Number of solves in a round.
Definition: adpcg.h:117
adpcg::chol
void * chol
Cholesky pre-conditioner.
Definition: adpcg.h:97
adpcg::nmaxiter
cgint nmaxiter
Number of non-successfull solves.
Definition: adpcg.h:113
adpcg::Av
void(* Av)(void *A, void *v, void *Av)
Compute Av = A * v.
Definition: adpcg.h:140
adpcg::ptype
cgint ptype
Pre-conditioner type.
Definition: adpcg.h:96
adpcg::nused
cgint nused
Number of rounds current Cholesky pre-conditioner is already used.
Definition: adpcg.h:112
adpcg::d
void * d
Workspace array.
Definition: adpcg.h:89
adpcg::avgsvtime
double avgsvtime
Averate solution time of previous CG solves.
Definition: adpcg.h:102
adpcg::status
cgint status
Solution status.
Definition: adpcg.h:110
adpcg::latesttime
double latesttime
Time for the latest solve.
Definition: adpcg.h:105
adpcg::btmp
void * btmp
CG temporary RHS array.
Definition: adpcg.h:94
adpcg::reuse
cgint reuse
Reuse Cholesky pre-conditioner.
Definition: adpcg.h:111