The LINBCG function is used in conjunction with SPRSIN to solve a set of n sparse linear equations with n unknowns using the iterative biconjugate gradient method.
LINBCG is based on the routine linbcg described in section 2.7 of Numerical Recipes in C: The Art of Scientific Computing (Second Edition), published by Cambridge University Press, and is used by permission.
| Note |
Result = LINBCG( A, B, X [, /DOUBLE] [, ITOL={4 | 5 | 6 | 7}] [, TOL=value] [, ITER=variable] [, ITMAX=value] )
The result is an n-element vector.
A row-indexed sparse array created by the SPRSIN function.
An n-element vector containing the right-hand side of the linear system Ax=b.
An n-element vector containing the initial solution of the linear system.
Set this keyword to force the computation to be done in double-precision arithmetic.
Use this keyword to specify which convergence test should be used. Set ITOL to one of the following:
Use this keyword to specify the desired convergence tolerance. For single-precision calculations, the default value is 1.0 ´ 10-7. For double-precision values, the default is 1.0 ´ 10-14.
Use this keyword to specify an output variable that will be set to the number of iterations performed.
The maximum allowed number of iterations. The default is n2.
; Begin with an array A: A = [[ 5.0, 0.0, 0.0, 1.0, -2.0], $ [ 3.0, -2.0, 0.0, 1.0, 0.0], $ [ 4.0, -1.0, 0.0, 2.0, 0.0], $ [ 0.0, 3.0, 3.0, 1.0, 0.0], $ [-2.0, 0.0, 0.0, -1.0, 2.0]] ; Define a right-hand side vector B: B = [7.0, 1.0, 3.0, 3.0, -4.0] ; Start with an initial guess at the solution: X = REPLICATE(1.0, N_ELEMENTS(B)) ; Solve the linear system Ax=b: result = LINBCG(SPRSIN(A), B, X) ; Print the result: PRINT, result
IDL prints:
1.00000 1.00000 8.94134e-008 -2.37107e-007 -1.00000
The exact solution is [1, 1, 0, 0, -1].
Introduced: 4.0
FULSTR, READ_SPR, SPRSAB, SPRSAX, SPRSIN, SPRSTP, WRITE_SPR