home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / MATFUN.DI$ / ORTH.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  643 b   |  27 lines

  1. function Q = orth(A)
  2. %ORTH    Orthogonalization.
  3. %    Q = orth(A) is an orthonormal basis for the range of A.
  4. %    Q'*Q = I, the columns of Q span the same space as the columns
  5. %    of A and the number of columns of Q is the rank of A.
  6. %
  7. %    See also QR, NULL.
  8.  
  9. %    C.B. Moler 11-24-85
  10. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  11.  
  12. % QR decomposition
  13. [Q,R,E]=qr(A);
  14. % Determine r = effective rank
  15. tol = eps*norm(A,'fro');
  16. r = sum(abs(diag(R)) > tol);
  17. r = r(1); % fix for case where R is vector.
  18. % Use first r columns of Q.
  19. if r > 0
  20.    Q = Q(:,1:r);
  21.    % Cosmetic sign adjustment
  22.    Q = -Q;
  23.    Q(:,r) = -Q(:,r);
  24. else
  25.    Q = [];
  26. end
  27.