Mercurial > octave-nkf
annotate examples/code/funcdemo.cc @ 20596:87b557ee8e5d
clean up and vectorize code for dense output in ode45
* scripts/ode/private/ode_rk_interpolate.m: new file
* scripts/ode/private/ode_rk_interpolate.m(hermite_quartic_interpolation):
move to internal function, use vectorization and broadcasting.
* scripts/ode/private/hermite_quartic_interpolation.m: remove file
* scripts/ode/module.mk: list added and removed files
* scripts/ode/private/integrate_adaptive.m: use new interpolation code.
author | Carlo de Falco <carlo.defalco@polimi.it> |
---|---|
date | Tue, 06 Oct 2015 19:28:59 +0200 |
parents | 2f8500ca91d3 |
children |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/parse.h> | |
3 | |
4 DEFUN_DLD (funcdemo, args, nargout, "Function Demo") | |
5 { | |
16867
be41c30bcb44
Re-write documentation and all examples of dynamically linked functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
6 octave_value_list retval; |
20578
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
7 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
9932
diff
changeset
|
8 int nargin = args.length (); |
6572 | 9 |
10 if (nargin < 2) | |
11 print_usage (); | |
20578
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
12 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
13 octave_value_list newargs; |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
14 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
15 for (octave_idx_type i = nargin - 1; i > 0; i--) |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
16 newargs(i-1) = args(i); |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
17 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
18 if (args(0).is_function_handle () || args(0).is_inline_function ()) |
6572 | 19 { |
20578
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
20 octave_function *fcn = args(0).function_value (); |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
21 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
22 retval = feval (fcn, newargs, nargout); |
6572 | 23 } |
20578
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
24 else if (args(0).is_string ()) |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
25 { |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
26 std::string fcn = args(0).string_value (); |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
27 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
28 retval = feval (fcn, newargs, nargout); |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
29 } |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
30 else |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
31 error ("funcdemo: INPUT must be string, inline, or function handle"); |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19067
diff
changeset
|
32 |
6572 | 33 return retval; |
34 } |