Chapter Contents Previous Next
 Language Reference

## GSORTH Call

computes the Gram-Schmidt orthonormalization

CALL GSORTH( p, t, lindep, a);

The inputs to the GSORTH subroutine are as follows:
p
is an m ×n column-orthonormal output matrix.

t
is an upper triangular n ×n output matrix.

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

a
is an input m ×n matrix.
The GSORTH subroutine computes the Gram-Schmidt orthonormal factorization of the m ×n matrix A, where m is greater than or equal to n; that is, the GSORTH subroutine computes the column-orthonormal m ×n matrix P and the upper triangular n ×n matrix T such that
A = P*T   .
If the columns of A are linearly independent (that is, rank(A) = n), then P is full-rank column-orthonormal: P'P = Iw, T is nonsingular, and the value of lindep (a scalar) is set to 0. If the columns of A are linearly dependent (say rank(A) = k < n) then n-k columns of P are set to 0, the corresponding rows of T are set to 0 (T is singular), and lindep is set to 1. The pattern of zero columns in P corresponds to the pattern of linear dependencies of the columns of A when columns are considered in left-to-right order.

The GSORTH subroutine is not recommended for the construction of matrices of values of orthogonal polynomials; the should be used for that purpose.

If lindep is 1, you can rearrange the columns of P and rows of T so that the zero columns of P are right-most, that is, P = (P(,1),P(,k),0, ... ,0), where k is the column rank of A and A = P*T is preserved. The following statements make this rearrangement:

```   d=rank((ncol(t)-(1:ncol(t))`)#(vecdiag(t)=0));
temp=p;
p[,d]=temp;
temp=t;
t[,d]=temp;
```
An example of a valid GSORTH call follows:
```   x={1 1 1, 1 2 4, 1 3 9};
xpx=x`*x;
call gsorth(p, t, l, xpx);
```
These statements produce the output matrices
```                P             3 rows      3 cols    (numeric)

0.193247 -0.753259 0.6286946
0.386494 -0.530521 -0.754434
0.9018193 0.3887787 0.1886084

T             3 rows      3 cols    (numeric)

15.524175 39.035892 104.99753
0 2.0491877 8.4559365
0         0 0.1257389

L             1 row       1 col     (numeric)

0
```
See "Acknowledgments" in the front of this book for authorship of the GSORTH subroutine.

 Chapter Contents Previous Next Top