diff PoliMI2012/examples/dld.cc @ 4:0a1567794b40

[mq]: folder_reorganization
author Carlo de Falco <cdf@users.sourceforge.net>
date Thu, 08 Nov 2012 09:55:34 +0100
parents
children
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/PoliMI2012/examples/dld.cc
@@ -0,0 +1,24 @@
+#include <octave/oct.h>
+
+DEFUN_DLD(dld,args,nargout,"dld (array) \nreturn the elements of the array in reverse order\n")
+{
+  octave_value_list retval;
+  int nargin = args.length ();
+
+  if (nargin != 1)
+    print_usage ();
+  else
+    {
+      Array<double> a = args(0).array_value ();
+      if (! error_state)
+        {
+          Array<double> b (a);
+          double* ap = a.fortran_vec ();
+          double* bp = b.fortran_vec ();
+          for (octave_idx_type i = a.numel () - 1, j = 0; i >= 0; i--, j++)
+            bp[i] = ap[j];
+          retval = octave_value (b);
+        }
+    }
+  return retval;
+}