CALL GSORTH (P, T, lindep, A);
The GSORTH subroutine computes the Gram-Schmidt orthonormal factorization of the matrix , where m is greater than or equal to n. The GSORTH subroutine implements an algorithm described by Golub (1969).
The GSORTH subroutine has a single input argument:
is an input matrix.
The output arguments to the GSORTH subroutine are as follows:
is an column-orthonormal output matrix.
is an upper triangular output matrix.
is a flag with a value of 0 if columns of A are independent and a value of 1 if they are dependent. The lindep argument is an output scalar.
Specifically, the GSORTH subroutine computes the column-orthonormal matrix and the upper triangular matrix such that
If the columns of are linearly independent (that is, rank), then is full-rank column-orthonormal: , is nonsingular, and the value of lindep (a scalar) is set to 0. If the columns of are linearly dependent (say, rank) then columns of are set to 0, the corresponding rows of are set to 0 ( is singular), and lindep is set to 1. The pattern of zero columns in corresponds to the pattern of linear dependencies of the columns of when columns are considered in left-to-right order.
The following statements call the GSORTH subroutine and print the output parameters to the call:
x = {1 1 3 1 2, 1 0 1 2 3, 1 1 3 3 4, 1 0 1 4 5, 1 1 3 5 6, 1 0 1 6 7}; call gsorth(P, T, lindep, x); reset fuzz; print P, T, lindep;
Figure 25.150: Results of a Gram-Schmidt Orthonormalization
If lindep is 1, you can permute the columns of and rows of so that the zero columns of are rightmost—that is, , where k is the column rank of and the equality is preserved. The following statements show a permutation of columns:
d = loc(vecdiag(T)^=0) || loc(vecdiag(T)=0); temp = P; P[,d] = temp; temp = T; T[,d] = temp; print d, P, T;
Figure 25.151: Rearranging Columns
The GSORTH subroutine is not recommended for the construction of matrices of values of orthogonal polynomials; the ORPOL function should be used for that purpose.