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

  1. function [Q,R] = qrdelete(Q,R,j)
  2. %QRDELETE Delete a column from the QR factorization.
  3. %    If [Q,R] = qr(A) is the original QR factorization of A,
  4. %    then [Q,R] = qrdelete(Q,R,j) changes Q and R to be the
  5. %    factorization of the matrix with A(:,j) removed.
  6. %
  7. %    See also QR, QRINSERT, PLANEROT.
  8.  
  9. %    C.B.Moler 5/1/92.  Revised ACWG 6/15/92, CBM 9/11/92.
  10. %    Copyright (c) 1984-93 by the MathWorks, Inc.
  11.  
  12. % Remove the j-th column.  n = number of columns in modified R.
  13. R(:,j) = [];
  14. [m,n] = size(R);
  15.  
  16. % R now has nonzeros below the diagonal in columns j through n.
  17. %    R = [x x x x
  18. %         0 x x x
  19. %         0 + x x
  20. %         0 0 + x
  21. %         0 0 0 +]
  22. % Use Givens rotations to zero the +'s, one at a time, from left to right.
  23.  
  24. for k = j:min(n,m-1)
  25.    p = k:k+1;
  26.    [G,R(p,k)] = planerot(R(p,k));
  27.    if k < n
  28.       R(p,k+1:n) = G*R(p,k+1:n);
  29.    end
  30.    Q(:,p) = Q(:,p)*G';
  31. end
  32.