The LA_LUSOL function is used in conjunction with the LA_LUDC procedure to solve a set of n linear equations in n unknowns, AX = B. The parameter A is not the original array, but its LU decomposition, created by the routine LA_LUDC.

The LA_LUSOL function may also be used to solve for multiple systems of linear equations, with each column of B representing a different set of equations. In this case, the result is a k-by-n array where each of the k columns represents the solution vector for that set of equations.

LA_LUSOL is based on the following LAPACK routines:

Output Type

LAPACK Routine

Float

sgetrs

Double

dgetrs

Complex

cgetrs

Double complex

zgetrs

Examples


Given the system of equations:

4u + 16000v + 17000w = 100.1
2u +     5v +     8w = 0.1
3u +     6v +    10w = 0.01

the solution can be derived with the following code:

; Define the coefficient array:
a = [[4, 16000, 17000], $
   [2, 5, 8], $
   [3, 6, 10]]
; Compute the LU decomposition:
aludc = a
; make a copy
LA_LUDC, aludc, index
; Define the right-hand side vector B:
b = [100.1, 0.1, 0.01]
 
; Compute and print the solution to Ax=b:
x = LA_LUSOL(aludc, index, b)
PRINT, 'LA_LUSOL Solution:', x

IDL prints:

LA_LUSOL solution:    -0.397355    -0.334742     0.321033

The exact solution to 6 decimal places is [-0.397432, -0.334865, 0.321149].

Note: UNIX users may see slightly different output results.

Syntax


Result = LA_LUSOL( A, Index, B [, /DOUBLE] )

Return Value


The result is an n-element vector or k-by-n array.

Arguments


A

The n-by-n LU decomposition of an array, created by the LA_LUDC procedure.

Note: LA_LUSOL cannot accept any non-square output generated by LA_LUDC.

Index

An n-element input vector, created by the LA_LUDC procedure, containing the row permutations which occurred as a result of partial pivoting.

B

An n-element input vector containing the right-hand side of the linear system, or a k-by-n array, where each of the k columns represents a different linear system.

Keywords


DOUBLE

Set this keyword to use double-precision for computations and to return a double-precision (real or complex) result. Set DOUBLE = 0 to use single-precision for computations and to return a single-precision (real or complex) result. The default is /DOUBLE if A is double precision, otherwise the default is DOUBLE = 0.

Version History


5.6

Introduced

Resources and References


For details see Anderson et al., LAPACK Users' Guide, 3rd ed., SIAM, 1999.

See Also


LA_LINEAR_EQUATION, LA_LUDC, LA_LUMPROVE, LUSOL