Language Reference


TRISOLV Function

TRISOLV (form, R, b <, piv> );

The TRISOLV function efficiently solves linear systems that involve a triangular matrix.

The TRISOLV function returns the $n \times p$ matrix $\bX $ that contains p solutions of the p linear systems specified by form, R, and b.

The arguments to the TRISOLV function are as follows:

form

specifies which of the following form of a triangular linear system is to be solved:

form=1

solve $\bR x = b$, $\bR $ upper triangular

form=2

solve $\bR ^{\prime } x = b$, $\bR $ upper triangular

form=3

solve $\bR ^{\prime } x = b$, $\bR $ lower triangular

form=4

solve $\bR x = b$, $\bR $ lower triangular

R

specifies the $n \times n$ nonsingular upper (form=1,2) or lower (form=3,4) triangular coefficient matrix $\bR $. Only the upper or lower triangle of argument matrix R is used; the other triangle can contain any information.

b

specifies the $n \times p$ matrix, $\bB $, of p right-hand sides $b_ k, k=1 \ldots p$.

piv

specifies an optional n vector that relates the order of the columns of matrix $\bR $ to the order of the columns of an original coefficient matrix $\bA $ for which matrix $\bR $ has been computed as a factor. For example, the vector piv can be the result of the QR decomposition of a matrix $\bA $ whose columns were permuted in the order $\bA _{piv[1]}, \ldots , \bA _{piv[n]}$.

For form=1 and form=3, the solution is obtained by backward elimination. For form=2 and form=4, the solution is obtained by forward substitution.

If TRISOLV recognizes the upper or lower triangular matrix $\bR $ as a singular matrix (that is, one that contains at least one zero diagonal element), it exits with an error message.

Consider the following example:

R = { 1  0  0  0,
      3  2  0  0,
      1 -3  5  0,
      2  7  9 -1 };

b = {1, 1, 4, -6 };
x = trisolv(4, R, b);
print x;

Figure 25.417: Solution of a Triangular System

x
1
-1
0
1



Also see the example in section The Full-Rank Linear Least Squares Problem.