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

  1. function S = spaugment(A,c)
  2. %SPAUGMENT Express a least squares problem as a larger linear system.
  3. %    S = SPAUGMENT(A,c) creates the sparse, square, symmetric indefinite
  4. %    matrix S = [c*I A; A' 0].  This matrix is related to the least
  5. %    squares problem
  6. %            min norm(b - A*x)
  7. %    by
  8. %            r = b - A*x
  9. %            S * [r/c; x] = [b; 0].
  10. %
  11. %    The optimum value of the residual scaling factor c, involves
  12. %    min(svd(A)) and norm(r), which are usually too expensive to compute.
  13. %    S = SPAUGMENT(A), without a specified value of c, uses the
  14. %    default set by SPPARMS, which is usually max(max(abs(A)))/1000.
  15. %
  16. %    The augmented matrix is used automatically by the sparse
  17. %    linear equation solvers, \ and /, for nonsquare problems.
  18. %
  19. %    See also SPPARMS.
  20.  
  21. %    C. Moler, 4-30-91, 6-1-92.
  22. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  23.  
  24. if nargin < 2
  25.    c = spparms('aug_rel')*max(max(abs(A))) + spparms('aug_abs');
  26. end
  27. [m,n] = size(A);
  28. S = [sparse(1:m,1:m,c(1)) A; A' sparse(n,n)];
  29.