Mercurial > hg > what-is-octave
comparison OctConf2013/examples/dld.cc @ 8:50abddcc3409 default tip
Presentation delivered by cdf at OctConf 2013.
author | Carlo de Falco <cdf@users.sourceforge.net> |
---|---|
date | Mon, 22 Jul 2013 21:54:27 +0200 |
parents | FEMTEC2013/examples/dld.cc@60233b0075a9 |
children |
comparison
equal
deleted
inserted
replaced
7:229882e81c78 | 8:50abddcc3409 |
---|---|
1 #include <octave/oct.h> | |
2 | |
3 DEFUN_DLD(dld,args,nargout,"dld (array) \nreturn the elements of the array in reverse order\n") | |
4 { | |
5 octave_value_list retval; | |
6 int nargin = args.length (); | |
7 | |
8 if (nargin != 1) | |
9 print_usage (); | |
10 else | |
11 { | |
12 Array<double> a = args(0).array_value (); | |
13 if (! error_state) | |
14 { | |
15 Array<double> b (a); | |
16 double* ap = a.fortran_vec (); | |
17 double* bp = b.fortran_vec (); | |
18 for (octave_idx_type i = a.numel () - 1, j = 0; i >= 0; i--, j++) | |
19 bp[i] = ap[j]; | |
20 retval = octave_value (b); | |
21 } | |
22 } | |
23 return retval; | |
24 } |