Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
20567:2480bbcd1333 | 20568:fcb792acab9b |
---|---|
1 function res = AbsRel_Norm (x, x_old, AbsTol, RelTol, normcontrol, y) | |
2 | |
3 n = length (x); | |
4 | |
5 if (nargin == 5) | |
6 y = zeros (size (x)); | |
7 elseif (nargin != 6) | |
8 error ("OdePkg:InvalidArgument", | |
9 "invalid number of input arguments"); | |
10 endif | |
11 | |
12 if (length (x_old) != n | |
13 || length (y) != n) | |
14 error ("OdePkg:InvalidArgument", | |
15 "invalid dimensions of input arguments"); | |
16 endif | |
17 | |
18 if ((length (AbsTol) != 1 && length (AbsTol) != n) | |
19 || (length (RelTol) != 1 && length (RelTol) != n)) | |
20 error ("OdePkg:InvalidArgument", | |
21 "invalid dimensions of input arguments"); | |
22 endif | |
23 | |
24 sc = AbsTol + max (abs (x), abs (x_old)) .* RelTol; | |
25 if (normcontrol) | |
26 res = max (abs (x - y) ./ sc); | |
27 else | |
28 res = sqrt ((1 / n) * sum (((x - y) ./ sc).^2)); | |
29 endif | |
30 | |
31 endfunction |