# Conjugate gradient method of Golub and van Loan

(Difference between revisions)
 Revision as of 05:34, 14 September 2005 (view source)Zxaar (Talk | contribs)← Older edit Latest revision as of 12:39, 19 December 2008 (view source)Peter (Talk | contribs) m (Reverted edits by SitelTrlet (Talk) to last version by Tsaad) (6 intermediate revisions not shown) Line 12: Line 12: === Algorithm === === Algorithm === + ---- - Allocate temperary vectors p,z,q
+ :  Allocate temperary vectors p,z,q
- Allocate temerary reals rho_0, rho_1 , alpha, beta
+ :  Allocate temerary reals rho_0, rho_1 , alpha, beta
- + :
- r := b - A$\bullet$x
+ :  r := b - A$\cdot$x
- for i := 1 step 1 until max_itr do + :
- solve (M$\bullet$z = r )
+ :  for i := 1 step 1 until max_itr do - beta := rho_0 / rho_1
+ ::    solve (M$\cdot$z = r )
- p := z + beta$\bullet$p
+ ::      beta := rho_0 / rho_1
- q := A$\bullet$p
+ ::      p := z + beta$\cdot$p
- alpha = rho_0 / ( p$\bullet$q  )
+ ::      q := A$\bullet$p
- x := x + alpha$\bullet$p
+ ::      alpha = rho_0 / ( p$\cdot$q  )
- r := r - alpha$\bullet$q
+ ::      x := x + alpha$\cdot$p
- rho_1 = rho_0
+ ::      r := r - alpha$\cdot$q
- end (i-loop) + ::      rho_1 = rho_0
- + :  end (i-loop) - deallocate all temp memory
+ :
- return TRUE
+ :  deallocate all temp memory
- + :  return TRUE
+ ---- == Reference == == Reference == - ''Ferziger, J.H. and Peric, M. 2002''. "Computational Methods for Fluid Dynamics", 3rd rev. ed., Springer-Verlag, Berlin. + #'''Richard Barret, Michael Berry, Tony F. Chan, James Demmel, June M. Donato, Jack Dongarra, Victor Eijihout, Roldan Pozo, Charles Romine, Henk Van der Vorst''', "Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods" + #'''Ferziger, J.H. and Peric, M. 2002'''. Computational Methods for Fluid Dynamics, 3rd rev. ed., Springer-Verlag, Berlin. + + + ---- + Return to [[Numerical methods | Numerical Methods]]

## Contents

Conjugate gradient method could be summarized as follows

### System of equation

For the given system of equation
Ax = b ;
b = source vector
x = solution variable for which we seek the solution
A = coefficient matrix

M = the precondioning matrix constructued by matrix A

### Algorithm

Allocate temperary vectors p,z,q
Allocate temerary reals rho_0, rho_1 , alpha, beta

r := b - A$\cdot$x

for i := 1 step 1 until max_itr do
solve (M$\cdot$z = r )
beta := rho_0 / rho_1
p := z + beta$\cdot$p
q := A$\bullet$p
alpha = rho_0 / ( p$\cdot$q )
x := x + alpha$\cdot$p
r := r - alpha$\cdot$q
rho_1 = rho_0
end (i-loop)

deallocate all temp memory
return TRUE

## Reference

1. Richard Barret, Michael Berry, Tony F. Chan, James Demmel, June M. Donato, Jack Dongarra, Victor Eijihout, Roldan Pozo, Charles Romine, Henk Van der Vorst, "Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods"
2. Ferziger, J.H. and Peric, M. 2002. Computational Methods for Fluid Dynamics, 3rd rev. ed., Springer-Verlag, Berlin.