⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sfl.m

📁 DEMO_COND demonstrates the role of the condition number of a matrix (with respect to inversion)
💻 M
字号:
       %%  PURPOSE:%  SFL  computes the floating point represenation of x.%  This is just a simulation of what the floating point %  represenation of x would be. (sfl = Simulate FLoating %  point)% %  It assumed that the base is 10 and that there%  is no restriction on the exponent range.%  The mantissa length is m, i.e. if%%                                 -               e%          x = d  . d  d  d ..... d    d   ... * 10 ,%               0    1  2  3       m-1  m%%  then%                                         e%     sfl(x) = d  . d  d  d ..... d   * 10 .%               0    1  2  3       m-1   %%  The m-th digit of  sfl(x)  may be different from the%  m-th digit of. If FLOATING POINT ARITHMETIC is used, %  then%                -%         d    = d       if   d  <= 4 ,  %          m-1    m            m%                -%         d    = d +1    if   d  => 5 .%          m-1    m            m%%  If CHOPPED ARITHMETIC is used, then%              -%         d  = d  .  %          m    m         %   % %  CALLING SEQUENCE:%%  function [flx] = sfl( x, m, arith )% %  INPUT PARAMETERS:% %  x      real%         floating point operation% %  m      integer%         mantissa length% %  arith  string%         arith = 'c'   chopped arithmetic%         arith = 'r'   rounded arithmetic% %%%%%  Matthias Heinkenschloss%  Department of Computational and Applied Mathematics%  Rice University%  Feb 12, 2001%% function [flx] = sfl( x, m, arith )%  The following internal variables are used:%%  iexp   is the exponent e,  %  xm     is the mantissa (with leading 0.)%  xrd    is the rounded value of x  (rounded to m digits)%  xchp   is the chopped value of x  (chopped to m digits)%  if  x = 0. we don't have to do anythingif( x == 0. )     flx = 0.;    returnend%  Determine the exponenttmp = log10(abs(x));if ( tmp > 0. )      ixexp = 1 + fix( tmp );else     ixexp = fix( tmp );end    %  determine the mantissaxm = x * 10^(-ixexp);if( xm > 0 )     xrd  = fix( xm * 10^m + 0.5 ) * 10.^(ixexp-m);    xchp = fix( xm * 10^m ) * 10^(ixexp-m);endif( xm < 0 )     xrd  = fix( xm * 10^m - 0.5 ) * 10.^(ixexp-m);    xchp = fix( xm * 10^m ) * 10^(ixexp-m);endif( arith == 'c' )      flx = xchp;endif( arith == 'r' )      flx = xrd;end

⌨️ 快捷键说明

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