2928
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include <string> |
|
28 |
3567
|
29 #include <iomanip> |
3523
|
30 #include <iostream> |
2928
|
31 |
|
32 #include "LSODE.h" |
|
33 #include "lo-mappers.h" |
|
34 |
|
35 #include "defun-dld.h" |
|
36 #include "error.h" |
|
37 #include "gripes.h" |
|
38 #include "oct-obj.h" |
2968
|
39 #include "ov-fcn.h" |
2928
|
40 #include "pager.h" |
3952
|
41 #include "pr-output.h" |
3243
|
42 #include "unwind-prot.h" |
2928
|
43 #include "utils.h" |
|
44 #include "variables.h" |
|
45 |
|
46 // Global pointer for user defined function required by lsode. |
2968
|
47 static octave_function *lsode_fcn; |
2928
|
48 |
|
49 // Global pointer for optional user defined jacobian function used by lsode. |
2968
|
50 static octave_function *lsode_jac; |
2928
|
51 |
|
52 static LSODE_options lsode_opts; |
|
53 |
3243
|
54 // Is this a recursive call? |
|
55 static int call_depth = 0; |
|
56 |
2928
|
57 ColumnVector |
|
58 lsode_user_function (const ColumnVector& x, double t) |
|
59 { |
|
60 ColumnVector retval; |
|
61 |
|
62 int nstates = x.capacity (); |
|
63 |
|
64 octave_value_list args; |
|
65 args(1) = t; |
|
66 |
|
67 Matrix m (nstates, 1); |
|
68 for (int i = 0; i < nstates; i++) |
|
69 m (i, 0) = x (i); |
|
70 octave_value state (m); |
|
71 args(0) = state; |
|
72 |
|
73 if (lsode_fcn) |
|
74 { |
3544
|
75 octave_value_list tmp = lsode_fcn->do_multi_index_op (1, args); |
2928
|
76 |
|
77 if (error_state) |
|
78 { |
|
79 gripe_user_supplied_eval ("lsode"); |
|
80 return retval; |
|
81 } |
|
82 |
|
83 if (tmp.length () > 0 && tmp(0).is_defined ()) |
|
84 { |
3419
|
85 retval = ColumnVector (tmp(0).vector_value ()); |
2928
|
86 |
|
87 if (error_state || retval.length () == 0) |
|
88 gripe_user_supplied_eval ("lsode"); |
|
89 } |
|
90 else |
|
91 gripe_user_supplied_eval ("lsode"); |
|
92 } |
|
93 |
|
94 return retval; |
|
95 } |
|
96 |
|
97 Matrix |
|
98 lsode_user_jacobian (const ColumnVector& x, double t) |
|
99 { |
|
100 Matrix retval; |
|
101 |
|
102 int nstates = x.capacity (); |
|
103 |
|
104 octave_value_list args; |
|
105 args(1) = t; |
|
106 |
|
107 Matrix m (nstates, 1); |
|
108 for (int i = 0; i < nstates; i++) |
|
109 m (i, 0) = x (i); |
|
110 octave_value state (m); |
|
111 args(0) = state; |
|
112 |
|
113 if (lsode_jac) |
|
114 { |
3544
|
115 octave_value_list tmp = lsode_jac->do_multi_index_op (1, args); |
2928
|
116 |
|
117 if (error_state) |
|
118 { |
|
119 gripe_user_supplied_eval ("lsode"); |
|
120 return retval; |
|
121 } |
|
122 |
|
123 if (tmp.length () > 0 && tmp(0).is_defined ()) |
|
124 { |
|
125 retval = tmp(0).matrix_value (); |
|
126 |
|
127 if (error_state || retval.length () == 0) |
|
128 gripe_user_supplied_eval ("lsode"); |
|
129 } |
|
130 else |
|
131 gripe_user_supplied_eval ("lsode"); |
|
132 } |
|
133 |
|
134 return retval; |
|
135 } |
|
136 |
3323
|
137 #define LSODE_ABORT() \ |
|
138 do \ |
|
139 { \ |
|
140 unwind_protect::run_frame ("Flsode"); \ |
|
141 return retval; \ |
|
142 } \ |
|
143 while (0) |
|
144 |
|
145 #define LSODE_ABORT1(msg) \ |
|
146 do \ |
|
147 { \ |
3747
|
148 ::error ("lsode: " msg); \ |
3323
|
149 LSODE_ABORT (); \ |
|
150 } \ |
|
151 while (0) |
|
152 |
|
153 #define LSODE_ABORT2(fmt, arg) \ |
|
154 do \ |
|
155 { \ |
3747
|
156 ::error ("lsode: " fmt, arg); \ |
3323
|
157 LSODE_ABORT (); \ |
|
158 } \ |
|
159 while (0) |
|
160 |
2928
|
161 DEFUN_DLD (lsode, args, nargout, |
3373
|
162 "-*- texinfo -*-\n\ |
3959
|
163 @deftypefn {Loadable Function} {[@var{x}, @var{istate}, @var{msg}]} lsode (@var{fcn}, @var{x0}, @var{t}, @var{t_crit})\n\ |
3373
|
164 Return a matrix of @var{x} as a function of @var{t}, given the initial\n\ |
|
165 state of the system @var{x0}. Each row in the result matrix corresponds\n\ |
|
166 to one of the elements in the vector @var{t}. The first element of\n\ |
|
167 @var{t} corresponds to the initial state @var{x0}, so that the first row\n\ |
|
168 of the output is @var{x0}.\n\ |
|
169 \n\ |
|
170 The first argument, @var{fcn}, is a string that names the function to\n\ |
|
171 call to compute the vector of right hand sides for the set of equations.\n\ |
|
172 It must have the form\n\ |
2928
|
173 \n\ |
3373
|
174 @example\n\ |
|
175 @var{xdot} = f (@var{x}, @var{t})\n\ |
|
176 @end example\n\ |
2928
|
177 \n\ |
3373
|
178 @noindent\n\ |
|
179 where @var{xdot} and @var{x} are vectors and @var{t} is a scalar.\n\ |
2928
|
180 \n\ |
3373
|
181 The fourth argument is optional, and may be used to specify a set of\n\ |
|
182 times that the ODE solver should not integrate past. It is useful for\n\ |
|
183 avoiding difficulties with singularities and points where there is a\n\ |
|
184 discontinuity in the derivative.\n\ |
3964
|
185 \n\ |
|
186 You can use the function @code{lsode_options} to set optional\n\ |
|
187 parameters for @code{lsode}.\n\ |
3373
|
188 @end deftypefn") |
2928
|
189 { |
|
190 octave_value_list retval; |
|
191 |
3243
|
192 unwind_protect::begin_frame ("Flsode"); |
2928
|
193 |
3243
|
194 unwind_protect_int (call_depth); |
|
195 call_depth++; |
|
196 |
|
197 if (call_depth > 1) |
3323
|
198 LSODE_ABORT1 ("invalid recursive call"); |
2928
|
199 |
3243
|
200 int nargin = args.length (); |
2928
|
201 |
3959
|
202 if (nargin > 2 && nargin < 5 && nargout < 4) |
2928
|
203 { |
3991
|
204 lsode_fcn = 0; |
|
205 lsode_jac = 0; |
|
206 |
3243
|
207 octave_value f_arg = args(0); |
2928
|
208 |
3243
|
209 switch (f_arg.rows ()) |
|
210 { |
|
211 case 1: |
|
212 lsode_fcn = extract_function |
3991
|
213 (f_arg, "lsode", "__lsode_fcn__", |
3243
|
214 "function xdot = __lsode_fcn__ (x, t) xdot = ", |
|
215 "; endfunction"); |
|
216 break; |
2928
|
217 |
3243
|
218 case 2: |
2928
|
219 { |
3991
|
220 string_vector tmp = f_arg.all_strings (); |
2928
|
221 |
3243
|
222 if (! error_state) |
2928
|
223 { |
3243
|
224 lsode_fcn = extract_function |
|
225 (tmp(0), "lsode", "__lsode_fcn__", |
|
226 "function xdot = __lsode_fcn__ (x, t) xdot = ", |
2928
|
227 "; endfunction"); |
|
228 |
3243
|
229 if (lsode_fcn) |
|
230 { |
|
231 lsode_jac = extract_function |
|
232 (tmp(1), "lsode", "__lsode_jac__", |
|
233 "function jac = __lsode_jac__ (x, t) jac = ", |
|
234 "; endfunction"); |
|
235 |
|
236 if (! lsode_jac) |
|
237 lsode_fcn = 0; |
|
238 } |
2928
|
239 } |
|
240 } |
3243
|
241 break; |
2928
|
242 |
3243
|
243 default: |
3323
|
244 LSODE_ABORT1 |
|
245 ("first arg should be a string or 2-element string array"); |
3243
|
246 } |
2928
|
247 |
3243
|
248 if (error_state || ! lsode_fcn) |
3323
|
249 LSODE_ABORT (); |
2928
|
250 |
3419
|
251 ColumnVector state (args(1).vector_value ()); |
2928
|
252 |
|
253 if (error_state) |
3323
|
254 LSODE_ABORT1 ("expecting state vector as second argument"); |
3243
|
255 |
3419
|
256 ColumnVector out_times (args(2).vector_value ()); |
3243
|
257 |
|
258 if (error_state) |
3323
|
259 LSODE_ABORT1 ("expecting output time vector as third argument"); |
2928
|
260 |
3243
|
261 ColumnVector crit_times; |
2928
|
262 |
3243
|
263 int crit_times_set = 0; |
|
264 if (nargin > 3) |
|
265 { |
3419
|
266 crit_times = ColumnVector (args(3).vector_value ()); |
2928
|
267 |
3243
|
268 if (error_state) |
3323
|
269 LSODE_ABORT1 ("expecting critical time vector as fourth argument"); |
2928
|
270 |
3243
|
271 crit_times_set = 1; |
|
272 } |
2928
|
273 |
3243
|
274 double tzero = out_times (0); |
|
275 |
|
276 ODEFunc func (lsode_user_function); |
|
277 if (lsode_jac) |
|
278 func.set_jacobian_function (lsode_user_jacobian); |
2928
|
279 |
3243
|
280 LSODE ode (state, tzero, func); |
|
281 |
|
282 ode.copy (lsode_opts); |
|
283 |
3859
|
284 Matrix output; |
3243
|
285 if (crit_times_set) |
|
286 output = ode.integrate (out_times, crit_times); |
|
287 else |
|
288 output = ode.integrate (out_times); |
|
289 |
|
290 if (! error_state) |
|
291 { |
3997
|
292 std::string msg = ode.error_message (); |
|
293 |
|
294 retval(2) = msg; |
3959
|
295 retval(1) = static_cast<double> (ode.integration_state ()); |
|
296 |
|
297 if (ode.integration_ok ()) |
3971
|
298 retval(0) = output; |
3959
|
299 else |
|
300 { |
3971
|
301 retval(0) = Matrix (); |
3959
|
302 |
|
303 if (nargout < 2) |
3997
|
304 error ("lsode: %s", msg.c_str ()); |
3959
|
305 } |
3243
|
306 } |
|
307 } |
2928
|
308 else |
3243
|
309 print_usage ("lsode"); |
2928
|
310 |
3243
|
311 unwind_protect::run_frame ("Flsode"); |
2928
|
312 |
|
313 return retval; |
|
314 } |
|
315 |
3952
|
316 typedef void (LSODE_options::*da_set_opt_mf) (const Array<double>&); |
2928
|
317 typedef void (LSODE_options::*d_set_opt_mf) (double); |
|
318 typedef void (LSODE_options::*i_set_opt_mf) (int); |
3955
|
319 typedef void (LSODE_options::*s_set_opt_mf) (const std::string&); |
|
320 |
3952
|
321 typedef Array<double> (LSODE_options::*da_get_opt_mf) (void) const; |
|
322 typedef double (LSODE_options::*d_get_opt_mf) (void) const; |
|
323 typedef int (LSODE_options::*i_get_opt_mf) (void) const; |
3955
|
324 typedef std::string (LSODE_options::*s_get_opt_mf) (void) const; |
2928
|
325 |
|
326 #define MAX_TOKENS 3 |
|
327 |
|
328 struct LSODE_OPTIONS |
|
329 { |
|
330 const char *keyword; |
|
331 const char *kw_tok[MAX_TOKENS + 1]; |
|
332 int min_len[MAX_TOKENS + 1]; |
|
333 int min_toks_to_match; |
3952
|
334 da_set_opt_mf da_set_fcn; |
2928
|
335 d_set_opt_mf d_set_fcn; |
|
336 i_set_opt_mf i_set_fcn; |
3955
|
337 s_set_opt_mf s_set_fcn; |
3952
|
338 da_get_opt_mf da_get_fcn; |
2928
|
339 d_get_opt_mf d_get_fcn; |
|
340 i_get_opt_mf i_get_fcn; |
3955
|
341 s_get_opt_mf s_get_fcn; |
2928
|
342 }; |
|
343 |
|
344 static LSODE_OPTIONS lsode_option_table [] = |
|
345 { |
|
346 { "absolute tolerance", |
|
347 { "absolute", "tolerance", 0, 0, }, |
|
348 { 1, 0, 0, 0, }, 1, |
3955
|
349 &LSODE_options::set_absolute_tolerance, 0, 0, 0, |
|
350 &LSODE_options::absolute_tolerance, 0, 0, 0, }, |
2928
|
351 |
|
352 { "initial step size", |
|
353 { "initial", "step", "size", 0, }, |
3955
|
354 { 3, 0, 0, 0, }, 1, |
|
355 0, &LSODE_options::set_initial_step_size, 0, 0, |
|
356 0, &LSODE_options::initial_step_size, 0, 0, }, |
|
357 |
|
358 { "integration method", |
|
359 { "integration", "method", 0, 0, }, |
|
360 { 3, 0, 0, 0, }, 1, |
|
361 0, 0, 0, &LSODE_options::set_integration_method, |
|
362 0, 0, 0, &LSODE_options::integration_method, }, |
2928
|
363 |
|
364 { "maximum step size", |
|
365 { "maximum", "step", "size", 0, }, |
|
366 { 2, 0, 0, 0, }, 1, |
3955
|
367 0, &LSODE_options::set_maximum_step_size, 0, 0, |
|
368 0, &LSODE_options::maximum_step_size, 0, 0, }, |
2928
|
369 |
|
370 { "minimum step size", |
|
371 { "minimum", "step", "size", 0, }, |
|
372 { 2, 0, 0, 0, }, 1, |
3955
|
373 0, &LSODE_options::set_minimum_step_size, 0, 0, |
|
374 0, &LSODE_options::minimum_step_size, 0, 0, }, |
2928
|
375 |
|
376 { "relative tolerance", |
|
377 { "relative", "tolerance", 0, 0, }, |
|
378 { 1, 0, 0, 0, }, 1, |
3955
|
379 0, &LSODE_options::set_relative_tolerance, 0, 0, |
|
380 0, &LSODE_options::relative_tolerance, 0, 0, }, |
2928
|
381 |
|
382 { "step limit", |
|
383 { "step", "limit", 0, 0, }, |
|
384 { 1, 0, 0, 0, }, 1, |
3955
|
385 0, 0, &LSODE_options::set_step_limit, 0, |
|
386 0, 0, &LSODE_options::step_limit, 0, }, |
2928
|
387 |
|
388 { 0, |
|
389 { 0, 0, 0, 0, }, |
|
390 { 0, 0, 0, 0, }, 0, |
3955
|
391 0, 0, 0, 0, |
|
392 0, 0, 0, 0, }, |
2928
|
393 }; |
|
394 |
|
395 static void |
3523
|
396 print_lsode_option_list (std::ostream& os) |
2928
|
397 { |
|
398 print_usage ("lsode_options", 1); |
|
399 |
|
400 os << "\n" |
|
401 << "Options for lsode include:\n\n" |
|
402 << " keyword value\n" |
|
403 << " ------- -----\n\n"; |
|
404 |
|
405 LSODE_OPTIONS *list = lsode_option_table; |
|
406 |
|
407 const char *keyword; |
|
408 while ((keyword = list->keyword) != 0) |
|
409 { |
3568
|
410 os << " " |
|
411 << std::setiosflags (std::ios::left) << std::setw (40) |
|
412 << keyword |
|
413 << std::resetiosflags (std::ios::left) |
|
414 << " "; |
3567
|
415 |
3952
|
416 if (list->da_get_fcn) |
|
417 { |
|
418 Array<double> val = (lsode_opts.*list->da_get_fcn) (); |
|
419 if (val.length () == 1) |
|
420 { |
|
421 if (val(0) < 0.0) |
|
422 os << "computed automatically"; |
|
423 else |
|
424 os << val(0); |
|
425 } |
|
426 else |
|
427 { |
|
428 os << "\n\n"; |
|
429 // XXX FIXME XXX |
|
430 Matrix tmp = Matrix (ColumnVector (val)); |
|
431 octave_print_internal (os, tmp, false, 2); |
|
432 os << "\n"; |
|
433 } |
|
434 } |
|
435 else if (list->d_get_fcn) |
2928
|
436 { |
|
437 double val = (lsode_opts.*list->d_get_fcn) (); |
|
438 if (val < 0.0) |
|
439 os << "computed automatically"; |
|
440 else |
|
441 os << val; |
|
442 } |
3955
|
443 else if (list->i_get_fcn) |
2928
|
444 { |
|
445 int val = (lsode_opts.*list->i_get_fcn) (); |
|
446 if (val < 0) |
|
447 os << "infinite"; |
|
448 else |
|
449 os << val; |
|
450 } |
3955
|
451 else if (list->s_get_fcn) |
|
452 { |
|
453 os << (lsode_opts.*list->s_get_fcn) (); |
|
454 } |
|
455 else |
|
456 panic_impossible (); |
|
457 |
2928
|
458 os << "\n"; |
|
459 list++; |
|
460 } |
|
461 |
|
462 os << "\n"; |
|
463 } |
|
464 |
|
465 static void |
3523
|
466 set_lsode_option (const std::string& keyword, double val) |
2928
|
467 { |
|
468 LSODE_OPTIONS *list = lsode_option_table; |
|
469 |
|
470 while (list->keyword != 0) |
|
471 { |
|
472 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
473 list->min_toks_to_match, MAX_TOKENS)) |
|
474 { |
3957
|
475 if (list->da_set_fcn) |
|
476 { |
|
477 Array<double> tmp (1, val); |
|
478 (lsode_opts.*list->da_set_fcn) (tmp); |
|
479 } |
|
480 else if (list->d_set_fcn) |
|
481 { |
|
482 (lsode_opts.*list->d_set_fcn) (val); |
|
483 } |
2928
|
484 else |
|
485 { |
|
486 if (xisnan (val)) |
|
487 { |
|
488 error ("lsode_options: %s: expecting integer, found NaN", |
|
489 keyword.c_str ()); |
|
490 } |
|
491 else |
|
492 (lsode_opts.*list->i_set_fcn) (NINT (val)); |
|
493 } |
|
494 return; |
|
495 } |
|
496 list++; |
|
497 } |
|
498 |
|
499 warning ("lsode_options: no match for `%s'", keyword.c_str ()); |
|
500 } |
|
501 |
3952
|
502 static void |
|
503 set_lsode_option (const std::string& keyword, const Array<double>& val) |
|
504 { |
|
505 LSODE_OPTIONS *list = lsode_option_table; |
|
506 |
|
507 while (list->keyword != 0) |
|
508 { |
|
509 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
510 list->min_toks_to_match, MAX_TOKENS)) |
|
511 { |
|
512 if (list->da_set_fcn) |
|
513 (lsode_opts.*list->da_set_fcn) (val); |
|
514 else |
|
515 error ("lsode_options: no function to handle vector option"); |
|
516 |
|
517 return; |
|
518 } |
|
519 list++; |
|
520 } |
|
521 |
|
522 warning ("lsode_options: no match for `%s'", keyword.c_str ()); |
|
523 } |
|
524 |
3955
|
525 static void |
|
526 set_lsode_option (const std::string& keyword, const std::string& val) |
|
527 { |
|
528 LSODE_OPTIONS *list = lsode_option_table; |
|
529 |
|
530 while (list->keyword != 0) |
|
531 { |
|
532 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
533 list->min_toks_to_match, MAX_TOKENS)) |
|
534 { |
|
535 if (list->s_set_fcn) |
|
536 (lsode_opts.*list->s_set_fcn) (val); |
|
537 else |
|
538 error ("lsode_options: no function to handle string option"); |
|
539 |
|
540 return; |
|
541 } |
|
542 list++; |
|
543 } |
|
544 |
|
545 warning ("lsode_options: no match for `%s'", keyword.c_str ()); |
|
546 } |
|
547 |
2928
|
548 static octave_value_list |
3523
|
549 show_lsode_option (const std::string& keyword) |
2928
|
550 { |
|
551 octave_value retval; |
|
552 |
|
553 LSODE_OPTIONS *list = lsode_option_table; |
|
554 |
|
555 while (list->keyword != 0) |
|
556 { |
|
557 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
558 list->min_toks_to_match, MAX_TOKENS)) |
|
559 { |
3952
|
560 if (list->da_get_fcn) |
|
561 { |
|
562 Array<double> val = (lsode_opts.*list->da_get_fcn) (); |
|
563 if (val.length () == 1) |
|
564 { |
|
565 if (val(0) < 0.0) |
|
566 retval = "computed automatically"; |
|
567 else |
|
568 retval = val(0); |
|
569 } |
|
570 else |
|
571 retval = ColumnVector (val); |
|
572 } |
|
573 else if (list->d_get_fcn) |
2928
|
574 { |
|
575 double val = (lsode_opts.*list->d_get_fcn) (); |
|
576 if (val < 0.0) |
|
577 retval = "computed automatically"; |
|
578 else |
|
579 retval = val; |
|
580 } |
3955
|
581 else if (list->i_get_fcn) |
2928
|
582 { |
|
583 int val = (lsode_opts.*list->i_get_fcn) (); |
|
584 if (val < 0) |
|
585 retval = "infinite"; |
|
586 else |
|
587 retval = static_cast<double> (val); |
|
588 } |
3955
|
589 else if (list->s_get_fcn) |
|
590 { |
|
591 retval = (lsode_opts.*list->s_get_fcn) (); |
|
592 } |
|
593 else |
|
594 panic_impossible (); |
2928
|
595 |
|
596 return retval; |
|
597 } |
|
598 list++; |
|
599 } |
|
600 |
|
601 warning ("lsode_options: no match for `%s'", keyword.c_str ()); |
|
602 |
|
603 return retval; |
|
604 } |
|
605 |
|
606 DEFUN_DLD (lsode_options, args, , |
3373
|
607 "-*- texinfo -*-\n\ |
|
608 @deftypefn {Loadable Function} {} lsode_options (@var{opt}, @var{val})\n\ |
|
609 When called with two arguments, this function allows you set options\n\ |
|
610 parameters for the function @code{lsode}. Given one argument,\n\ |
|
611 @code{lsode_options} returns the value of the corresponding option. If\n\ |
|
612 no arguments are supplied, the names of all the available options and\n\ |
|
613 their current values are displayed.\n\ |
|
614 @end deftypefn") |
2928
|
615 { |
|
616 octave_value_list retval; |
|
617 |
|
618 int nargin = args.length (); |
|
619 |
|
620 if (nargin == 0) |
|
621 { |
|
622 print_lsode_option_list (octave_stdout); |
|
623 } |
|
624 else if (nargin == 1 || nargin == 2) |
|
625 { |
3523
|
626 std::string keyword = args(0).string_value (); |
2928
|
627 |
|
628 if (! error_state) |
|
629 { |
|
630 if (nargin == 1) |
3952
|
631 retval = show_lsode_option (keyword); |
2928
|
632 else |
|
633 { |
3955
|
634 if (args(1).is_string ()) |
|
635 { |
|
636 std::string val = args(1).string_value (); |
|
637 |
|
638 if (! error_state) |
|
639 set_lsode_option (keyword, val); |
|
640 } |
|
641 else if (args(1).is_scalar_type ()) |
3952
|
642 { |
|
643 double val = args(1).double_value (); |
2928
|
644 |
3952
|
645 if (! error_state) |
|
646 set_lsode_option (keyword, val); |
|
647 } |
|
648 else |
2928
|
649 { |
3952
|
650 Array<double> val = args(1).vector_value (); |
|
651 |
|
652 if (! error_state) |
|
653 set_lsode_option (keyword, val); |
2928
|
654 } |
|
655 } |
|
656 } |
|
657 } |
3952
|
658 else |
|
659 print_usage ("lsode_options"); |
2928
|
660 |
|
661 return retval; |
|
662 } |
|
663 |
|
664 /* |
|
665 ;;; Local Variables: *** |
|
666 ;;; mode: C++ *** |
|
667 ;;; End: *** |
|
668 */ |