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 { |
3959
|
292 retval(2) = ode.error_message (); |
|
293 retval(1) = static_cast<double> (ode.integration_state ()); |
|
294 |
|
295 if (ode.integration_ok ()) |
3971
|
296 retval(0) = output; |
3959
|
297 else |
|
298 { |
3971
|
299 retval(0) = Matrix (); |
3959
|
300 |
|
301 if (nargout < 2) |
|
302 { |
|
303 std::string msg = ode.error_message (); |
|
304 error ("lsode: %s", msg.c_str ()); |
|
305 } |
|
306 } |
3243
|
307 } |
|
308 } |
2928
|
309 else |
3243
|
310 print_usage ("lsode"); |
2928
|
311 |
3243
|
312 unwind_protect::run_frame ("Flsode"); |
2928
|
313 |
|
314 return retval; |
|
315 } |
|
316 |
3952
|
317 typedef void (LSODE_options::*da_set_opt_mf) (const Array<double>&); |
2928
|
318 typedef void (LSODE_options::*d_set_opt_mf) (double); |
|
319 typedef void (LSODE_options::*i_set_opt_mf) (int); |
3955
|
320 typedef void (LSODE_options::*s_set_opt_mf) (const std::string&); |
|
321 |
3952
|
322 typedef Array<double> (LSODE_options::*da_get_opt_mf) (void) const; |
|
323 typedef double (LSODE_options::*d_get_opt_mf) (void) const; |
|
324 typedef int (LSODE_options::*i_get_opt_mf) (void) const; |
3955
|
325 typedef std::string (LSODE_options::*s_get_opt_mf) (void) const; |
2928
|
326 |
|
327 #define MAX_TOKENS 3 |
|
328 |
|
329 struct LSODE_OPTIONS |
|
330 { |
|
331 const char *keyword; |
|
332 const char *kw_tok[MAX_TOKENS + 1]; |
|
333 int min_len[MAX_TOKENS + 1]; |
|
334 int min_toks_to_match; |
3952
|
335 da_set_opt_mf da_set_fcn; |
2928
|
336 d_set_opt_mf d_set_fcn; |
|
337 i_set_opt_mf i_set_fcn; |
3955
|
338 s_set_opt_mf s_set_fcn; |
3952
|
339 da_get_opt_mf da_get_fcn; |
2928
|
340 d_get_opt_mf d_get_fcn; |
|
341 i_get_opt_mf i_get_fcn; |
3955
|
342 s_get_opt_mf s_get_fcn; |
2928
|
343 }; |
|
344 |
|
345 static LSODE_OPTIONS lsode_option_table [] = |
|
346 { |
|
347 { "absolute tolerance", |
|
348 { "absolute", "tolerance", 0, 0, }, |
|
349 { 1, 0, 0, 0, }, 1, |
3955
|
350 &LSODE_options::set_absolute_tolerance, 0, 0, 0, |
|
351 &LSODE_options::absolute_tolerance, 0, 0, 0, }, |
2928
|
352 |
|
353 { "initial step size", |
|
354 { "initial", "step", "size", 0, }, |
3955
|
355 { 3, 0, 0, 0, }, 1, |
|
356 0, &LSODE_options::set_initial_step_size, 0, 0, |
|
357 0, &LSODE_options::initial_step_size, 0, 0, }, |
|
358 |
|
359 { "integration method", |
|
360 { "integration", "method", 0, 0, }, |
|
361 { 3, 0, 0, 0, }, 1, |
|
362 0, 0, 0, &LSODE_options::set_integration_method, |
|
363 0, 0, 0, &LSODE_options::integration_method, }, |
2928
|
364 |
|
365 { "maximum step size", |
|
366 { "maximum", "step", "size", 0, }, |
|
367 { 2, 0, 0, 0, }, 1, |
3955
|
368 0, &LSODE_options::set_maximum_step_size, 0, 0, |
|
369 0, &LSODE_options::maximum_step_size, 0, 0, }, |
2928
|
370 |
|
371 { "minimum step size", |
|
372 { "minimum", "step", "size", 0, }, |
|
373 { 2, 0, 0, 0, }, 1, |
3955
|
374 0, &LSODE_options::set_minimum_step_size, 0, 0, |
|
375 0, &LSODE_options::minimum_step_size, 0, 0, }, |
2928
|
376 |
|
377 { "relative tolerance", |
|
378 { "relative", "tolerance", 0, 0, }, |
|
379 { 1, 0, 0, 0, }, 1, |
3955
|
380 0, &LSODE_options::set_relative_tolerance, 0, 0, |
|
381 0, &LSODE_options::relative_tolerance, 0, 0, }, |
2928
|
382 |
|
383 { "step limit", |
|
384 { "step", "limit", 0, 0, }, |
|
385 { 1, 0, 0, 0, }, 1, |
3955
|
386 0, 0, &LSODE_options::set_step_limit, 0, |
|
387 0, 0, &LSODE_options::step_limit, 0, }, |
2928
|
388 |
|
389 { 0, |
|
390 { 0, 0, 0, 0, }, |
|
391 { 0, 0, 0, 0, }, 0, |
3955
|
392 0, 0, 0, 0, |
|
393 0, 0, 0, 0, }, |
2928
|
394 }; |
|
395 |
|
396 static void |
3523
|
397 print_lsode_option_list (std::ostream& os) |
2928
|
398 { |
|
399 print_usage ("lsode_options", 1); |
|
400 |
|
401 os << "\n" |
|
402 << "Options for lsode include:\n\n" |
|
403 << " keyword value\n" |
|
404 << " ------- -----\n\n"; |
|
405 |
|
406 LSODE_OPTIONS *list = lsode_option_table; |
|
407 |
|
408 const char *keyword; |
|
409 while ((keyword = list->keyword) != 0) |
|
410 { |
3568
|
411 os << " " |
|
412 << std::setiosflags (std::ios::left) << std::setw (40) |
|
413 << keyword |
|
414 << std::resetiosflags (std::ios::left) |
|
415 << " "; |
3567
|
416 |
3952
|
417 if (list->da_get_fcn) |
|
418 { |
|
419 Array<double> val = (lsode_opts.*list->da_get_fcn) (); |
|
420 if (val.length () == 1) |
|
421 { |
|
422 if (val(0) < 0.0) |
|
423 os << "computed automatically"; |
|
424 else |
|
425 os << val(0); |
|
426 } |
|
427 else |
|
428 { |
|
429 os << "\n\n"; |
|
430 // XXX FIXME XXX |
|
431 Matrix tmp = Matrix (ColumnVector (val)); |
|
432 octave_print_internal (os, tmp, false, 2); |
|
433 os << "\n"; |
|
434 } |
|
435 } |
|
436 else if (list->d_get_fcn) |
2928
|
437 { |
|
438 double val = (lsode_opts.*list->d_get_fcn) (); |
|
439 if (val < 0.0) |
|
440 os << "computed automatically"; |
|
441 else |
|
442 os << val; |
|
443 } |
3955
|
444 else if (list->i_get_fcn) |
2928
|
445 { |
|
446 int val = (lsode_opts.*list->i_get_fcn) (); |
|
447 if (val < 0) |
|
448 os << "infinite"; |
|
449 else |
|
450 os << val; |
|
451 } |
3955
|
452 else if (list->s_get_fcn) |
|
453 { |
|
454 os << (lsode_opts.*list->s_get_fcn) (); |
|
455 } |
|
456 else |
|
457 panic_impossible (); |
|
458 |
2928
|
459 os << "\n"; |
|
460 list++; |
|
461 } |
|
462 |
|
463 os << "\n"; |
|
464 } |
|
465 |
|
466 static void |
3523
|
467 set_lsode_option (const std::string& keyword, double val) |
2928
|
468 { |
|
469 LSODE_OPTIONS *list = lsode_option_table; |
|
470 |
|
471 while (list->keyword != 0) |
|
472 { |
|
473 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
474 list->min_toks_to_match, MAX_TOKENS)) |
|
475 { |
3957
|
476 if (list->da_set_fcn) |
|
477 { |
|
478 Array<double> tmp (1, val); |
|
479 (lsode_opts.*list->da_set_fcn) (tmp); |
|
480 } |
|
481 else if (list->d_set_fcn) |
|
482 { |
|
483 (lsode_opts.*list->d_set_fcn) (val); |
|
484 } |
2928
|
485 else |
|
486 { |
|
487 if (xisnan (val)) |
|
488 { |
|
489 error ("lsode_options: %s: expecting integer, found NaN", |
|
490 keyword.c_str ()); |
|
491 } |
|
492 else |
|
493 (lsode_opts.*list->i_set_fcn) (NINT (val)); |
|
494 } |
|
495 return; |
|
496 } |
|
497 list++; |
|
498 } |
|
499 |
|
500 warning ("lsode_options: no match for `%s'", keyword.c_str ()); |
|
501 } |
|
502 |
3952
|
503 static void |
|
504 set_lsode_option (const std::string& keyword, const Array<double>& val) |
|
505 { |
|
506 LSODE_OPTIONS *list = lsode_option_table; |
|
507 |
|
508 while (list->keyword != 0) |
|
509 { |
|
510 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
511 list->min_toks_to_match, MAX_TOKENS)) |
|
512 { |
|
513 if (list->da_set_fcn) |
|
514 (lsode_opts.*list->da_set_fcn) (val); |
|
515 else |
|
516 error ("lsode_options: no function to handle vector option"); |
|
517 |
|
518 return; |
|
519 } |
|
520 list++; |
|
521 } |
|
522 |
|
523 warning ("lsode_options: no match for `%s'", keyword.c_str ()); |
|
524 } |
|
525 |
3955
|
526 static void |
|
527 set_lsode_option (const std::string& keyword, const std::string& val) |
|
528 { |
|
529 LSODE_OPTIONS *list = lsode_option_table; |
|
530 |
|
531 while (list->keyword != 0) |
|
532 { |
|
533 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
534 list->min_toks_to_match, MAX_TOKENS)) |
|
535 { |
|
536 if (list->s_set_fcn) |
|
537 (lsode_opts.*list->s_set_fcn) (val); |
|
538 else |
|
539 error ("lsode_options: no function to handle string option"); |
|
540 |
|
541 return; |
|
542 } |
|
543 list++; |
|
544 } |
|
545 |
|
546 warning ("lsode_options: no match for `%s'", keyword.c_str ()); |
|
547 } |
|
548 |
2928
|
549 static octave_value_list |
3523
|
550 show_lsode_option (const std::string& keyword) |
2928
|
551 { |
|
552 octave_value retval; |
|
553 |
|
554 LSODE_OPTIONS *list = lsode_option_table; |
|
555 |
|
556 while (list->keyword != 0) |
|
557 { |
|
558 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
559 list->min_toks_to_match, MAX_TOKENS)) |
|
560 { |
3952
|
561 if (list->da_get_fcn) |
|
562 { |
|
563 Array<double> val = (lsode_opts.*list->da_get_fcn) (); |
|
564 if (val.length () == 1) |
|
565 { |
|
566 if (val(0) < 0.0) |
|
567 retval = "computed automatically"; |
|
568 else |
|
569 retval = val(0); |
|
570 } |
|
571 else |
|
572 retval = ColumnVector (val); |
|
573 } |
|
574 else if (list->d_get_fcn) |
2928
|
575 { |
|
576 double val = (lsode_opts.*list->d_get_fcn) (); |
|
577 if (val < 0.0) |
|
578 retval = "computed automatically"; |
|
579 else |
|
580 retval = val; |
|
581 } |
3955
|
582 else if (list->i_get_fcn) |
2928
|
583 { |
|
584 int val = (lsode_opts.*list->i_get_fcn) (); |
|
585 if (val < 0) |
|
586 retval = "infinite"; |
|
587 else |
|
588 retval = static_cast<double> (val); |
|
589 } |
3955
|
590 else if (list->s_get_fcn) |
|
591 { |
|
592 retval = (lsode_opts.*list->s_get_fcn) (); |
|
593 } |
|
594 else |
|
595 panic_impossible (); |
2928
|
596 |
|
597 return retval; |
|
598 } |
|
599 list++; |
|
600 } |
|
601 |
|
602 warning ("lsode_options: no match for `%s'", keyword.c_str ()); |
|
603 |
|
604 return retval; |
|
605 } |
|
606 |
|
607 DEFUN_DLD (lsode_options, args, , |
3373
|
608 "-*- texinfo -*-\n\ |
|
609 @deftypefn {Loadable Function} {} lsode_options (@var{opt}, @var{val})\n\ |
|
610 When called with two arguments, this function allows you set options\n\ |
|
611 parameters for the function @code{lsode}. Given one argument,\n\ |
|
612 @code{lsode_options} returns the value of the corresponding option. If\n\ |
|
613 no arguments are supplied, the names of all the available options and\n\ |
|
614 their current values are displayed.\n\ |
|
615 @end deftypefn") |
2928
|
616 { |
|
617 octave_value_list retval; |
|
618 |
|
619 int nargin = args.length (); |
|
620 |
|
621 if (nargin == 0) |
|
622 { |
|
623 print_lsode_option_list (octave_stdout); |
|
624 } |
|
625 else if (nargin == 1 || nargin == 2) |
|
626 { |
3523
|
627 std::string keyword = args(0).string_value (); |
2928
|
628 |
|
629 if (! error_state) |
|
630 { |
|
631 if (nargin == 1) |
3952
|
632 retval = show_lsode_option (keyword); |
2928
|
633 else |
|
634 { |
3955
|
635 if (args(1).is_string ()) |
|
636 { |
|
637 std::string val = args(1).string_value (); |
|
638 |
|
639 if (! error_state) |
|
640 set_lsode_option (keyword, val); |
|
641 } |
|
642 else if (args(1).is_scalar_type ()) |
3952
|
643 { |
|
644 double val = args(1).double_value (); |
2928
|
645 |
3952
|
646 if (! error_state) |
|
647 set_lsode_option (keyword, val); |
|
648 } |
|
649 else |
2928
|
650 { |
3952
|
651 Array<double> val = args(1).vector_value (); |
|
652 |
|
653 if (! error_state) |
|
654 set_lsode_option (keyword, val); |
2928
|
655 } |
|
656 } |
|
657 } |
|
658 } |
3952
|
659 else |
|
660 print_usage ("lsode_options"); |
2928
|
661 |
|
662 return retval; |
|
663 } |
|
664 |
|
665 /* |
|
666 ;;; Local Variables: *** |
|
667 ;;; mode: C++ *** |
|
668 ;;; End: *** |
|
669 */ |