Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
KryPcg.c File Reference

Krylov subspace methods – Preconditioned CG. More...

#include <math.h>
#include "fasp.h"
#include "fasp_functs.h"
#include "KryUtil.inl"

Go to the source code of this file.

Functions

INT fasp_solver_dcsr_pcg (dCSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
 Preconditioned conjugate gradient method for solving Au=b. More...
 
INT fasp_solver_dbsr_pcg (dBSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
 Preconditioned conjugate gradient method for solving Au=b. More...
 
INT fasp_solver_dblc_pcg (dBLCmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
 Preconditioned conjugate gradient method for solving Au=b. More...
 
INT fasp_solver_dstr_pcg (dSTRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
 Preconditioned conjugate gradient method for solving Au=b. More...
 
INT fasp_solver_pcg (mxv_matfree *mf, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
 

Detailed Description

Krylov subspace methods – Preconditioned CG.

Note
This file contains Level-3 (Kry) functions. It requires: AuxArray.c, AuxMemory.c, AuxMessage.c, BlaArray.c, BlaSpmvBLC.c, BlaSpmvBSR.c, BlaSpmvCSR.c, and BlaSpmvSTR.c
See KrySPcg.c for a safer version

Reference: Y. Saad 2003 Iterative methods for sparse linear systems (2nd Edition), SIAM


Copyright (C) 2009–Present by the FASP team. All rights reserved.

Released under the terms of the GNU Lesser General Public License 3.0 or later.

Abstract algorithm

PCG method to solve A*x=b is to generate {x_k} to approximate x

Step 0. Given A, b, x_0, M

Step 1. Compute residual r_0 = b-A*x_0 and convergence check;

Step 2. Initialization z_0 = M^{-1}*r_0, p_0=z_0;

Step 3. Main loop ...

FOR k = 0:MaxIt

  • get step size alpha = f(r_k,z_k,p_k);
  • update solution: x_{k+1} = x_k + alpha*p_k;
  • perform stagnation check;
  • update residual: r_{k+1} = r_k - alpha*(A*p_k);
  • perform residual check;
  • obtain p_{k+1} using {p_0, p_1, ... , p_k};
  • prepare for next iteration;
  • print the result of k-th iteration; END FOR

Convergence check: norm(r)/norm(b) < tol

Stagnation check:

  • IF norm(alpha*p_k)/norm(x_{k+1}) < tol_stag
    1. compute r=b-A*x_{k+1};
    2. convergence check;
    3. IF ( not converged & restart_number < Max_Stag_Check ) restart;
  • END IF

Residual check:

  • IF norm(r_{k+1})/norm(b) < tol
    1. compute the real residual r = b-A*x_{k+1};
    2. convergence check;
    3. IF ( not converged & restart_number < Max_Res_Check ) restart;
  • END IF

Definition in file KryPcg.c.

Function Documentation

◆ fasp_solver_dblc_pcg()

INT fasp_solver_dblc_pcg ( dBLCmat A,
dvector b,
dvector u,
precond pc,
const REAL  tol,
const REAL  abstol,
const INT  MaxIt,
const SHORT  StopType,
const SHORT  PrtLvl 
)

Preconditioned conjugate gradient method for solving Au=b.

Parameters
APointer to dBLCmat: coefficient matrix
bPointer to dvector: right hand side
uPointer to dvector: unknowns
pcPointer to precond: structure of precondition
tolTolerance for relative residual
abstolTolerance for absolute residual
MaxItMaximal number of iterations
StopTypeStopping criteria type
PrtLvlHow much information to print out
Returns
Iteration number if converges; ERROR otherwise.
Author
Xiaozhe Hu
Date
05/24/2010

Modified by Chensong Zhang on 03/28/2013

Definition at line 678 of file KryPcg.c.

◆ fasp_solver_dbsr_pcg()

INT fasp_solver_dbsr_pcg ( dBSRmat A,
dvector b,
dvector u,
precond pc,
const REAL  tol,
const REAL  abstol,
const INT  MaxIt,
const SHORT  StopType,
const SHORT  PrtLvl 
)

Preconditioned conjugate gradient method for solving Au=b.

Parameters
APointer to dBSRmat: coefficient matrix
bPointer to dvector: right hand side
uPointer to dvector: unknowns
pcPointer to precond: structure of precondition
tolTolerance for relative residual
abstolTolerance for absolute residual
MaxItMaximal number of iterations
StopTypeStopping criteria type
PrtLvlHow much information to print out
Returns
Iteration number if converges; ERROR otherwise.
Author
Xiaozhe Hu
Date
05/26/2014

Definition at line 386 of file KryPcg.c.

◆ fasp_solver_dcsr_pcg()

INT fasp_solver_dcsr_pcg ( dCSRmat A,
dvector b,
dvector u,
precond pc,
const REAL  tol,
const REAL  abstol,
const INT  MaxIt,
const SHORT  StopType,
const SHORT  PrtLvl 
)

Preconditioned conjugate gradient method for solving Au=b.

Parameters
APointer to dCSRmat: coefficient matrix
bPointer to dvector: right hand side
uPointer to dvector: unknowns
pcPointer to precond: structure of precondition
tolTolerance for relative residual
abstolTolerance for absolute residual
MaxItMaximal number of iterations
StopTypeStopping criteria type
PrtLvlHow much information to print out
Returns
Iteration number if converges; ERROR otherwise.
Author
Chensong Zhang, Xiaozhe Hu, Shiquan Zhang
Date
05/06/2010

Definition at line 96 of file KryPcg.c.

◆ fasp_solver_dstr_pcg()

INT fasp_solver_dstr_pcg ( dSTRmat A,
dvector b,
dvector u,
precond pc,
const REAL  tol,
const REAL  abstol,
const INT  MaxIt,
const SHORT  StopType,
const SHORT  PrtLvl 
)

Preconditioned conjugate gradient method for solving Au=b.

Parameters
APointer to dSTRmat: coefficient matrix
bPointer to dvector: right hand side
uPointer to dvector: unknowns
pcPointer to precond: structure of precondition
tolTolerance for relative residual
abstolTolerance for absolute residual
MaxItMaximal number of iterations
StopTypeStopping criteria type
PrtLvlHow much information to print out
Returns
Iteration number if converges; ERROR otherwise.
Author
Zhiyang Zhou
Date
04/25/2010

Modified by Chensong Zhang on 03/28/2013

Definition at line 970 of file KryPcg.c.

◆ fasp_solver_pcg()

INT fasp_solver_pcg ( mxv_matfree mf,
dvector b,
dvector u,
precond pc,
const REAL  tol,
const REAL  abstol,
const INT  MaxIt,
const SHORT  StopType,
const SHORT  PrtLvl 
)

Definition at line 1260 of file KryPcg.c.