The GS_ITER function solves an n by n linear system of equations using Gauss-Seidel iteration with over- and under-relaxation to enhance convergence.
Note that the equations must be entered in diagonally dominant form to guarantee convergence. A system is diagonally dominant if the diagonal element in a given row is greater than the sum of the absolute values of the non-diagonal elements in that row.
This routine is written in the IDL language. Its source code can be found in the file
gs_iter.pro
in the
lib
subdirectory of the IDL distribution.
Set this keyword to check the array A for diagonal dominance. If A is not in diagonally dominant form, GS_ITER reports the fact but continues processing on the chance that the algorithm may converge.
A scalar value in the range: [0.0, 2.0]. This value determines the amount of relaxation . Relaxation is a weighting technique used to enhance convergence.
B = [12.0, 2.0, -9.0] ; Define the right-hand side vector B.
RESULT = GS_ITER(A, B, /CHECK) ; Compute the solution to the system.
Input matrix is not in Diagonally Dominant form.
% GS_ITER: Algorithm failed to converge within given parameters.
Since the A represents a system of linear equations, we can reorder it into diagonally dominant form by rearranging the rows:
Make corresponding changes in the ordering of B.
RESULT = GS_ITER(A, B, /CHECK) ; Compute the solution to the system.