Mercurial > octave
annotate libinterp/corefcn/lsode.cc @ 30896:c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
* __eigs__.cc, bsxfun.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc,
debug.cc, error.cc, graphics.cc, graphics.in.h, gzfstream.h, ls-hdf5.cc,
lsode.cc, max.cc, oct-opengl.h, quad.cc, strfns.cc, utils.cc, utils.h,
variables.cc, __ode15__.cc, gzip.cc, cdef-manager.cc, ov-fcn-handle.cc,
ov-java.cc, ov-usr-fcn.cc, bp-table.cc, bp-table.h, lex.h, lex.ll,
oct-parse.yy, pt-eval.cc:
Replace "func", "fun", "fn" in documentation and variable names with "fcn".
author | Rik <rik@octave.org> |
---|---|
date | Tue, 05 Apr 2022 08:33:58 -0700 |
parents | 796f54d4ddbf |
children | 773a361bc476 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29996
diff
changeset
|
3 // Copyright (C) 1996-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2928 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
2928 | 28 #endif |
29 | |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
30 #include <list> |
2928 | 31 #include <string> |
32 | |
33 #include "LSODE.h" | |
34 #include "lo-mappers.h" | |
35 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14854
diff
changeset
|
36 #include "defun.h" |
2928 | 37 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20990
diff
changeset
|
38 #include "errwarn.h" |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
39 #include "interpreter-private.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20909
diff
changeset
|
40 #include "ovl.h" |
2968 | 41 #include "ov-fcn.h" |
5729 | 42 #include "ov-cell.h" |
2928 | 43 #include "pager.h" |
23473
55916f99b8b6
prefer feval over do_multi_index_op
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
44 #include "parse.h" |
3952 | 45 #include "pr-output.h" |
3243 | 46 #include "unwind-prot.h" |
2928 | 47 #include "utils.h" |
48 #include "variables.h" | |
49 | |
3998 | 50 #include "LSODE-opts.cc" |
51 | |
29996
c4bc77a90fb5
move lsode functions to octave namespace and make local functions static
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
52 OCTAVE_NAMESPACE_BEGIN |
c4bc77a90fb5
move lsode functions to octave namespace and make local functions static
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
53 |
2928 | 54 // Global pointer for user defined function required by lsode. |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
55 static octave_value lsode_fcn; |
2928 | 56 |
57 // Global pointer for optional user defined jacobian function used by lsode. | |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
58 static octave_value lsode_jac; |
2928 | 59 |
4140 | 60 // Have we warned about imaginary values returned from user function? |
61 static bool warned_fcn_imaginary = false; | |
62 static bool warned_jac_imaginary = false; | |
63 | |
3243 | 64 // Is this a recursive call? |
65 static int call_depth = 0; | |
66 | |
29996
c4bc77a90fb5
move lsode functions to octave namespace and make local functions static
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
67 static ColumnVector |
2928 | 68 lsode_user_function (const ColumnVector& x, double t) |
69 { | |
70 ColumnVector retval; | |
71 | |
72 octave_value_list args; | |
73 args(1) = t; | |
4628 | 74 args(0) = x; |
2928 | 75 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
76 if (lsode_fcn.is_defined ()) |
2928 | 77 { |
20725
7164a69472dd
eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
78 octave_value_list tmp; |
2928 | 79 |
20725
7164a69472dd
eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
80 try |
7164a69472dd
eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
81 { |
23473
55916f99b8b6
prefer feval over do_multi_index_op
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
82 tmp = octave::feval (lsode_fcn, args, 1); |
20725
7164a69472dd
eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
83 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28817
diff
changeset
|
84 catch (octave::execution_exception& ee) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
85 { |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28817
diff
changeset
|
86 err_user_supplied_eval (ee, "lsode"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
87 } |
2928 | 88 |
21885
0806871e3e1e
maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
89 if (tmp.empty () || ! tmp(0).is_defined ()) |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
90 err_user_supplied_eval ("lsode"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
91 |
23581
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
92 if (! warned_fcn_imaginary && tmp(0).iscomplex ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
93 { |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
94 warning ("lsode: ignoring imaginary part returned from user-supplied function"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
95 warned_fcn_imaginary = true; |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
96 } |
4140 | 97 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
98 retval = tmp(0).xvector_value ("lsode: expecting user supplied function to return numeric vector"); |
2928 | 99 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
100 if (retval.isempty ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20990
diff
changeset
|
101 err_user_supplied_eval ("lsode"); |
2928 | 102 } |
103 | |
104 return retval; | |
105 } | |
106 | |
29996
c4bc77a90fb5
move lsode functions to octave namespace and make local functions static
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
107 static Matrix |
2928 | 108 lsode_user_jacobian (const ColumnVector& x, double t) |
109 { | |
110 Matrix retval; | |
111 | |
112 octave_value_list args; | |
113 args(1) = t; | |
4628 | 114 args(0) = x; |
2928 | 115 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
116 if (lsode_jac.is_defined ()) |
2928 | 117 { |
20725
7164a69472dd
eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
118 octave_value_list tmp; |
2928 | 119 |
20725
7164a69472dd
eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
120 try |
7164a69472dd
eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
121 { |
23473
55916f99b8b6
prefer feval over do_multi_index_op
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
122 tmp = octave::feval (lsode_jac, args, 1); |
20725
7164a69472dd
eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
123 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28817
diff
changeset
|
124 catch (octave::execution_exception& ee) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
125 { |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28817
diff
changeset
|
126 err_user_supplied_eval (ee, "lsode"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
127 } |
2928 | 128 |
21885
0806871e3e1e
maint: Prefer is_empty() rather than "length () == 0".
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
129 if (tmp.empty () || ! tmp(0).is_defined ()) |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
130 err_user_supplied_eval ("lsode"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
131 |
23581
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
132 if (! warned_jac_imaginary && tmp(0).iscomplex ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
133 { |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
134 warning ("lsode: ignoring imaginary part returned from user-supplied jacobian function"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
135 warned_jac_imaginary = true; |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
136 } |
4140 | 137 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
138 retval = tmp(0).xmatrix_value ("lsode: expecting user supplied jacobian function to return numeric array"); |
2928 | 139 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
140 if (retval.isempty ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20990
diff
changeset
|
141 err_user_supplied_eval ("lsode"); |
2928 | 142 } |
143 | |
144 return retval; | |
145 } | |
146 | |
23699
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
147 DEFMETHOD (lsode, interp, args, nargout, |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
148 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
149 @deftypefn {} {[@var{x}, @var{istate}, @var{msg}] =} lsode (@var{fcn}, @var{x_0}, @var{t}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
150 @deftypefnx {} {[@var{x}, @var{istate}, @var{msg}] =} lsode (@var{fcn}, @var{x_0}, @var{t}, @var{t_crit}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
151 Ordinary Differential Equation (ODE) solver. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
152 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
153 The set of differential equations to solve is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
154 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
155 $$ {dx \over dt} = f (x, t) $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
156 with |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
157 $$ x(t_0) = x_0 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
158 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
159 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
160 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
161 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
162 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
163 dx |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
164 -- = f (x, t) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
165 dt |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
166 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
167 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
168 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
169 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
170 with |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
171 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
172 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
173 x(t_0) = x_0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
174 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
175 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
176 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
177 The solution is returned in the matrix @var{x}, with each row |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
178 corresponding to an element of the vector @var{t}. The first element |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
179 of @var{t} should be @math{t_0} and should correspond to the initial |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
180 state of the system @var{x_0}, so that the first row of the output |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
181 is @var{x_0}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
182 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
183 The first argument, @var{fcn}, is a string, inline, or function handle |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
184 that names the function @math{f} to call to compute the vector of right |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
185 hand sides for the set of equations. The function must have the form |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
186 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
187 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
188 @var{xdot} = f (@var{x}, @var{t}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
189 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
190 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
191 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
192 in which @var{xdot} and @var{x} are vectors and @var{t} is a scalar. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
193 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
194 If @var{fcn} is a two-element string array or a two-element cell array |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
195 of strings, inline functions, or function handles, the first element names |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
196 the function @math{f} described above, and the second element names a |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
197 function to compute the Jacobian of @math{f}. The Jacobian function |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
198 must have the form |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
199 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
200 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
201 @var{jac} = j (@var{x}, @var{t}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
202 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
203 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
204 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
205 in which @var{jac} is the matrix of partial derivatives |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
206 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
207 $$ J = {\partial f_i \over \partial x_j} = \left[\matrix{ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
208 {\partial f_1 \over \partial x_1} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
209 & {\partial f_1 \over \partial x_2} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
210 & \cdots |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
211 & {\partial f_1 \over \partial x_N} \cr |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
212 {\partial f_2 \over \partial x_1} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
213 & {\partial f_2 \over \partial x_2} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
214 & \cdots |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
215 & {\partial f_2 \over \partial x_N} \cr |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
216 \vdots & \vdots & \ddots & \vdots \cr |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
217 {\partial f_3 \over \partial x_1} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
218 & {\partial f_3 \over \partial x_2} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
219 & \cdots |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
220 & {\partial f_3 \over \partial x_N} \cr}\right]$$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
221 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
222 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
223 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
224 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
225 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
226 | df_1 df_1 df_1 | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
227 | ---- ---- ... ---- | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
228 | dx_1 dx_2 dx_N | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
229 | | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
230 | df_2 df_2 df_2 | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
231 | ---- ---- ... ---- | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
232 df_i | dx_1 dx_2 dx_N | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
233 jac = ---- = | | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
234 dx_j | . . . . | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
235 | . . . . | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
236 | . . . . | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
237 | | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
238 | df_N df_N df_N | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
239 | ---- ---- ... ---- | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
240 | dx_1 dx_2 dx_N | |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
241 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
242 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
243 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
244 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
245 |
24412
6e1d3ad32ed1
doc: Fix documentation of third input to lsode() (bug #52664).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
246 The second argument specifies the initial state of the system @math{x_0}. The |
6e1d3ad32ed1
doc: Fix documentation of third input to lsode() (bug #52664).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
247 third argument is a vector, @var{t}, specifying the time values for which a |
6e1d3ad32ed1
doc: Fix documentation of third input to lsode() (bug #52664).
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
248 solution is sought. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
249 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
250 The fourth argument is optional, and may be used to specify a set of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
251 times that the ODE solver should not integrate past. It is useful for |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
252 avoiding difficulties with singularities and points where there is a |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
253 discontinuity in the derivative. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
254 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
255 After a successful computation, the value of @var{istate} will be 2 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
256 (consistent with the Fortran version of @sc{lsode}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
257 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
258 If the computation is not successful, @var{istate} will be something |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
259 other than 2 and @var{msg} will contain additional information. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
260 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
261 You can use the function @code{lsode_options} to set optional |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
262 parameters for @code{lsode}. |
29743
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
263 |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
264 See @nospell{Alan C. Hindmarsh}, |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
265 @cite{ODEPACK, A Systematized Collection of ODE Solvers}, |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
266 in Scientific Computing, @nospell{R. S. Stepleman}, editor, (1983) |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
267 or @url{https://computing.llnl.gov/projects/odepack} |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
268 for more information about the inner workings of @code{lsode}. |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
269 |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
270 Example: Solve the @nospell{Van der Pol} equation |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
271 |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
272 @example |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
273 @group |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
274 fvdp = @@(@var{y},@var{t}) [@var{y}(2); (1 - @var{y}(1)^2) * @var{y}(2) - @var{y}(1)]; |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
275 @var{t} = linspace (0, 20, 100); |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
276 @var{y} = lsode (fvdp, [2; 0], @var{t}); |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
277 @end group |
f82a1bc641b8
doc: Improve Differential Equations chapter and example for lsode (bug #57508)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
29358
diff
changeset
|
278 @end example |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
279 @seealso{daspk, dassl, dasrt} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
280 @end deftypefn */) |
2928 | 281 { |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20892
diff
changeset
|
282 int nargin = args.length (); |
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20892
diff
changeset
|
283 |
20909
03e4ddd49396
omit unnecessary nargout checks
John W. Eaton <jwe@octave.org>
parents:
20898
diff
changeset
|
284 if (nargin < 3 || nargin > 4) |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20892
diff
changeset
|
285 print_usage (); |
2928 | 286 |
4140 | 287 warned_fcn_imaginary = false; |
288 warned_jac_imaginary = false; | |
289 | |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
290 unwind_protect_var<int> restore_var (call_depth); |
3243 | 291 call_depth++; |
292 | |
293 if (call_depth > 1) | |
20709
a2a99aaf680b
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
294 error ("lsode: invalid recursive call"); |
2928 | 295 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
296 symbol_table& symtab = interp.get_symbol_table (); |
23699
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
297 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
298 std::string fcn_name, fname, jac_name, jname; |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
299 |
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
300 lsode_fcn = octave_value (); |
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
301 lsode_jac = octave_value (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
302 |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
303 octave_value f_arg = args(0); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
304 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
305 std::list<std::string> parameter_names ({"x", "t"}); |
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
306 |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23473
diff
changeset
|
307 if (f_arg.iscell ()) |
2928 | 308 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
309 Cell c = f_arg.cell_value (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
310 if (c.numel () == 1) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
311 f_arg = c(0); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
312 else if (c.numel () == 2) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
313 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
314 lsode_fcn = get_function_handle (interp, c(0), parameter_names); |
2928 | 315 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
316 if (lsode_fcn.is_defined ()) |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
317 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
318 lsode_jac = get_function_handle (interp, c(1), parameter_names); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
319 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
320 if (lsode_jac.is_undefined ()) |
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
321 lsode_fcn = octave_value (); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
322 } |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
323 } |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
324 else |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
325 error ("lsode: incorrect number of elements in cell array"); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
326 } |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
327 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
328 if (lsode_fcn.is_undefined () && ! f_arg.iscell ()) |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
329 { |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
330 if (f_arg.is_function_handle () || f_arg.is_inline_function ()) |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
331 lsode_fcn = f_arg; |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
332 else |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
333 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
334 switch (f_arg.rows ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
335 { |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
336 case 1: |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
337 lsode_fcn = get_function_handle (interp, f_arg, parameter_names); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
338 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
339 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
340 case 2: |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
341 { |
20990
fc9cca99b2de
Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
342 string_vector tmp = f_arg.string_vector_value (); |
2928 | 343 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
344 lsode_fcn = get_function_handle (interp, tmp(0), |
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
345 parameter_names); |
2928 | 346 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
347 if (lsode_fcn.is_defined ()) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
348 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
349 lsode_jac = get_function_handle (interp, tmp(1), |
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
350 parameter_names); |
5729 | 351 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
352 if (lsode_jac.is_undefined ()) |
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
353 lsode_fcn = octave_value (); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
354 } |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
355 } |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
356 break; |
2928 | 357 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
358 default: |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
359 error ("lsode: first arg should be a string or 2-element string array"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
360 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
10066
diff
changeset
|
361 } |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
362 } |
2928 | 363 |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
364 if (lsode_fcn.is_undefined ()) |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
365 error ("lsode: FCN argument is not a valid function name or handle"); |
20687
5f04bfc7c17a
backout changeset 18f38ed43962
John W. Eaton <jwe@octave.org>
parents:
20682
diff
changeset
|
366 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
367 ColumnVector state = args(1).xvector_value ("lsode: initial state X_0 must be a vector"); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
368 ColumnVector out_times = args(2).xvector_value ("lsode: output time variable T must be a vector"); |
2928 | 369 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
370 ColumnVector crit_times; |
2928 | 371 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
372 int crit_times_set = 0; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
373 if (nargin > 3) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
374 { |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
375 crit_times = args(3).xvector_value ("lsode: list of critical times T_CRIT must be a vector"); |
2928 | 376 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
377 crit_times_set = 1; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
378 } |
2928 | 379 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
380 double tzero = out_times (0); |
3243 | 381 |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
382 ODEFunc fcn (lsode_user_function); |
26864
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
383 |
041caa61ed34
use get_function_handle instead of extract_function
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
384 if (lsode_jac.is_defined ()) |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
385 fcn.set_jacobian_function (lsode_user_jacobian); |
2928 | 386 |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
387 LSODE ode (state, tzero, fcn); |
3243 | 388 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
389 ode.set_options (lsode_opts); |
3243 | 390 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
391 Matrix output; |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
392 if (crit_times_set) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
393 output = ode.integrate (out_times, crit_times); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
394 else |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
395 output = ode.integrate (out_times); |
5729 | 396 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
397 if (fcn_name.length ()) |
23699
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
398 symtab.clear_function (fcn_name); |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
399 if (jac_name.length ()) |
23699
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
400 symtab.clear_function (jac_name); |
3997 | 401 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
402 std::string msg = ode.error_message (); |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
403 |
20898
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20892
diff
changeset
|
404 octave_value_list retval (3); |
8da80da1ac37
maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents:
20892
diff
changeset
|
405 |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
406 if (ode.integration_ok ()) |
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
407 retval(0) = output; |
20892 | 408 else if (nargout < 2) |
409 error ("lsode: %s", msg.c_str ()); | |
20801
a542a9bf177e
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
410 else |
20892 | 411 retval(0) = Matrix (); |
3959 | 412 |
20892 | 413 retval(1) = static_cast<double> (ode.integration_state ()); |
414 retval(2) = msg; | |
2928 | 415 |
416 return retval; | |
417 } | |
418 | |
419 /* | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
420 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
421 ## dassl-1.m |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
422 ## |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
423 ## Test lsode() function |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
424 ## |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
425 ## Author: David Billinghurst (David.Billinghurst@riotinto.com.au) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
426 ## Comalco Research and Technology |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
427 ## 20 May 1998 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
428 ## |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
429 ## Problem |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
430 ## |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
431 ## y1' = -y2, y1(0) = 1 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
432 ## y2' = y1, y2(0) = 0 |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
433 ## |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
434 ## Solution |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
435 ## |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
436 ## y1(t) = cos(t) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
437 ## y2(t) = sin(t) |
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
438 ## |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13915
diff
changeset
|
439 %!function xdot = __f (x, t) |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
440 %! xdot = [-x(2); x(1)]; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
441 %!endfunction |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
442 %!test |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
443 %! |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
444 %! x0 = [1; 0]; |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
445 %! xdot0 = [0; 1]; |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
446 %! t = (0:1:10)'; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
447 %! |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
448 %! tol = 500 * lsode_options ("relative tolerance"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
449 %! |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13915
diff
changeset
|
450 %! x = lsode ("__f", x0, t); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
451 %! |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
452 %! y = [cos(t), sin(t)]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
453 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
454 %! assert (x, y, tol); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
455 |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13915
diff
changeset
|
456 %!function xdotdot = __f (x, t) |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
457 %! xdotdot = [x(2); -x(1)]; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
458 %!endfunction |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
459 %!test |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
460 %! |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
461 %! x0 = [1; 0]; |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
462 %! t = [0; 2*pi]; |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
463 %! tol = 100 * dassl_options ("relative tolerance"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
464 %! |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13915
diff
changeset
|
465 %! x = lsode ("__f", x0, t); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
466 %! |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
467 %! y = [1, 0; 1, 0]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
468 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
469 %! assert (x, y, tol); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
470 |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13915
diff
changeset
|
471 %!function xdot = __f (x, t) |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
472 %! xdot = x; |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
473 %!endfunction |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
474 %!test |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
475 %! |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
476 %! x0 = 1; |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
477 %! t = [0; 1]; |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
478 %! tol = 100 * dassl_options ("relative tolerance"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
479 %! |
14085
4e8f23ccadce
test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents:
13915
diff
changeset
|
480 %! x = lsode ("__f", x0, t); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
481 %! |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
482 %! y = [1; e]; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11553
diff
changeset
|
483 %! |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
484 %! assert (x, y, tol); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
485 |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
486 %!test |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
487 %! lsode_options ("absolute tolerance", eps); |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
488 %! assert (lsode_options ("absolute tolerance") == eps); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
489 |
14501
60e5cf354d80
Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
490 %!error lsode_options ("foo", 1, 2) |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
491 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29744
diff
changeset
|
492 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29744
diff
changeset
|
493 OCTAVE_NAMESPACE_END |