| GSORTH Call | 
The GSORTH subroutine computes the Gram-Schmidt orthonormal factorization of the  matrix
 matrix  , where
, where  is greater than or equal to
 is greater than or equal to  . The GSORTH subroutine implements an algorithm described by Golub (1969).
. The GSORTH subroutine implements an algorithm described by Golub (1969). 
The GSORTH subroutine has a single input argument:
is an input  matrix.
 matrix. 
The output arguments to the GSORTH subroutine are as follows:
is an  column-orthonormal output matrix.
 column-orthonormal output matrix. 
is an upper triangular  output matrix.
 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
 matrix  and the upper triangular
 and the upper triangular  matrix
 matrix  such that
 such that 
|  | 
 If the columns of  are linearly independent (that is, rank
 are linearly independent (that is, rank ), then
), then  is full-rank column-orthonormal:
 is full-rank column-orthonormal:  ,
,  is nonsingular, and the value of lindep (a scalar) is set to 0. If the columns of
 is nonsingular, and the value of lindep (a scalar) is set to 0. If the columns of  are linearly dependent (say, rank
 are linearly dependent (say, rank ) then
) then  columns of
 columns of  are set to 0, the corresponding rows of
 are set to 0, the corresponding rows of  are set to 0 (
 are set to 0 ( is singular), and lindep is set to 1. The pattern of zero columns in
 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
 corresponds to the pattern of linear dependencies of the columns of  when columns are considered in left-to-right order.
 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;
| P | ||||
|---|---|---|---|---|
| 0.4082483 | 0.4082483 | 0 | -0.5 | 0 | 
| 0.4082483 | -0.408248 | 0 | -0.5 | 0 | 
| 0.4082483 | 0.4082483 | 0 | 0 | 0 | 
| 0.4082483 | -0.408248 | 0 | 0 | 0 | 
| 0.4082483 | 0.4082483 | 0 | 0.5 | 0 | 
| 0.4082483 | -0.408248 | 0 | 0.5 | 0 | 
| T | ||||
|---|---|---|---|---|
| 2.4494897 | 1.2247449 | 4.8989795 | 8.5732141 | 11.022704 | 
| 0 | 1.2247449 | 2.4494897 | -1.224745 | -1.224745 | 
| 0 | 0 | 0 | 0 | 0 | 
| 0 | 0 | 0 | 4 | 4 | 
| 0 | 0 | 0 | 0 | 0 | 
| lindep | 
|---|
| 1 | 
If lindep is 1, you can permute the columns of  and rows of
 and rows of  so that the zero columns of
 so that the zero columns of  are rightmost—that is,
 are rightmost—that is,  , where
, where  is the column rank of
 is the column rank of  and the equality
 and the equality  is preserved. The following statements show a permutation of columns:
 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;
| d | ||||
|---|---|---|---|---|
| 1 | 2 | 4 | 3 | 5 | 
| P | ||||
|---|---|---|---|---|
| 0.4082483 | 0.4082483 | -0.5 | 0 | 0 | 
| 0.4082483 | -0.408248 | -0.5 | 0 | 0 | 
| 0.4082483 | 0.4082483 | 0 | 0 | 0 | 
| 0.4082483 | -0.408248 | 0 | 0 | 0 | 
| 0.4082483 | 0.4082483 | 0.5 | 0 | 0 | 
| 0.4082483 | -0.408248 | 0.5 | 0 | 0 | 
| T | ||||
|---|---|---|---|---|
| 2.4494897 | 1.2247449 | 8.5732141 | 4.8989795 | 11.022704 | 
| 0 | 1.2247449 | -1.224745 | 2.4494897 | -1.224745 | 
| 0 | 0 | 0 | 0 | 0 | 
| 0 | 0 | 4 | 0 | 4 | 
| 0 | 0 | 0 | 0 | 0 | 
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.