# ForwSub

Advanced Analysis Library Only

AnalysisLibErrType ForwSub (void *inputMatrixA, double knownVectorY[], int arraySizes, double outputVectorX[], int permutationVector[]);

## Purpose

Solves the linear equations a × x = y by forward substitution. ForwSub assumes a to be an arraySizes-by-arraySizes lower triangular matrix with all diagonal elements equal to one. ForwSub obtains x using the following formulas:

x0 = y0

for i = 1, 2, . . ., n — 1

ForwSub can perform the operation in place; that is, the input and output arrays can be the same.

The input matrix must be a lower triangular matrix or a matrix obtained from LU decomposition.

### Example

/* to solve a linear equation A*x = y */
double A[10][10], x[10], y[10];
int p[10]; /* permutation vector */
int sign, n;
n = 10;
LU (A, n, p, &sign); /* LU decomposition of A */
ForwSub (A, y, n, x, p); /* forward substitution */
BackSub (A, x, n, x); /* backward substitution */

## Parameters

Input
Name | Type | Description
inputMatrixA | numeric array | Input matrix. This matrix must be an array of doubles.
knownVectorY | double-precision array | Array that represents the set of known vector coefficients.
arraySizes | integer | The number of rows and columns in the square input matrix and the number of elements in the known vector array.
permutationVector | integer array | An input vector obtained from the LU decomposition. This vector has the row exchange information. If there was no row exchange in LU, pi = i.
Output
Name | Type | Description
outputVectorX | double-precision array | Solution vector.

## 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.