Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


Harris Geospatial / Docs Center / IDL Reference / Math - LAPACK / LA_LINEAR_EQUATION

LA_LINEAR_EQUATION

LA_LINEAR_EQUATION

The LA_LINEAR_EQUATION function uses LU decomposition to solve a system of linear equations, AX = B, and provides optional error bounds and backward error estimates.

The LA_LINEAR_EQUATION 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.

This routine is written in the IDL language. Its source code can be found in the file la_linear_equation.pro in the lib subdirectory of the IDL distribution.

Examples


Given the system of equations:

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

The following program can be used to find the solution:

; Define the coefficient array:
a = [[4, 16000, 17000], $
   [2, 5, 8], $
   [3, 6, 10]]
; Define the right-hand side vector b:
b = [100.1, 0.1, 0.01]
 
; Compute and print the solution to ax=b:
x = LA_LINEAR_EQUATION(a, b)
PRINT, 'LA_LINEAR_EQUATION solution:', X

IDL prints:

LA_LINEAR_EQUATION solution:
-0.397432    -0.334865     0.321148

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

Syntax


Result = LA_LINEAR_EQUATION( Array, B [, BACKWARD_ERROR=variable] [, /DOUBLE] [, FORWARD_ERROR=variable] [, STATUS=variable])

Return Value


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

Arguments


Array

The n-by-n array of the linear system AX = B.

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


BACKWARD_ERROR

Set this keyword to a named variable that will contain the relative backward error estimate for each linear system. If B is a vector containing a single linear system, then BACKWARD_ERROR will be a scalar. If B is an array containing k linear systems, then BACKWARD_ERROR will be a k-element vector. The backward error is the smallest relative change in any element of A or B that makes X an exact solution.

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 Array is double precision, otherwise the default is DOUBLE = 0.

FORWARD_ERROR

Set this keyword to a named variable that will contain the estimated forward error bound for each linear system. If B is a vector containing a single linear system, then FORWARD_ERROR will be a scalar. If B is an array containing k linear systems, then FORWARD_ERROR will be a k-element vector. For each linear system, if Xtrue is the true solution corresponding to X, then the forward error is an estimated upper bound for the magnitude of the largest element in (X - Xtrue) divided by the magnitude of the largest element in X.

STATUS

Set this keyword to a named variable that will contain the status of the computation. Possible values are:

  • STATUS = 0: The computation was successful.
  • STATUS > 0: The computation failed because one of the diagonal elements of the LU decomposition is zero. The STATUS value specifies which value along the diagonal (starting at one) is zero.

Note: If STATUS is not specified, any error messages will be output to the screen.

Version History


5.6

Introduced

See Also


LA_LUDC, LA_LUMPROVE, LA_LUSOL



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us