| Language Reference |
provides columnwise orthogonalization by the Gram-Schmidt process and stepwise QR decomposition by the Gram-Schmidt process
There are two special cases:
The case
is not possible since
is
assumed to have
(nearly) orthonormal columns.
To initialize a stepwise QR decomposition, ORTVEC
can be called to normalize
only, that is,
to compute
and
only.
There are two ways of using the ORTVEC call for this reason:
The ORTVEC subroutine is useful for the following applications:
The
matrix
contains the
unit vectors
, and
.
The column vector
is pairwise linearly
independent with the three columns of
.
As expected, the ORTVEC call computes the vector
as
the unit vector
with
and
.
Here is the code:
q = { 1 0 0,
0 0 0,
0 1 0,
0 0 1 };
v = { 1, 1, 1, 1 };
call ortvec(w,u,rho,lindep,v,q);
print rho u w;
You can perform the QR decomposition of the
linearly independent columns of an
matrix
with the following statements:
a = { . . . enter matrix A here . . . };
nind = 0; ndep = 0; dmax = 0.;
n = ncol(a); m = nrow(a);
free q;
do j = 1 to n;
v = a[ ,j];
call ortvec(w,u,rho,lindep,v,q);
aro = abs(rho);
if aro > dmax then dmax = aro;
if aro <= 1.e-10 * dmax then lindep = 1;
if lindep = 0 then do;
nind = nind + 1;
q = q || w;
if nind = n then r = r || (u // rho);
else r = r || (u // rho // j(n-nind,1,0.));
end;
else do;
print "Column " j " is linearly dependent.";
ndep = ndep + 1; ind[ndep] = j;
end;
end;
Next, process the remaining columns of
do j = 1 to ndep;
k = ind[ndep-j+1];
v = a[ ,k];
call ortvec(w,u,rho,lindep,v,q);
if lindep = 0 then do;
nind = nind + 1;
q = q || w;
if nind = n then r = r || (u // rho);
else r = r || (u // rho // j(n-nind,1,0.));
end;
end;
Now compute the null space in the last columns of
do i = 1 to m;
if nind < m then do;
v = j(m,1,0.); v[i] = 1.;
call ortvec(w,u,rho,lindep,v,q);
aro = abs(rho);
if aro > dmax then dmax = aro;
if aro <= 1.e-10 * dmax then lindep = 1;
if lindep = 0 then do;
nind = nind + 1;
q = q || w;
end;
else print "Unit vector" i "linearly dependent.";
end;
end;
if nind < m then do;
print "This is theoretically not possible.";
end;
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.