CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Wiki > Conjugate gradient method of Golub and van Loan

Conjugate gradient method of Golub and van Loan

From CFD-Wiki

(Difference between revisions)
Jump to: navigation, search
Line 12: Line 12:
=== Algorithm ===
=== Algorithm ===
 +
----
-
  Allocate temperary vectors p,z,q <br>
+
Allocate temperary vectors p,z,q <br>
-
  Allocate temerary reals rho_0, rho_1 , alpha, beta <br>
+
Allocate temerary reals rho_0, rho_1 , alpha, beta <br>
-
+
: <br>
-
  r := b - A<math>\bullet</math>x <br>
+
r := b - A<math>\bullet</math>x <br>
-
  for i := 1 step 1 until max_itr do
+
: <br>
-
      solve (M<math>\bullet</math>z = r ) <br>
+
for i := 1 step 1 until max_itr do
-
      beta := rho_0 / rho_1 <br>
+
::    solve (M<math>\bullet</math>z = r ) <br>
-
      p := z + beta<math>\bullet</math>p <br>
+
::      beta := rho_0 / rho_1 <br>
-
      q := A<math>\bullet</math>p <br>
+
::      p := z + beta<math>\bullet</math>p <br>
-
      alpha = rho_0 / ( p<math>\bullet</math>q  ) <br>
+
::      q := A<math>\bullet</math>p <br>
-
      x := x + alpha<math>\bullet</math>p <br>
+
::      alpha = rho_0 / ( p<math>\bullet</math>q  ) <br>
-
      r := r - alpha<math>\bullet</math>q <br>
+
::      x := x + alpha<math>\bullet</math>p <br>
-
      rho_1 = rho_0 <br>
+
::      r := r - alpha<math>\bullet</math>q <br>
-
  end (i-loop)
+
::      rho_1 = rho_0 <br>
-
 
+
end (i-loop)
-
  deallocate all temp memory <br>
+
: <br>
-
  return TRUE <br>
+
deallocate all temp memory <br>
-
 
+
return TRUE <br>
 +
----

Revision as of 08:15, 14 September 2005

Contents

Conjugate gradient method

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\bulletx

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

deallocate all temp memory
return TRUE


Reference

Ferziger, J.H. and Peric, M. 2002. "Computational Methods for Fluid Dynamics", 3rd rev. ed., Springer-Verlag, Berlin.

My wiki