1 %# Copyright (C) 2007-2012, Thomas Treichl <treichl@users.sourceforge.net>
2 %# OdePkg - A package for solving ordinary differential equations and more
4 %# This program is free software; you can redistribute it and/or modify
5 %# it under the terms of the GNU General Public License as published by
6 %# the Free Software Foundation; either version 2 of the License, or
7 %# (at your option) any later version.
9 %# This program is distributed in the hope that it will be useful,
10 %# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 %# GNU General Public License for more details.
14 %# You should have received a copy of the GNU General Public License
15 %# along with this program; If not, see <http://www.gnu.org/licenses/>.
18 %# @deftypefn {Function File} {[@var{scd}] =} odepkg_testsuite_calcscd (@var{solution}, @var{reference}, @var{abstol}, @var{reltol})
20 %# If this function is called with four input arguments of type double scalar or column vector then return a normalized value for the minimum number of correct digits @var{scd} that is calculated from the solution at the end of an integration interval @var{solution} and a set of reference values @var{reference}. The input arguments @var{abstol} and @var{reltol} are unused but present because of compatibility to the function @command{odepkg_testsuite_calcmescd}.
22 %# Run examples with the command
24 %# demo odepkg_testsuite_calcscd
27 %# This function has been ported from the "Test Set for IVP solvers" which is developed by the INdAM Bari unit project group "Codes and Test Problems for Differential Equations", coordinator F. Mazzia.
32 function vscd = odepkg_testsuite_calcscd (vsol, vref, vatol, vrtol)
33 vsol = vsol(:); vref = vref(:);
34 vrel = (vref - vsol) / vref;
35 vscd = -log10 (norm (vrel, inf));
38 %! # Displays the value for the mimum number of correct digits in
39 %! # the vector sol = [1, 2, 2.9] compared to the reference vector
42 %! odepkg_testsuite_calcscd ([1, 2, 2.9], [1, 2, 3], NaN, NaN)
45 %! # Displays the value for the mimum number of correct digits in
46 %! # the vector sol = [1, 2, 2.9] compared to the reference vector
49 %! odepkg_testsuite_calcscd ([1 + 1e10, 2 + 1e10, 3 + 1e10], ...
50 %! [1, 2, 3], NaN, NaN)
52 %!assert (odepkg_testsuite_calcscd ([1, 2, 3], [1, 2, 3], NaN, NaN), Inf);
53 %!assert (odepkg_testsuite_calcscd ([1, 2, 3], [1, 2.1, 3], 1, 1), 1.5, 0.2);
54 %!assert (odepkg_testsuite_calcscd ([1, 2, 3], [1+1e-6, 2, 3], 1, 1), 6.5, 0.2);
56 %# Local Variables: ***