3990
|
1 /* |
|
2 |
|
3 Copyright (C) 2002 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 |
|
29 #include <iostream.h> |
|
30 |
|
31 #include "DASRT.h" |
|
32 #include "lo-mappers.h" |
|
33 |
|
34 #include "defun-dld.h" |
|
35 #include "error.h" |
|
36 #include "gripes.h" |
|
37 #include "oct-obj.h" |
|
38 #include "ov-fcn.h" |
|
39 #include "pager.h" |
|
40 #include "parse.h" |
|
41 #include "unwind-prot.h" |
|
42 #include "utils.h" |
|
43 #include "variables.h" |
|
44 |
|
45 // Global pointers for user defined function required by dassl. |
|
46 static octave_function *dasrt_f; |
|
47 static octave_function *dasrt_j; |
|
48 static octave_function *dasrt_cf; |
|
49 |
|
50 static DASRT_options dasrt_opts; |
|
51 |
|
52 // Is this a recursive call? |
|
53 static int call_depth = 0; |
|
54 |
|
55 static ColumnVector |
|
56 dasrt_user_f (const ColumnVector& x, const ColumnVector& xprime, |
|
57 double t, int& ires) |
|
58 { |
|
59 ColumnVector retval; |
|
60 |
|
61 octave_value_list args; |
|
62 |
|
63 int n = x.length (); |
|
64 |
|
65 if (n > 1) |
|
66 { |
|
67 args(0) = x; |
|
68 args(1) = xprime; |
|
69 } |
|
70 else if (n == 1) |
|
71 { |
|
72 args(0) = x(0); |
|
73 args(1) = xprime(0); |
|
74 } |
|
75 else |
|
76 { |
|
77 args(0) = Matrix (); |
|
78 args(1) = Matrix (); |
|
79 } |
|
80 |
|
81 args(2) = t; |
|
82 |
|
83 if (dasrt_f) |
|
84 { |
|
85 octave_value_list tmp = dasrt_f->do_multi_index_op (1, args); |
|
86 |
|
87 if (error_state) |
|
88 { |
|
89 gripe_user_supplied_eval ("dasrt"); |
|
90 return retval; |
|
91 } |
|
92 |
|
93 if (tmp.length () > 0 && tmp(0).is_defined ()) |
|
94 { |
|
95 retval = ColumnVector (tmp(0).vector_value ()); |
|
96 |
|
97 if (error_state || retval.length () == 0) |
|
98 gripe_user_supplied_eval ("dasrt"); |
|
99 } |
|
100 else |
|
101 gripe_user_supplied_eval ("dasrt"); |
|
102 } |
|
103 |
|
104 return retval; |
|
105 } |
|
106 |
|
107 static ColumnVector |
|
108 dasrt_user_cf (const ColumnVector& x, double t) |
|
109 { |
|
110 ColumnVector retval; |
|
111 |
|
112 octave_value_list args; |
|
113 |
|
114 int n = x.length (); |
|
115 |
|
116 if (n > 1) |
|
117 args(0) = x; |
|
118 else if (n == 1) |
|
119 args(0) = x(0); |
|
120 else |
|
121 args(0) = Matrix (); |
|
122 |
|
123 args(1) = t; |
|
124 |
|
125 if (dasrt_cf) |
|
126 { |
|
127 octave_value_list tmp = dasrt_cf->do_multi_index_op (1, args); |
|
128 |
|
129 if (error_state) |
|
130 { |
|
131 gripe_user_supplied_eval ("dasrt"); |
|
132 return retval; |
|
133 } |
|
134 |
|
135 if (tmp.length () > 0 && tmp(0).is_defined ()) |
|
136 { |
|
137 retval = ColumnVector (tmp(0).vector_value ()); |
|
138 |
|
139 if (error_state || retval.length () == 0) |
|
140 gripe_user_supplied_eval ("dasrt"); |
|
141 } |
|
142 else |
|
143 gripe_user_supplied_eval ("dasrt"); |
|
144 } |
|
145 |
|
146 return retval; |
|
147 } |
|
148 |
|
149 static ColumnVector |
|
150 dasrt_dumb_cf (const ColumnVector& x, double t) |
|
151 { |
|
152 ColumnVector retval (1, 1.0); |
|
153 return retval; |
|
154 } |
|
155 |
|
156 #if 0 |
|
157 static Matrix |
|
158 dasrt_user_mf (double t, const ColumnVector& x, const ColumnVector& xprime, |
|
159 const double& cj, octave_function *mf) |
|
160 { |
|
161 Matrix retval; |
|
162 |
|
163 if (mf) |
|
164 { |
|
165 octave_value_list args; |
|
166 |
|
167 int n = x.length (); |
|
168 |
|
169 if (n > 1) |
|
170 { |
|
171 args(0) = x; |
|
172 args(1) = xprime; |
|
173 args(3) = cj; |
|
174 } |
|
175 else if (n == 1) |
|
176 { |
|
177 args(0) = x(0); |
|
178 args(1) = xprime(0); |
|
179 args(3) = cj; |
|
180 } |
|
181 else |
|
182 { |
|
183 args(0) = Matrix (); |
|
184 args(1) = Matrix (); |
|
185 args(3) = Matrix (); |
|
186 } |
|
187 |
|
188 args(2) = t; |
|
189 |
|
190 octave_value_list tmp = mf->do_multi_index_op (1, args); |
|
191 |
|
192 if (error_state) |
|
193 { |
|
194 gripe_user_supplied_eval ("dasrt"); |
|
195 return retval; |
|
196 } |
|
197 |
|
198 if (tmp.length () > 0 && tmp(0).is_defined ()) |
|
199 { |
|
200 retval = tmp(0).matrix_value (); |
|
201 |
|
202 if (error_state || retval.length () == 0) |
|
203 gripe_user_supplied_eval ("dasrt"); |
|
204 } |
|
205 else |
|
206 gripe_user_supplied_eval ("dasrt"); |
|
207 } |
|
208 |
|
209 return retval; |
|
210 } |
|
211 |
|
212 static Matrix |
|
213 dasrt_user_j (const ColumnVector& x, const ColumnVector& xprime, double t) |
|
214 { |
|
215 return dasrt_user_mf (t, x, xprime, dasrt_j); |
|
216 } |
|
217 #endif |
|
218 |
|
219 #define DASRT_ABORT \ |
|
220 do \ |
|
221 { \ |
|
222 unwind_protect::run_frame ("Fdasrt"); \ |
|
223 return retval; \ |
|
224 } \ |
|
225 while (0) |
|
226 |
|
227 #define DASRT_ABORT1(msg) \ |
|
228 do \ |
|
229 { \ |
|
230 ::error ("dasrt: " ## msg); \ |
|
231 DASRT_ABORT; \ |
|
232 } \ |
|
233 while (0) |
|
234 |
|
235 #define DASRT_ABORT2(fmt, arg) \ |
|
236 do \ |
|
237 { \ |
|
238 ::error ("dasrt: " ## fmt, arg); \ |
|
239 DASRT_ABORT; \ |
|
240 } \ |
|
241 while (0) |
|
242 |
|
243 DEFUN_DLD (dasrt, args, , |
|
244 "-*- texinfo -*-\n\ |
|
245 @deftypefn {Loadable Function} {[@var{x}, @var{xdot}, @var{t}] =} dasrt (@var{fj} [, @var{g}], @var{x_0}, @var{xdot_0}, @var{t_out} [, @var{t_crit}])\n\ |
|
246 Solve a system of differential/algebraic equations with functional\n\ |
|
247 stopping criteria.\n\ |
|
248 \n\ |
|
249 The function to be integrated must be of the form:\n\ |
|
250 @example\n\ |
|
251 @var{res} = f (@var{x}, @var{xdot}, @var{t}) = 0\n\ |
|
252 @end example\n\ |
|
253 \n\ |
|
254 The stopping condition must be of the form:\n\ |
|
255 \n\ |
|
256 @example\n\ |
|
257 @var{res} = g (@var{x}, @var{t}) = 0\n\ |
|
258 @end example\n\ |
|
259 \n\ |
|
260 The Jacobian (if included) must be of the form:\n\ |
|
261 \n\ |
|
262 @example\n\ |
|
263 @var{jac} = j (@var{x}, @var{xdot}, @var{t}, @var{cj})\n\ |
|
264 = df/dx + cj*df/dxdot\n\ |
|
265 @end example\n\ |
|
266 \n\ |
|
267 @noindent\n\ |
|
268 The following inputs are entered:\n\ |
|
269 \n\ |
|
270 @table @var\n\ |
|
271 @item fj\n\ |
|
272 The string vector containing either @var{f} or both @var{f} and @var{j}.\n\ |
|
273 \n\ |
|
274 @item f\n\ |
|
275 The function to be integrated.\n\ |
|
276 \n\ |
|
277 @item g\n\ |
|
278 The function with the stopping conditions.\n\ |
|
279 \n\ |
|
280 @item j\n\ |
|
281 The optional Jacobian function. If not included, it will be approximated\n\ |
|
282 by finite differences.\n\ |
|
283 \n\ |
|
284 @item x_0\n\ |
|
285 The initial state.\n\ |
|
286 \n\ |
|
287 @item xdot_0\n\ |
|
288 The time derivative of the initial state.\n\ |
|
289 \n\ |
|
290 @item t_out\n\ |
|
291 The times at which the solution should be returned. This vector should\n\ |
|
292 include the initial time a the first value.\n\ |
|
293 \n\ |
|
294 @item t_crit\n\ |
|
295 The times at which the function is non-smooth or poorly behaved.\n\ |
|
296 \n\ |
|
297 @end table\n\ |
|
298 \n\ |
|
299 @noindent\n\ |
|
300 The following outputs are returned:\n\ |
|
301 \n\ |
|
302 @table @var\n\ |
|
303 @item x\n\ |
|
304 The states at each time in @var{t}.\n\ |
|
305 \n\ |
|
306 @item xdot\n\ |
|
307 The time derivative of the states at each time in @var{t}.\n\ |
|
308 \n\ |
|
309 @item t\n\ |
|
310 All the times in the requested output time vector up to the stopping\n\ |
|
311 criteria. The time at which the stopping criteria is achieved is returned\n\ |
|
312 as the last time in the vector.\n\ |
|
313 @end table\n\ |
|
314 \n\ |
|
315 You can use the function @code{dasrt_options} to set optional\n\ |
|
316 parameters for @code{dasrt}.\n\ |
|
317 @end deftypefn") |
|
318 { |
|
319 octave_value_list retval; |
|
320 |
|
321 unwind_protect::begin_frame ("Fdasrt"); |
|
322 |
|
323 unwind_protect_int (call_depth); |
|
324 call_depth++; |
|
325 |
|
326 if (call_depth > 1) |
|
327 DASRT_ABORT1 ("invalid recursive call"); |
|
328 |
|
329 int argp = 0; |
|
330 |
|
331 int nargin = args.length (); |
|
332 |
|
333 if (nargin < 4 || nargin > 6) |
|
334 { |
|
335 print_usage ("dasrt"); |
|
336 unwind_protect::run_frame ("Fdasrt"); |
|
337 return retval; |
|
338 } |
|
339 |
|
340 dasrt_f = 0; |
|
341 dasrt_j = 0; |
|
342 dasrt_cf = 0; |
|
343 |
|
344 // Check all the arguments. Are they the right animals? |
|
345 |
|
346 // Here's where I take care of f and j in one shot: |
|
347 |
|
348 octave_value f_arg = args(0); |
|
349 |
|
350 switch (f_arg.rows ()) |
|
351 { |
|
352 case 1: |
|
353 dasrt_f = extract_function |
|
354 (args(0), "dasrt", "__dasrt_fcn__", |
|
355 "function res = __dasrt_fcn__ (x, xdot, t) res = ", |
|
356 "; endfunction"); |
|
357 break; |
|
358 |
|
359 case 2: |
|
360 { |
|
361 string_vector tmp = args(0).all_strings (); |
|
362 |
|
363 if (! error_state) |
|
364 { |
|
365 dasrt_f = extract_function |
|
366 (tmp(0), "dasrt", "__dasrt_fcn__", |
|
367 "function res = __dasrt_fcn__ (x, xdot, t) res = ", |
|
368 "; endfunction"); |
|
369 |
|
370 if (dasrt_f) |
|
371 { |
|
372 dasrt_j = extract_function |
|
373 (tmp(1), "dasrt", "__dasrt_jac__", |
|
374 "function jac = __dasrt_jac__ (x, xdot, t, cj) jac = ", |
|
375 "; endfunction"); |
|
376 |
|
377 if (! dasrt_j) |
|
378 dasrt_f = 0; |
|
379 } |
|
380 } |
|
381 } |
|
382 break; |
|
383 |
|
384 default: |
|
385 DASRT_ABORT1 |
|
386 ("first arg should be a string or 2-element string array"); |
|
387 } |
|
388 |
|
389 if (error_state || (! dasrt_f)) |
|
390 DASRT_ABORT; |
|
391 |
|
392 DAERTFunc func (dasrt_user_f); |
|
393 |
|
394 argp++; |
|
395 |
|
396 if (args(1).is_string ()) |
|
397 { |
|
398 dasrt_cf = is_valid_function (args(1), "dasrt", true); |
|
399 |
|
400 if (! dasrt_cf) |
3992
|
401 DASRT_ABORT1 ("expecting function name as argument 2"); |
3990
|
402 |
|
403 argp++; |
|
404 |
|
405 func.set_constraint_function (dasrt_user_cf); |
|
406 } |
|
407 |
|
408 ColumnVector state (args(argp++).vector_value ()); |
|
409 |
|
410 if (error_state) |
|
411 DASRT_ABORT2 ("expecting state vector as argument %d", argp); |
|
412 |
3992
|
413 ColumnVector stateprime (args(argp++).vector_value ()); |
3990
|
414 |
|
415 if (error_state) |
|
416 DASRT_ABORT2 |
|
417 ("expecting time derivative of state vector as argument %d", argp); |
|
418 |
|
419 ColumnVector old_out_times (args(argp++).vector_value ()); |
|
420 |
|
421 if (error_state) |
|
422 DASRT_ABORT2 |
|
423 ("expecting output time vector as %s argument %d", argp); |
|
424 |
|
425 double tzero = old_out_times (0); |
|
426 |
|
427 int ol = old_out_times.length (); |
|
428 |
|
429 ColumnVector out_times (ol-1, 0.0); |
|
430 |
3992
|
431 for (int i = 1; i < ol; i++) |
|
432 out_times(i-1) = old_out_times(i); |
3990
|
433 |
|
434 ColumnVector crit_times; |
|
435 |
|
436 bool crit_times_set = false; |
|
437 |
|
438 if (argp < nargin) |
|
439 { |
|
440 crit_times = ColumnVector (args(argp++).vector_value ()); |
|
441 |
|
442 if (error_state) |
|
443 DASRT_ABORT2 |
|
444 ("expecting critical time vector as argument %d", argp); |
|
445 |
|
446 crit_times_set = true; |
|
447 } |
|
448 |
|
449 #if 0 |
|
450 if (dasrt_j) |
|
451 func.set_jacobian_function (dasrt_user_j); |
|
452 #endif |
|
453 |
|
454 DASRT_result output; |
|
455 |
3992
|
456 DASRT dae = DASRT (state, stateprime, tzero, func); |
3990
|
457 |
|
458 dae.copy (dasrt_opts); |
|
459 |
|
460 if (error_state) |
|
461 DASRT_ABORT1 ("something is wrong"); |
|
462 |
|
463 if (crit_times_set) |
|
464 output = dae.integrate (out_times, crit_times); |
|
465 else |
|
466 output = dae.integrate (out_times); |
|
467 |
|
468 if (! error_state) |
|
469 { |
|
470 ColumnVector old_output_times = output.times (); |
|
471 |
|
472 Matrix old_output_deriv = output.deriv (); |
|
473 Matrix old_output_state = output.state (); |
|
474 |
|
475 int lstuff = old_output_times.length (); |
3992
|
476 int lstate = state.length (); |
3990
|
477 |
|
478 ColumnVector output_times (lstuff+1, 0.0); |
|
479 |
|
480 Matrix output_deriv (lstuff+1, lstate, 0.0); |
|
481 Matrix output_state (lstuff+1, lstate, 0.0); |
|
482 |
|
483 output_times(0) = tzero; |
|
484 |
3992
|
485 for (int i = 0; i < lstate; i++) |
3990
|
486 { |
3992
|
487 output_deriv(0,i) = stateprime(i); |
|
488 output_state(0,i) = state(i); |
3990
|
489 } |
|
490 |
3992
|
491 for (int i = 0; i < lstuff; i++) |
3990
|
492 { |
3992
|
493 output_times(i+1) = old_output_times(i); |
3990
|
494 |
3992
|
495 for (int j = 0; j < lstate; j++) |
3990
|
496 { |
3992
|
497 output_deriv(i+1,j) = old_output_deriv(i,j); |
|
498 output_state(i+1,j) = old_output_state(i,j); |
3990
|
499 } |
|
500 } |
|
501 |
|
502 retval(2) = output_times; |
|
503 retval(1) = output_deriv; |
|
504 retval(0) = output_state; |
|
505 } |
|
506 else |
|
507 { |
|
508 DASRT_ABORT1("something wicked has occurred!"); |
|
509 // print_usage ("dasrt"); |
|
510 } |
|
511 |
|
512 unwind_protect::run_frame ("Fdasrt"); |
|
513 |
|
514 return retval; |
|
515 } |
|
516 |
|
517 typedef void (DASRT_options::*d_set_opt_mf) (double); |
|
518 typedef void (DASRT_options::*i_set_opt_mf) (int); |
|
519 typedef double (DASRT_options::*d_get_opt_mf) (void); |
|
520 typedef int (DASRT_options::*i_get_opt_mf) (void); |
|
521 |
|
522 #define MAX_TOKENS 3 |
|
523 |
|
524 struct DASRT_OPTIONS |
|
525 { |
|
526 const char *keyword; |
|
527 const char *kw_tok[MAX_TOKENS + 1]; |
|
528 int min_len[MAX_TOKENS + 1]; |
|
529 int min_toks_to_match; |
|
530 d_set_opt_mf d_set_fcn; |
|
531 i_set_opt_mf i_set_fcn; |
|
532 d_get_opt_mf d_get_fcn; |
|
533 i_get_opt_mf i_get_fcn; |
|
534 }; |
|
535 |
|
536 static DASRT_OPTIONS dasrt_option_table [] = |
|
537 { |
|
538 { "absolute tolerance", |
|
539 { "absolute", "tolerance", 0, 0, }, |
|
540 { 1, 0, 0, 0, }, 1, |
|
541 &DASRT_options::set_absolute_tolerance, 0, |
|
542 &DASRT_options::absolute_tolerance, 0, }, |
|
543 |
|
544 { "initial step size", |
|
545 { "initial", "step", "size", 0, }, |
|
546 { 1, 0, 0, 0, }, 1, |
|
547 &DASRT_options::set_initial_step_size, 0, |
|
548 &DASRT_options::initial_step_size, 0, }, |
|
549 |
|
550 { "maximum step size", |
|
551 { "maximum", "step", "size", 0, }, |
|
552 { 2, 0, 0, 0, }, 1, |
|
553 &DASRT_options::set_maximum_step_size, 0, |
|
554 &DASRT_options::maximum_step_size, 0, }, |
|
555 |
|
556 { "minimum step size", |
|
557 { "minimum", "step", "size", 0, }, |
|
558 { 2, 0, 0, 0, }, 1, |
|
559 &DASRT_options::set_minimum_step_size, 0, |
|
560 &DASRT_options::minimum_step_size, 0, }, |
|
561 |
|
562 { "relative tolerance", |
|
563 { "relative", "tolerance", 0, 0, }, |
|
564 { 1, 0, 0, 0, }, 1, |
|
565 &DASRT_options::set_relative_tolerance, 0, |
|
566 &DASRT_options::relative_tolerance, 0, }, |
|
567 |
|
568 { "step limit", |
|
569 { "step", "limit", 0, 0, }, |
|
570 { 1, 0, 0, 0, }, 1, |
|
571 0, &DASRT_options::set_step_limit, |
|
572 0, &DASRT_options::step_limit, }, |
|
573 |
|
574 { 0, |
|
575 { 0, 0, 0, 0, }, |
|
576 { 0, 0, 0, 0, }, 0, |
|
577 0, 0, 0, 0, }, |
|
578 }; |
|
579 |
|
580 static void |
|
581 print_dasrt_option_list (ostream& os) |
|
582 { |
|
583 print_usage ("dasrt_options", 1); |
|
584 |
|
585 os << "\n" |
|
586 << "Options for dasrt include:\n\n" |
|
587 << " keyword value\n" |
|
588 << " ------- -----\n\n"; |
|
589 |
|
590 DASRT_OPTIONS *list = dasrt_option_table; |
|
591 |
|
592 const char *keyword; |
|
593 while ((keyword = list->keyword) != 0) |
|
594 { |
|
595 os.form (" %-40s ", keyword); |
|
596 |
|
597 if (list->d_get_fcn) |
|
598 { |
|
599 double val = (dasrt_opts.*list->d_get_fcn) (); |
|
600 if (val < 0.0) |
|
601 os << "computed automatically"; |
|
602 else |
|
603 os << val; |
|
604 } |
|
605 else |
|
606 { |
|
607 int val = (dasrt_opts.*list->i_get_fcn) (); |
|
608 if (val < 0) |
|
609 os << "computed automatically"; |
|
610 else |
|
611 os << val; |
|
612 } |
|
613 os << "\n"; |
|
614 list++; |
|
615 } |
|
616 |
|
617 os << "\n"; |
|
618 } |
|
619 |
|
620 static void |
|
621 set_dasrt_option (const string& keyword, double val) |
|
622 { |
|
623 DASRT_OPTIONS *list = dasrt_option_table; |
|
624 |
|
625 while (list->keyword != 0) |
|
626 { |
|
627 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
628 list->min_toks_to_match, MAX_TOKENS)) |
|
629 { |
|
630 if (list->d_set_fcn) |
|
631 (dasrt_opts.*list->d_set_fcn) (val); |
|
632 else |
|
633 { |
|
634 if (xisnan (val)) |
|
635 { |
|
636 error ("dasrt_options: %s: expecting integer, found NaN", |
|
637 keyword.c_str ()); |
|
638 } |
|
639 else |
|
640 (dasrt_opts.*list->i_set_fcn) (NINT (val)); |
|
641 } |
|
642 return; |
|
643 } |
|
644 list++; |
|
645 } |
|
646 |
|
647 warning ("dasrt_options: no match for `%s'", keyword.c_str ()); |
|
648 } |
|
649 |
|
650 static octave_value_list |
|
651 show_dasrt_option (const string& keyword) |
|
652 { |
|
653 octave_value retval; |
|
654 |
|
655 DASRT_OPTIONS *list = dasrt_option_table; |
|
656 |
|
657 while (list->keyword != 0) |
|
658 { |
|
659 if (keyword_almost_match (list->kw_tok, list->min_len, keyword, |
|
660 list->min_toks_to_match, MAX_TOKENS)) |
|
661 { |
|
662 if (list->d_get_fcn) |
|
663 { |
|
664 double val = (dasrt_opts.*list->d_get_fcn) (); |
|
665 if (val < 0.0) |
|
666 retval = "computed automatically"; |
|
667 else |
|
668 retval = val; |
|
669 } |
|
670 else |
|
671 { |
|
672 int val = (dasrt_opts.*list->i_get_fcn) (); |
|
673 if (val < 0) |
|
674 retval = "computed automatically"; |
|
675 else |
|
676 retval = static_cast<double> (val); |
|
677 } |
|
678 |
|
679 return retval; |
|
680 } |
|
681 list++; |
|
682 } |
|
683 |
|
684 warning ("dasrt_options: no match for `%s'", keyword.c_str ()); |
|
685 |
|
686 return retval; |
|
687 } |
|
688 |
|
689 DEFUN_DLD (dasrt_options, args, , |
|
690 "dasrt_options (KEYWORD, VALUE)\n\ |
|
691 \n\ |
|
692 Set or show options for dasrt. Keywords may be abbreviated\n\ |
|
693 to the shortest match.") |
|
694 { |
|
695 octave_value_list retval; |
|
696 |
|
697 int nargin = args.length (); |
|
698 |
|
699 if (nargin == 0) |
|
700 { |
|
701 print_dasrt_option_list (octave_stdout); |
|
702 return retval; |
|
703 } |
|
704 else if (nargin == 1 || nargin == 2) |
|
705 { |
|
706 string keyword = args(0).string_value (); |
|
707 |
|
708 if (! error_state) |
|
709 { |
|
710 if (nargin == 1) |
|
711 return show_dasrt_option (keyword); |
|
712 else |
|
713 { |
|
714 double val = args(1).double_value (); |
|
715 |
|
716 if (! error_state) |
|
717 { |
|
718 set_dasrt_option (keyword, val); |
|
719 return retval; |
|
720 } |
|
721 } |
|
722 } |
|
723 } |
|
724 |
|
725 print_usage ("dasrt_options"); |
|
726 |
|
727 return retval; |
|
728 } |
|
729 |
|
730 /* |
|
731 ;;; Local Variables: *** |
|
732 ;;; mode: C++ *** |
|
733 ;;; End: *** |
|
734 */ |