view scripts/ode/private/AbsRel_Norm.m @ 20568:fcb792acab9b

Moving ode45, odeset, odeget, and levenshtein from odepkg to core. * libinterp/corefcn/levenshtein.cc: move function from odepkg into core * libinterp/corefcn/module.mk: include levenshtein.cc * scripts/ode: move ode45, odeset, odeget, and all dependencies from odepkg into core * scripts/module.mk: include them * doc/interpreter/diffeq.txi: add documentation for ode45, odeset, odeget * NEWS: announce functions included with this changeset * scripts/help/__unimplemented__.m: removed new functions
author jcorno <jacopo.corno@gmail.com>
date Thu, 24 Sep 2015 12:58:46 +0200
parents
children 6256f6e366ac
line wrap: on
line source

function res = AbsRel_Norm (x, x_old, AbsTol, RelTol, normcontrol, y)

  n = length (x);

  if (nargin == 5)
    y = zeros (size (x));
  elseif (nargin != 6)
    error ("OdePkg:InvalidArgument",
           "invalid number of input arguments");
  endif

  if (length (x_old) != n
      || length (y) != n)
    error ("OdePkg:InvalidArgument",
           "invalid dimensions of input arguments");
  endif
  
  if ((length (AbsTol) != 1 && length (AbsTol) != n)
      || (length (RelTol) != 1 && length (RelTol) != n))
    error ("OdePkg:InvalidArgument",
           "invalid dimensions of input arguments");
  endif
  
  sc = AbsTol + max (abs (x), abs (x_old)) .* RelTol;
  if (normcontrol)
    res = max (abs (x - y) ./ sc);
  else
    res = sqrt ((1 / n) * sum (((x - y) ./ sc).^2));
  endif

endfunction