51 #define __FUNC__ "bicgstab_euclid"
58 double atol = ctx->
atol, rtol = ctx->
rtol;
61 double alpha, alpha_1,
63 widget, widget_1, rho_1, rho_2, s_norm, eps, exit_a, b_iprod, r_iprod;
66 double *t, *s, *s_hat, *v, *p, *p_hat, *r, *r_hat;
71 t = (
double *)
MALLOC_DH (m *
sizeof (
double));
72 s = (
double *)
MALLOC_DH (m *
sizeof (
double));
73 s_hat = (
double *)
MALLOC_DH (m *
sizeof (
double));
74 v = (
double *)
MALLOC_DH (m *
sizeof (
double));
75 p = (
double *)
MALLOC_DH (m *
sizeof (
double));
76 p_hat = (
double *)
MALLOC_DH (m *
sizeof (
double));
77 r = (
double *)
MALLOC_DH (m *
sizeof (
double));
78 r_hat = (
double *)
MALLOC_DH (m *
sizeof (
double));
89 exit_a = atol * atol * b_iprod;
91 eps = rtol * rtol * b_iprod;
110 beta_1 = (rho_1 / rho_2) * (alpha_1 / widget_1);
113 Axpy (m, -widget_1, v, p);
139 Axpy (m, -alpha, v, s);
149 SET_INFO (
"reached absolute stopping criteria");
168 widget = tmp1 / tmp2;
172 Axpy (m, alpha, p_hat, x);
174 Axpy (m, widget, s_hat, x);
180 Axpy (m, -widget, t, r);
190 SET_INFO (
"stipulated residual reduction achieved");
197 fprintf (stderr,
"[it = %i] %e\n", its, sqrt (r_iprod / b_iprod));
225 #define __FUNC__ "cg_euclid"
231 double alpha, beta, gamma, gamma_old, eps, bi_prod, i_prod;
235 double rtol = ctx->
rtol;
243 eps = (rtol * rtol) * bi_prod;
245 p = (
double *)
MALLOC_DH (m *
sizeof (
double));
246 s = (
double *)
MALLOC_DH (m *
sizeof (
double));
247 r = (
double *)
MALLOC_DH (m *
sizeof (
double));
283 Axpy (m, alpha, p, x);
287 Axpy (m, -alpha, s, r);
304 fprintf (stderr,
"iter = %i rel. resid. norm: %e\n", its,
305 sqrt (i_prod / bi_prod));
313 beta = gamma / gamma_old;
double InnerProd(int n, double *x, double *y)
void Euclid_dhApply(Euclid_dh ctx, double *rhs, double *lhs)
bool Parser_dhHasSwitch(Parser_dh p, char *s)
void Axpy(int n, double alpha, double *x, double *y)
void cg_euclid(Mat_dh A, Euclid_dh ctx, double *x, double *b, int *itsOUT)
void Mat_dhMatVec(Mat_dh mat, double *x, double *b)
void ScaleVec(int n, double alpha, double *x)
void bicgstab_euclid(Mat_dh A, Euclid_dh ctx, double *x, double *b, int *itsOUT)
void CopyVec(int n, double *xIN, double *yOUT)