25#include "fasp_functs.h"
77 REAL *r, *Br, *beta, *p;
78 r = work; Br = r + m; beta = Br + m; p = beta + MaxIt;
81 if ( PrtLvl >
PRINT_NONE ) printf(
"\nCalling GCG solver (CSR) ...\n");
84 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
85 printf(
"### DEBUG: maxit = %d, tol = %.4le\n", MaxIt, tol);
116 relres = absres/normb;
119 fasp_itinfo(PrtLvl,StopType,iter,relres,absres,factor);
124 for ( iter = 1; iter < MaxIt ; iter++) {
135 for (i=0; i<iter; i++) {
160 relres = absres/normb;
163 fasp_itinfo(PrtLvl,StopType,iter,relres,absres,factor);
165 if (relres < tol)
break;
173 if ( PrtLvl >
PRINT_NONE ) ITS_FINAL(iter,MaxIt,relres);
179 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
219 const SHORT StopType,
225 REAL alpha, factor, gama_1, gama_2;
230 REAL *r, *Br, *beta, *p, *q;
231 q = work; r = q + m; Br = r + m; beta = Br + m; p = beta + MaxIt;
234 if ( PrtLvl >
PRINT_NONE ) printf(
"\nCalling GCG solver (MatFree) ...\n");
237 printf(
"### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
238 printf(
"### DEBUG: maxit = %d, tol = %.4le\n", MaxIt, tol);
271 relres = absres/normb;
274 fasp_itinfo(PrtLvl,StopType,iter+1,relres,absres,factor);
279 for ( iter = 1; iter < MaxIt ; iter++) {
290 for (i=0; i<iter; i++) {
295 beta[i] = (-1.0) * ( gama_1 / gama_2 );
305 mf->
fct(mf->
data, p+iter*m, q);
313 mf->
fct(mf->
data, p+iter*m, q);
320 relres = absres/normb;
323 fasp_itinfo(PrtLvl,StopType,iter+1,relres,absres,factor);
325 if (relres < tol)
break;
333 if ( PrtLvl >
PRINT_NONE ) ITS_FINAL(iter,MaxIt,relres);
339 printf(
"### DEBUG: [--End--] %s ...\n", __FUNCTION__);
void fasp_darray_cp(const INT n, const REAL *x, REAL *y)
Copy an array to the other y=x.
void fasp_mem_free(void *mem)
Free up previous allocated memory body and set pointer to NULL.
void * fasp_mem_calloc(const unsigned int size, const unsigned int type)
Allocate, initiate, and check memory.
void fasp_itinfo(const INT ptrlvl, const INT stop_type, const INT iter, const REAL relres, const REAL absres, const REAL factor)
Print out iteration information for iterative solvers.
REAL fasp_blas_darray_dotprod(const INT n, const REAL *x, const REAL *y)
Inner product of two arraies x and y.
void fasp_blas_darray_axpby(const INT n, const REAL a, const REAL *x, const REAL b, REAL *y)
y = a*x + b*y
REAL fasp_blas_darray_norm2(const INT n, const REAL *x)
L2 norm of array x.
void fasp_blas_darray_axpy(const INT n, const REAL a, const REAL *x, REAL *y)
y = a*x + y
REAL fasp_blas_dcsr_vmv(const dCSRmat *A, const REAL *x, const REAL *y)
vector-Matrix-vector multiplication alpha = y'*A*x
void fasp_blas_dcsr_aAxpy(const REAL alpha, const dCSRmat *A, const REAL *x, REAL *y)
Matrix-vector multiplication y = alpha*A*x + y.
INT fasp_solver_pgcg(mxv_matfree *mf, dvector *b, dvector *u, precond *pc, const REAL tol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned generilzed conjugate gradient (GCG) method for solving Au=b.
INT fasp_solver_dcsr_pgcg(dCSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned generilzed conjugate gradient (GCG) method for solving Au=b.
Main header file for the FASP project.
#define SHORT
FASP integer and floating point numbers.
#define ERROR_SOLVER_MAXIT
#define BIGREAL
Some global constants.
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
Sparse matrix of REAL type in CSR format.
INT row
row number of matrix A, m
Vector with n entries of REAL type.
REAL * val
actual vector entries
Matrix-vector multiplication, replace the actual matrix.
void * data
data for MxV, can be a Matrix or something else
void(* fct)(const void *, const REAL *, REAL *)
action for MxV, void function pointer
Preconditioner data and action.
void * data
data for preconditioner, void pointer
void(* fct)(REAL *, REAL *, void *)
action for preconditioner, void function pointer