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