home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS2.DI$ / SUBGRAD.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  918 b   |  26 lines

  1.  function [delfx,cost] = subgrad(m,x,blk,blkp)
  2. %function [delfx,cost] = subgrad(m,x,blk,blkp)
  3. %  calculates an element of the subgradient set
  4. %  for the function f(X) := sigma_max { e^X M e^{-X} }
  5. %  at an arbitrary given point X. this routine
  6. %  assumes that the last coordinate of the X
  7. %  vector is fixed at 0, so there are NBLK-1 variables
  8. %  in the X vector
  9.  [nblk,dum] = size(blk);
  10.  delfx = zeros(length(x),1);
  11.  sm = m;
  12.  for i=1:nblk-1
  13.    sm(blkp(i,2):blkp(i+1,2)-1,:) = exp(x(i))*sm(blkp(i,2):blkp(i+1,2)-1,:);
  14.    sm(:,blkp(i,1):blkp(i+1,1)-1) = exp(-x(i))*sm(:,blkp(i,1):blkp(i+1,1)-1);
  15.  end
  16.  [u,s,v] = svd(sm);
  17.  cost = s(1,1);
  18.  
  19.  for i=1:nblk-1
  20.    w1 = abs( u(blkp(i,2):blkp(i+1,2)-1,1)'* u(blkp(i,2):blkp(i+1,2)-1,1) );
  21.    w2 = abs( v(blkp(i,1):blkp(i+1,1)-1,1)'* v(blkp(i,1):blkp(i+1,1)-1,1) );
  22.    delfx(i) = s(1,1) * (w1-w2);
  23.  end
  24. %
  25. % Copyright MUSYN INC 1991,  All Rights Reserved
  26.