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