Admin Production ni-theme
Current Publication

LU

LabWindows/CVI

LU

Advanced Analysis Library Only

AnalysisLibErrType LU (void *matrix, ssize_t matrixVectorSize, ssize_t permutationVector[], int *sign);

Purpose

Performs an LU matrix decomposition:

A = LU

where L is an n-by-n lower triangular matrix with main diagonal elements all equal to one
U is an upper triangular matrix
n is matrixVectorSize

Use LU in conjunction with BackSub and ForwSub to solve a set of linear equations with the same matrix A.

The following example solves two linear equations, a*x1 = y1 and a*x2 = y2.

LU(a, n, p, &sign)
ForwSub(a, y1, n, x1, p);
BackSub(a, x1, n, x1);

ForSub(a, y2, n, x2, p);
BackSub(a, x2, n, x2);

After LU executes, LU replaces the input matrix with two triangular matrices. L occupies the lower triangular part of matrix, and U occupies the upper triangular part of matrix. The permutation vector records possible row exchange information in the LU decomposition. sign = 0 indicates that there is no such exchange or that there is an even number of such exchanges. sign = 1 indicates that there is an odd number of such exchanges. permutationVector and sign are useful when solving the linear equations or computing the determinant.

For more information, refer to Numerical Recipes in C: The Art of Scientific Computing by Press, et al., cited in the Bibliography.

Parameters

Input
Name Type Description
matrixVectorSize ssize_t The number of rows and columns in the square input matrix and the number of elements in the permutation vector.
Output
Name Type Description
matrix void * On input, the square matrix. On output, the decomposed matrix. This matrix must be an array of doubles.
permutationVector ssize_t [] Permutation information obtained from the LU decomposition. This vector is needed if you plan to call ForwSub.
sign int 0 if there were an even number of row exchanges during the LU decomposition, or no exchanges. Contains 1 if there were an odd number of row exchanges during the LU decomposition. sign is useful in computing the determinant.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 3.1 and later