diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/differential_equations/macros | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/differential_equations/macros')
21 files changed, 1240 insertions, 0 deletions
diff --git a/modules/differential_equations/macros/buildmacros.bat b/modules/differential_equations/macros/buildmacros.bat new file mode 100755 index 000000000..c4e35ec40 --- /dev/null +++ b/modules/differential_equations/macros/buildmacros.bat @@ -0,0 +1 @@ +@..\..\..\bin\scilex -nwni -ns -e exec('buildmacros.sce');quit;
\ No newline at end of file diff --git a/modules/differential_equations/macros/buildmacros.sce b/modules/differential_equations/macros/buildmacros.sce new file mode 100755 index 000000000..ddf71f52f --- /dev/null +++ b/modules/differential_equations/macros/buildmacros.sce @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Allan Cornet +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +if (isdef("genlib") == %f) then + exec(SCI+"/modules/functions/scripts/buildmacros/loadgenlib.sce"); +end + +genlib("differential_equationlib","SCI/modules/differential_equations/macros",%f,%t); diff --git a/modules/differential_equations/macros/cleanmacros.bat b/modules/differential_equations/macros/cleanmacros.bat new file mode 100755 index 000000000..5079dfd71 --- /dev/null +++ b/modules/differential_equations/macros/cleanmacros.bat @@ -0,0 +1,3 @@ +@del *.bin 2>NUL +@del lib 2>NUL +@del names 2>NUL
\ No newline at end of file diff --git a/modules/differential_equations/macros/dae.bin b/modules/differential_equations/macros/dae.bin Binary files differnew file mode 100755 index 000000000..343d6f1fa --- /dev/null +++ b/modules/differential_equations/macros/dae.bin diff --git a/modules/differential_equations/macros/dae.sci b/modules/differential_equations/macros/dae.sci new file mode 100755 index 000000000..82628e320 --- /dev/null +++ b/modules/differential_equations/macros/dae.sci @@ -0,0 +1,689 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier +// Copyright (C) 2008 - INRIA - Sabine GAUZERE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function [varargout] = dae(varargin) + + [lhs, rhs] = argn(); + + if size(varargin) == 0 then + error(sprintf(gettext("%s: Wrong number of input argument(s): %d or %d expected.\n"), "dae", 3, 8)); + end + if isdef("%DAEOPTIONS") == %F then + if varargin(1) <> "root2" then + %DAEOPTIONS = list ([], 0, [], [], [], 0, 0); + else + %DAEOPTIONS = list ([], 0, [], [], [], 0, [], 0, [], 0, [], [], [], 1); + end + end + if type(varargin(1)) == 1 then //standard case (dassl) + + if rhs == 4 then //call without optional arguments + [x0, t0, t, res] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, res, %DAEOPTIONS); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, res, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + elseif rhs == 8 then // call with all the optional arguments + [x0, t0, t, rtol, atol, res, jac, hd] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0,t0, t, atol, rtol, res, jac, %DAEOPTIONS, hd); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, atol, rtol, res, jac, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + elseif rhs == 5 then + + if type(varargin(4)) == 1 then + [x0, t0, t, atol, res] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, atol, res, %DAEOPTIONS); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, atol, res, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + else + + if type(varargin(5)) == 1 then + [x0, t0, t, res, hd] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, res, %DAEOPTIONS, hd); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, res, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + else + [x0, t0, t, res, jac] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, res, jac, %DAEOPTIONS); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, res, jac, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + end + + end + + elseif rhs == 6 then + + if type(varargin(4)) == 1 then + + if type(varargin(5)) == 1 then + [x0, t0, t, rtol, atol, res] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, atol, rtol, res, %DAEOPTIONS); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, atol, rtol, res, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + else + + if type(varargin(6)) == 1 then + [x0, t0, t, atol, res, hd] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, atol, res, %DAEOPTIONS, hd); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, atol, res, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + else + [x0, t0, t, atol, res, jac] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, atol, res, jac, %DAEOPTIONS); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, atol, res, jac, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + end + end + + else + [x0, t0, t, res, jac, hd] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, res, jac, %DAEOPTIONS, hd); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, res, jac, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + end + + elseif rhs == 7 then + + if type(varargin(5)) == 1 then + + if type(varargin(7)) == 1 then + [x0, t0, t, rtol, atol, res, hd] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, atol, rtol, res, %DAEOPTIONS, hd); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, atol, rtol, res, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + else + [x0, t0, t, rtol, atol, res, jac] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, atol, rtol, res, jac, %DAEOPTIONS); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, atol, rtol, res, jac, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + end + + else + [x0, t0, t, atol, res, jac, hd] = varargin(:) + if lhs == 2 then + [y, hd] = dassl(x0, t0, t, atol, res, jac, %DAEOPTIONS, hd); + elseif lhs == 1 then + [y] = dassl(x0, t0, t, atol, res, jac, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + end + + else + error(sprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "dae", 4, 8)); + end + + if %DAEOPTIONS(2) == 0 then + [r, c] = size(y); + y = y([2:1:r], :); + end + if lhs == 2 then + varargout = list(y, hd); + elseif lhs == 1 then + varargout = list(y); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 1, 2)); + end + + elseif varargin(1) == "root" then // Case root (dasrt) + [lhs, rhs] = argn(); + + if rhs == 7 then // Call without optional arguments + [typ, x0, t0, t, res, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, res, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, res, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + elseif rhs == 11 then // Call with all the optional arguments + [typ, x0, t0, t, rtol, atol, res, jac, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0,t0,t,atol,rtol,res,jac,ng,surface,%DAEOPTIONS,hd); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + elseif rhs == 8 then + + if type(varargin(5)) == 1 then + [typ, x0, t0, t, atol, res, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, atol, res, ng, surface,%DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + + if type(varargin(8)) == 1 then + [typ, x0, t0, t, res, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, res, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, res, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + [typ, x0, t0, t, res, jac, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + end + + end + + elseif rhs == 9 then + + if type(varargin(5)) == 1 then + + if type(varargin(6)) == 1 then + [typ, x0, t0, t, rtol, atol, res, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + + if type(varargin(9)) == 1 then + [typ, x0, t0, t, atol, res, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + [typ, x0, t0, t, atol, res, jac, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + end + end + + else + [typ, x0, t0, t, res, jac, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + elseif rhs == 10 then + + if type(varargin(5)) == 1 then + + if type(varargin(6)) == 1 then + + if type(varargin(10)) == 1 then + [typ, x0, t0, t, rtol, atol, res, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + [typ, x0, t0, t, rtol, atol, res, jac, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + else + [typ, x0, t0, t, atol, res, jac, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + end + + else + [typ, x0, t0, t, res, jac, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = dasrt(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = dasrt(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + else + error(sprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "dae", 7, 11)); + end + if %DAEOPTIONS(2) == 0 then + [r, c] = size(y); + y = y([2:1:r], :); + end + if lhs == 2 then + varargout = list(y, nn); + elseif lhs == 3 then + varargout = list(y, nn, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + elseif varargin(1) == "root2" then // Case root2 (daskr) + [lhs, rhs] = argn(); + + if rhs == 7 then // Call without optional arguments + [typ, x0, t0, t, res, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, res, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, res, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + elseif rhs == 13 then // Call with all the optional arguments + [typ, x0, t0, t, rtol, atol, res, jac, ng, surface, psol, pjac, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0,t0,t,atol,rtol,res,jac,ng,surface,%DAEOPTIONS, psol, pjac, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + elseif rhs == 8 then + + if type(varargin(5)) == 1 then + [typ, x0, t0, t, atol, res, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, res, ng, surface,%DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + + if type(varargin(8)) == 1 then + [typ, x0, t0, t, res, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, res, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, res, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + [typ, x0, t0, t, res, jac, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + end + + end + + elseif rhs == 9 then + + if type(varargin(5)) == 1 then + + if type(varargin(6)) == 1 then + [typ, x0, t0, t, rtol, atol, res, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + + if type(varargin(9)) == 1 then + [typ, x0, t0, t, atol, res, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + [typ, x0, t0, t, atol, res, jac, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + end + end + + else + if type(varargin(9)) == 1 then + [typ, x0, t0, t, res, jac, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + else + [typ, x0, t0, t, res, ng, surface, psol, pjac] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, res, ng, surface, %DAEOPTIONS, psol, pjac); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, res, ng, surface, %DAEOPTIONS, psol, pjac); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + end + + elseif rhs == 10 then + + if type(varargin(5)) == 1 then + + if type(varargin(6)) == 1 then + + if type(varargin(10)) == 1 then + [typ, x0, t0, t, rtol, atol, res, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + [typ, x0, t0, t, rtol, atol, res, jac, ng, surface] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + else + if type(varargin(10)) == 1 then + [typ, x0, t0, t, atol, res, jac, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + else + [typ, x0, t0, t, atol, res, ng, surface, psol, pjac] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS, psol, pjac); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS, psol, pjac); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + end + + else + if type(varargin(10)) == 1 then + [typ, x0, t0, t, res, ng, surface, psol, pjac, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, res, ng, surface, %DAEOPTIONS, psol, pjac, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, res, ng, surface, %DAEOPTIONS, psol, pjac, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + else + [typ, x0, t0, t, res, jac, ng, surface, psol, pjac] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, psol, pjac); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, psol, pjac); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + end + + elseif rhs == 11 then + + if type(varargin(5)) == 1 then + + if type(varargin(6)) == 1 then + + if type(varargin(11)) == 1 then + [typ, x0, t0, t, rtol, atol, res, jac, ng, surface, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + [typ, x0, t0, t, rtol, atol, res, ng, surface, psol, pjac] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS, psol, pjac); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS, psol, pjac); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + else + if type(varargin(11)) == 1 then + [typ, x0, t0, t, atol, res, ng, surface, psol, pjac, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS, psol, pjac, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, res, ng, surface, %DAEOPTIONS, psol, pjac, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + else + [typ, x0, t0, t, atol, res, jac, ng, surface, psol, pjac] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + end + + else + [typ, x0, t0, t, res, jac, ng, surface, psol, pjac, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, psol, pjac, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, res, jac, ng, surface, %DAEOPTIONS, psol, pjac, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + elseif rhs == 12 then + + if type(varargin(5)) == 1 then + + if type(varargin(6)) == 1 then + + if type(varargin(12)) == 1 then + [typ, x0, t0, t, rtol, atol, res, ng, surface, psol, pjac, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS, psol, pjac, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, ng, surface, %DAEOPTIONS, psol, pjac, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + [typ, x0, t0, t, rtol, atol, res, jac, ng, surface, psol, pjac] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + + else + [typ, x0, t0, t, atol, res, jac, ng, surface, psol, pjac, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + end + end + + elseif rhs == 13 then + + [typ, x0, t0, t, rtol, atol, res, jac, ng, surface, psol, pjac, hd] = varargin(:) + if lhs == 2 then + [y, nn] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac, hd); + elseif lhs == 3 then + [y, nn, hd] = daskr(x0, t0, t, atol, rtol, res, jac, ng, surface, %DAEOPTIONS, psol, pjac, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + + else + error(sprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "dae", 7, 13)); + end + if %DAEOPTIONS(2) == 0 then + [r, c] = size(y); + y = y([2:1:r], :); + end + if lhs == 2 then + varargout = list(y, nn); + elseif lhs == 3 then + varargout = list(y, nn, hd); + else + error(sprintf(gettext("%s: Wrong number of output argument(s): %d or %d expected.\n"), "dae", 2, 3)); + end + else + error(sprintf(gettext("%s: Invalid option %s: real matrix expected.\n"), "dae", "root")); + end + +endfunction diff --git a/modules/differential_equations/macros/daeoptions.bin b/modules/differential_equations/macros/daeoptions.bin Binary files differnew file mode 100755 index 000000000..9711a13b9 --- /dev/null +++ b/modules/differential_equations/macros/daeoptions.bin diff --git a/modules/differential_equations/macros/daeoptions.sci b/modules/differential_equations/macros/daeoptions.sci new file mode 100755 index 000000000..9cf3c7682 --- /dev/null +++ b/modules/differential_equations/macros/daeoptions.sci @@ -0,0 +1,154 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - Scilab Enterprises - Paul Bignier : added daskr options +// Copyright (C) 2008 - INRIA - Sabine GAUZERE +// ... +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [%DAEOPTIONS] = daeoptions(%DAEOPTIONS) + + //%DAEOPTIONS=list(tstop,imode,band,maxstep,stepin,nonneg,isest) + // This function displays the command line + // %DAEOPTIONS=[...] to be executed + // for defining the variable %DAEOPTIONS + // This variables sets a number of optional parameters + // for the lsod* fortran routines. + + //options = [1,0,0,%inf,0,2,500,12,5,0,-1,-1]; + options = list ([],0,[],[],[],0,0); + //default = [string(options(1:10)),sci2exp(options(11:12))] + default = ["0","[]","0","[]","[]","[]","0","0","0","[]","0","0","[]","[]","1"]; + //default(find(default=='Inf'))="%inf" + + if argn(2)>0 then + options=%DAEOPTIONS + end + + //lab_=[string(options(1:10)),sci2exp(options(11:12))] + lab_= ["0","[]","0","[]","[]","[]","0","0","0","[]","0","0","[]","[]","1"]; + //lab_(find(lab_=="[]"))="[]" + + + chapeau=["Defining %DAEOPTIONS variable"; + "*****************************"; + "Meaning of solver:"; + "solver is a real scalar which selects the solver"; + "0 : use dassl/dasrt"; + "1 : use daskr"; + " "; + "Meaning of tstop:"; + "tstop is a real scalar which gives the maximum time"; + "for which g is allowed to be evaluated"; + "[] : if no limits imposed for time"; + " "; + "Meaning of imode:"; + "0 : if only the user specified time point values"; + "1 : if dae returns its intermediate computed values"; + " "; + "Meaning of band:"; + " "; + "Meaning of maxstep:"; + " "; + "Meaning of stepin:"; + " "; + "Meaning of nonneg:"; + "0 : if the solution is known to be negative"; + "1 : if the solution is known to be non negative"; + " "; + "Meaning of isest:"; + "0 : if g(t0,y0,ydot0)=0"; + "1 : if ydot0 is just an estimation and you want to use dassl/dasrt"; + "[+-1,...,+-1]: if ydot0 is just an estimation and you want to use daskr, with:"; + "1 if y(i) is a differential variable and"; + "-1 if y(i) is an algebraic variable"; + "(if its derivatives do not appear explicitly in the function g(t, y, ydot))."; + " " + "The following values are only used by daskr (solver = 1)"; + " "; + "Meaning of method:"; + "0 : use GMRes Krylov method and provide a psol routine in dae"; + "1 : use direct method"; + " "; + "Meaning of Kry_params:"; + "Treat as dummy argument if you have set method=0. Otherwise, set :"; + "[] : default parameters"; + "[maxl kmp nrmax epli] : where"; + "- maxl = maximum number of iterations in the GMRes algorithm (default min(5, neq)),"; + "- kmp = number of vectors on which orthogonalization is done in the GMRes algorithm (default maxl),"; + "- nrmax = maximum number of restarts of the GMRes algorithm per nonlinear iteration (default 5),"; + "- epli = convergence test constant in GMRes algorithm (default 0.05)."; + " "; + "Meaning of init:"; + "Treat as dummy argument if you have set isest=0. Otherwise, set :"; + "0 : stop after initial values computation"; + "1 : proceed to integration"; + " "; + "Meaning of precond:"; + "Treat as dummy argument if you have set method=0. Otherwise, set :"; + "0 : specify a specific pjac routine in dae()"; + "1 : use the default"; + " "; + "Meaning of control:"; + "[] : if you wish to control errors locally on all the variables then set to []."; + "[+-1,...,+-1] : 1 if y(i) is a differential variable and -1 if y(i) is an algebraic variable"; + "(if its derivatives do not appear explicitly in the function g(t, y, ydot))."; + " "; + "Meaning of heuristic:"; + "Treat as dummy argument if you have set isest=0. Otherwise, set :"; + "[] : default parameters"; + "[mxnit mxnj mxnh lsoff stptol epinit] : where"; + "mxnj = maximum number of Jacobian or preconditioner evaluations (default 6 if info(8)=0, 2 otherwise),"; + "lsoff = flag to turn off the linesearch algorithm (lsoff = 0 means linesearch is on, lsoff = 1 means it is turned off) (default 0)"; + "mxnj = maximum number of Jacobian or preconditioner evaluations (default 6 if info(8)=0, 2 otherwise),"; + "stptol = minimum scaled step in linesearch algorithm (default (unit roundoff)^(2/3)),"; + "epinit = swing factor in the Newton iteration convergence test (default 0.01)."; + " "; + "Meaning of verbosity:"; + "0 : standard printing"; + "1 : minimal printing"; + "2 : full printing"; + " "; + "Default values are given in square brackets" + "If the function is called without argument, default values"+... + " are used" + ] + + dims = list("vec",1,"vec",-1,"vec",1,"vec",-1,"vec",-1,"vec",-1,.. + "vec",1,"vec",-1,"vec",1,"vec",-1,"vec",1,"vec",1,"vec",-1,"vec",-1,"vec",1); + + + labels = ["solver (assumes solver = 0 or 1) ",... + "tstop (maximum time) ","imode (assumes imode = 0 or 1)",... + "band ()",... + "maxstep (max step size)","stepin (initial step size)",... + "nonneg (assumes nonneg = 0 or 1)",... + "isest (assumes isest = 0, 1 or [+-1,...])",... + "method (assumes method = 0 or 1)","Kry_params",... + "init (assumes init = 0 or 1)","precond (assumes precond = 0 or 1)",... + "control","heuristic","verbosity (assumes verbosity = 0 or 1)"] +" ["+default+"]"; + + + + [solver,ok,tstop,imode,band,maxstep,stepin,nonneg,isest,... + method,Kry_params,init,precond,control,heuristic,verbosity] = getvalue(chapeau,labels,dims,lab_); + //ml = mlmu(1); + //mu = mlmu(2); + + if solver == 0 then + DAEOPTIONS = list(tstop,imode,band,maxstep,stepin,nonneg,isest); + else + DAEOPTIONS = list(tstop,imode,band,maxstep,stepin,nonneg,isest,... + method,Kry_params,init,precond,control,heuristic,verbosity); + end + + if DAEOPTIONS<>list() then + %DAEOPTIONS=DAEOPTIONS + else + %DAEOPTIONS=options + end + +endfunction diff --git a/modules/differential_equations/macros/intc.bin b/modules/differential_equations/macros/intc.bin Binary files differnew file mode 100755 index 000000000..dd97dcc2e --- /dev/null +++ b/modules/differential_equations/macros/intc.bin diff --git a/modules/differential_equations/macros/intc.sci b/modules/differential_equations/macros/intc.sci new file mode 100755 index 000000000..1c839249a --- /dev/null +++ b/modules/differential_equations/macros/intc.sci @@ -0,0 +1,69 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA - Farid BELAHCENE +// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added argument checking and error control +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [r, err] = intc(a, b, f, abserr, relerr) + // If f is a complex-valued macro, intc(a, b, f) computes + // the integral from a to b of f(z)dz along the straight + // line a-b of the complex plane. + // abserr: absolute error required. Default: 1d-14. + // relerr: relative error required. Default: 1d-8. + // err : estimated absolute error on the result. + + [lhs, rhs] = argn(); + + if rhs < 3 then + error(msprintf(_("%s: Wrong number of input argument(s): at least %d expected.\n"), "intc", 3)); + end + + if rhs == 3 then + abserr = 1d-14; + relerr = 1d-8; + elseif rhs == 4 then + if type(abserr) <> 1 then + error(msprintf(_("%s: Wrong type for input argument #%d: Real expected.\n"), "intc", 4)); + end + if ~isscalar(abserr) then + error(msprintf(_("%s: Wrong size for input argument #%d: (%d,%d) expected.\n"), "intc", 4, 1, 1)); + end + relerr = 1d-8; + else + if type(abserr) <> 1 then + error(msprintf(_("%s: Wrong type for input argument #%d: Real expected.\n"), "intc", 4)); + end + if ~isscalar(abserr) then + error(msprintf(_("%s: Wrong size for input argument #%d: (%d,%d) expected.\n"), "intc", 4, 1, 1)); + end + if type(relerr) <> 1 then + error(msprintf(_("%s: Wrong type for input argument #%d: Real expected.\n"), "intc", 5)); + end + if ~isscalar(relerr) then + error(msprintf(_("%s: Wrong size for input argument #%d: (%d,%d) expected.\n"), "intc", 5, 1, 1)); + end + end + + if and(type(f) <> [11 13 130]) then + error(msprintf(_("%s: Wrong type for input argument #%d: Scilab function expected.\n"), "intc", 3)); + end + + // Compile f if necessary: + if type(f) == 11 then + comp(f); + end + // Define two functions which define the real part and + // imaginary part of f(g(t))*g'(t) where g(t) is a + // parametrization of the line a-b. + deff("<r> = real1(t, a, b, f)", "r = real(f((1-t)*a+t*b)*(b-a));") + deff("<r> = imag1(t, a, b, f)", "r = imag(f((1-t)*a+t*b)*(b-a));") + [r1, err1] = intg(0, 1, list(real1, a, b, f), abserr, relerr); + [r2, err2] = intg(0, 1, list(imag1, a, b, f), abserr, relerr); + r = r1 + %i*r2; + err = err1 + %i*err2; + +endfunction diff --git a/modules/differential_equations/macros/integrate.bin b/modules/differential_equations/macros/integrate.bin Binary files differnew file mode 100755 index 000000000..44d220aad --- /dev/null +++ b/modules/differential_equations/macros/integrate.bin diff --git a/modules/differential_equations/macros/integrate.sci b/modules/differential_equations/macros/integrate.sci new file mode 100755 index 000000000..87fba5c11 --- /dev/null +++ b/modules/differential_equations/macros/integrate.sci @@ -0,0 +1,92 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function %x=integrate(%expr,%var,%x0,%x1,%ea,%er) + // x=integrate(expr,v,x0,x1 [,ea [,er]]) computes + // /x1 + // [ + // x = I f(v)dv + // ] + // /x0 + // + // + //examples: + //integrate('sin(x)','x',0,%pi) + //integrate(['if x==0 then 1,'; + // 'else sin(x)/x,end'],'x',0,%pi) + rhs = argn(2); + + if rhs < 4 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"),"integrate",4)); + end + + select rhs + case 4 then + %ea=1d-14;%er=1.d-8 + case 5 then + %er=1d-14; + end + + if size(%x0,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A real expected.\n"),"integrate",3)); + end + + if size(%ea,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A real expected.\n"),"integrate",5)); + end + + if size(%er,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A real expected.\n"),"integrate",6)); + end + + if imag(%x0)<>0 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real expected.\n"),"integrate",3)); + end + + if norm(imag(%x1),1)<>0 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real expected.\n"),"integrate",4)); + else + %x1=real(%x1) + end + // + + try + if %expr==%var then + deff(%var+"=%func("+%var+")",%expr) + else + deff("ans=%func("+%var+")",%expr) + end + catch + error(msprintf(gettext("%s: Wrong value for input argument #%d: syntax error in given expression\n"),"integrate",1)); + end + + if strstr(%expr,"%i") <> "" then + error(msprintf(_("%s: Wrong value for input argument #%d: A real expected.\n"),"integrate",1)); + end + + [%x1,%ks]=gsort(%x1,"g","i") + %x=zeros(%x1) + + %kkk=find((%x1(1:$-1)<%x0) & (%x1(2:$)>=%x0)) + if %kkk <>[] then + %xx0=%x0; + for %kk=1:%kkk + %x(%kk)=-intg(%xx0,%x1(%kk),%func,%ea,%er); + %xx0=%x1(%kk); + end + end + %xx0=%x0; + for %kk=1:size(%x1,"*") + %x(%kk)=intg(%xx0,%x1(%kk),%func,%ea,%er); + %xx0=%x1(%kk); + end + %x=cumsum(%x) + %x=matrix(%x(%ks),size(%x1)); + +endfunction diff --git a/modules/differential_equations/macros/intl.bin b/modules/differential_equations/macros/intl.bin Binary files differnew file mode 100755 index 000000000..68d05cbfe --- /dev/null +++ b/modules/differential_equations/macros/intl.bin diff --git a/modules/differential_equations/macros/intl.sci b/modules/differential_equations/macros/intl.sci new file mode 100755 index 000000000..0fd9beee7 --- /dev/null +++ b/modules/differential_equations/macros/intl.sci @@ -0,0 +1,43 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA - Farid BELAHCENE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function r=intl(a,b,z0,r,f,ea,er) + //If f is a complex-valued function, intl(a,b,z0,r,f) computes + //the integral of f(z)dz along the complex plane curve defined by + // z0 + r.exp(%i*t) + //for a<=t<=b . + //(part of the circle with center z0 and radius r with phase between a and b) + //! + + //First compile f if necessary: + + rhs=argn(2) + if rhs<7 then + er=%eps; + end + if rhs<6 then + ea=1.d-12; + end + + if type(f)==11 then + comp(f) + end; + //Define two functions for the real part and + //imaginary part of f(g(t))*g'(t) where g(t) is a + //parametrization of the circle. + deff("y=real1(t)",[ + "z=r*exp(%i*((1-t)*a+t*b))" + "y=real(f(z+z0)*%i*(b-a)*z)"] ) + + deff("y=imag1(t)",[ + "z=r*exp(%i*((1-t)*a+t*b))" + "y=imag(f(z+z0)*%i*(b-a)*z)"] ) + + r=intg(0,1,real1,ea,er)+%i*intg(0,1,imag1,ea,er) +endfunction diff --git a/modules/differential_equations/macros/intsplin.bin b/modules/differential_equations/macros/intsplin.bin Binary files differnew file mode 100755 index 000000000..b84f3698a --- /dev/null +++ b/modules/differential_equations/macros/intsplin.bin diff --git a/modules/differential_equations/macros/intsplin.sci b/modules/differential_equations/macros/intsplin.sci new file mode 100755 index 000000000..22d463f22 --- /dev/null +++ b/modules/differential_equations/macros/intsplin.sci @@ -0,0 +1,34 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function v = intsplin(x,s) + //splin numerical integration. + //v = intsplin(x,s) computes the integral of y with respect to x using + //splin interpolation and integration. + //x and y must be vectors of the same dimension + // + //v = intsplin(s) computes the integral of y assuming unit + //spacing between the data points. + + [lhs,rhs]=argn(0) + if rhs<2 then + s=x; + s=s(:); + d=splin((1:size(s,"*"))',s); + v=sum((d(1:$-1)-d(2:$))/12 + (s(1:$-1)+s(2:$))/2); + else + if size(x,"*")<>size(s,"*") then + error(msprintf(gettext("%s: Wrong size for input arguments: Same size expected.\n"),"intsplin")); + end + end + x=x(:);s=s(:); + d=splin(x,s); + h=x(2:$)-x(1:$-1); + v=sum((h.*(d(1:$-1)-d(2:$))/12 + (s(1:$-1)+s(2:$))/2).*h); +endfunction diff --git a/modules/differential_equations/macros/inttrap.bin b/modules/differential_equations/macros/inttrap.bin Binary files differnew file mode 100755 index 000000000..a22819a26 --- /dev/null +++ b/modules/differential_equations/macros/inttrap.bin diff --git a/modules/differential_equations/macros/inttrap.sci b/modules/differential_equations/macros/inttrap.sci new file mode 100755 index 000000000..5d07044d4 --- /dev/null +++ b/modules/differential_equations/macros/inttrap.sci @@ -0,0 +1,28 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function v = inttrap(x,y) + //inttrap Trapezoidal numerical integration. + //v = inttrap(x,y) computes the integral of y with respect to x using + //trapezoidal integration. x and y must be vectors of the same dimension + //v = inttrap(y) computes the trapezoidal integral of y assuming unit + //spacing between the data points. + + [lhs,rhs]=argn(0) + if rhs<2 then + y=x; + v=sum(y(1:$-1) + y(2:$))/2; + else + if size(x,"*")<>size(y,"*") then + error(msprintf(gettext("%s: Wrong size for input arguments: Same size expected.\n"),"inttrap")); + end + x=x(:);y=y(:); + v=(x(2:$)-x(1:$-1))'*(y(1:$-1) + y(2:$))/2; + end +endfunction diff --git a/modules/differential_equations/macros/lib b/modules/differential_equations/macros/lib Binary files differnew file mode 100755 index 000000000..f47f3b830 --- /dev/null +++ b/modules/differential_equations/macros/lib diff --git a/modules/differential_equations/macros/names b/modules/differential_equations/macros/names new file mode 100755 index 000000000..7b492b79f --- /dev/null +++ b/modules/differential_equations/macros/names @@ -0,0 +1,8 @@ +dae +daeoptions +intc +integrate +intl +intsplin +inttrap +odeoptions diff --git a/modules/differential_equations/macros/odeoptions.bin b/modules/differential_equations/macros/odeoptions.bin Binary files differnew file mode 100755 index 000000000..b25e94fb3 --- /dev/null +++ b/modules/differential_equations/macros/odeoptions.bin diff --git a/modules/differential_equations/macros/odeoptions.sci b/modules/differential_equations/macros/odeoptions.sci new file mode 100755 index 000000000..9782b4310 --- /dev/null +++ b/modules/differential_equations/macros/odeoptions.sci @@ -0,0 +1,105 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// ... +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [%ODEOPTIONS] = odeoptions(%ODEOPTIONS) + + //%ODEOPTIONS=[itask,tcrit,h0,hmax,hmin,jactyp,mxstep,.. + // maxordn,maxords,ixpr, ml,mu] + // This function displays the command line + // %ODEOPTIONS=[...] to be executed + // for defining the variable %ODEOPTIONS + // This variables sets a number of optional parameters + // for the lsod* fortran routines. + + //** This function can be (ab)used from the Scilab command line and + //** inside a Scicos "context". In order to handle the different situations, + //** the required library are loaded if not already present in the + //** "semiglobal-local-environment". + + if exists("scicos_scicoslib")==0 then + load("SCI/modules/scicos/macros/scicos_scicos/lib") ; + end + + if exists("scicos_autolib")==0 then + load("SCI/modules/scicos/macros/scicos_auto/lib") ; + end + + if exists("scicos_utilslib")==0 then + load("SCI/modules/scicos/macros/scicos_utils/lib") ; + end + + options = [1,0,0,%inf,0,2,500,12,5,0,-1,-1]; + default = [string(options(1:10)),sci2exp(options(11:12))] + default(find(default=="Inf"))="%inf" + + if argn(2)>0 then + options=%ODEOPTIONS + end + + lab_=[string(options(1:10)),sci2exp(options(11:12))] + lab_(find(lab_=="Inf"))="%inf" + + + chapeau=[gettext("Defining %ODEOPTIONS variable"); + "*****************************"; + gettext("Meaning of itask and tcrit:"); + gettext("1 : normal computation at specified times"); + gettext("2 : computation at mesh points (given in first row of output of ode)"); + gettext("3 : one step at one internal mesh point and return"); + gettext("4 : normal computation without overshooting tcrit"); + gettext("5 : one step, without passing tcrit, and return"); + " "; + gettext("Meaning of jactype:"); + gettext("0 : functional iterations (no jacobian used (''adams'' or ''stiff'' only))"); + gettext("1 : user-supplied full jacobian"); + gettext("2 : internally generated full jacobian"); + gettext("3 : internally generated diagonal jacobian (''adams'' or ''stiff'' only)"); + gettext("4 : user-supplied banded jacobian (see ml,mu)"); + gettext("5 : internally generated banded jacobian (see ml,mu)"); + " "; + gettext("Meaning of ml,mu:"); + gettext("If jactype = 4 or 5 ml and mu are the lower and upper half-bandwidths"); + gettext("of the banded jacobian: the band is the i,j''s with i-ml <= j <= ny-1"); + gettext("If jactype = 4 the jacobian function must return"); + gettext("a matrix J which is ml+mu+1 x ny (where ny=dim of y in ydot=f(t,y))"); + gettext("such that column 1 of J is made of mu zeros followed by"); + gettext("df1/dy1, df2/dy1, df3/dy1,... (1+ml possibly non-zero entries)"); + gettext("column 2 is made of mu-1 zeros followed by df1/dx2, df2/dx2,etc"); + " "; + gettext("Default values are given in square brackets"); + gettext("If the function is called without argument, default values are used"); + ] + + dims = list("vec",1,"vec",1,"vec",1,"vec",1,"vec",1,.. + "vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",2); + + + labels = ["itask (1,2,3,4,5) ",gettext("tcrit (assumes itask=4 or 5)"),... + gettext("h0 (first step tried)"),... + gettext( "hmax (max step size)"),... + gettext("hmin (min step size)"),... + "jactype (0,1,2,3,4,5)",... + gettext("mxstep (max number of steps allowed)"),... + gettext("maxordn (maximum non-stiff order allowed, at most 12)"),... + gettext("maxords (maximum stiff order allowed, at most 5)"),... + gettext("ixpr (print level 0 or 1)"),"[ml,mu]"] +" ["+default+"]"; + + [ok,itask,tcrit,h0,hmax,hmin,jactyp,mxstep,maxordn,maxords,ixpr,mlmu] = getvalue(chapeau,labels,dims,lab_); + ml = mlmu(1); + mu = mlmu(2); + ODEOPTIONS = [itask,tcrit,h0,hmax,hmin,jactyp,mxstep,maxordn,maxords,ixpr,ml,mu]; + + if ODEOPTIONS<>[] then + %ODEOPTIONS=ODEOPTIONS + else + %ODEOPTIONS=options + end + +endfunction |