slopeconvexconcave.m

来自「intlab 工具用于快速计算 各各层的倒数等等」· M 代码 · 共 69 行

M
69
字号
function us = slopeconvexconcave(f,strfs,a,convex)
%SLOPECONVEXCONCAVE  Improved slope for convex and concave functions
%
%Internal function
%

%Input  f       string such that feval(f,a) evaluates f(a)
%       strfs   string such that eval(str) gives back f'(a) for
%                 str = strrep(strfs,'%','a')
%       a       input argument
%       convex  1/0 for convex/concave function
%
%Output us      improved slope
%

% written  12/06/98     S.M. Rump
%

  global INTLAB_SLOPE

  indexc = 1:INTLAB_SLOPE.NUMVAR;
  indexr = 2:INTLAB_SLOPE.NUMVAR+1;
  xs = a.r(:,indexc);
  X = a.r(:,indexr);

  ws = warning;
  warning off

  if convex
    bndX = intval(inf(X));
    bndxs = intval(inf(xs));
  else
    bndX = intval(sup(X));
    bndxs = intval(sup(xs));
  end
  fbndX = feval(f,bndX);
  fbndxs = feval(f,bndxs);
  N = bndX - bndxs;
  s = ( fbndX - fbndxs ) ./ N ;
  index = ( N.inf<=0 ) & ( N.sup>=0 );
  if any(index(:))
    s(index) = infsup(-inf,inf);
  end
  hullXxs = hull(bndX,bndxs);
  strfs = strrep(strfs,'%','hullXxs');
  eval(['s1 = max( inf(s) , inf(' strfs ') );'])

  if convex
    bndX = intval(sup(X));
    bndxs = intval(sup(xs));
  else
    bndX = intval(inf(X));
    bndxs = intval(inf(xs));
  end
  fbndX = feval(f,bndX);
  fbndxs = feval(f,bndxs);
  N = bndX - bndxs;
  s = ( fbndX - fbndxs ) ./ N ;
  index = ( N.inf<=0 ) & ( N.sup>=0 );
  if any(index(:))
    s(index) = infsup(-inf,inf);
  end
  hullXxs = hull(bndX,bndxs);
% strfs = strrep(strfs,'%','hullXxs');   %% already defined %%
  eval(['s2 = min( sup(s) , sup(' strfs ') );'])

  warning(ws)
  us = infsup(s1,s2) .* a.s;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?