[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem creating compiled oct file
From: |
babelproofreader |
Subject: |
Re: Problem creating compiled oct file |
Date: |
Sun, 4 Oct 2009 08:22:15 -0700 (PDT) |
I have written a function that by necessity uses a loop for recursive
calculations and also has loops within the main loop and as a result it is
very slow. Despite much investigation I have not been able to find out how
to vectorise this function and so have decided to compile an oct file as I
believe the loop structures can be easily written in c++. However I am
having problems just passing arguments to the function and retrieving the
output value. My code so far, in a file called "loop.cc", is....
My immediate problem is now solved and I post the code below in the hope
that it will help others who may search this forum.
#include <octave/oct.h>
#include <octave/dColVector.h>
DEFUN_DLD (basicloop, args, , "Help String")
{
octave_value retval;
ColumnVector c = args(0).column_vector_value (); // This is the input
argument, in column vector form
ColumnVector d(c); //
This will be the output column vector returned to Octave by "retval"
int ii;
// Declare the loop counter ii as integer type
for (ii = octave_idx_type (0); ii<c.length (); ii++) // Start the
loop
{
d(c.length () - ii - 1) = c(ii) + 0.5; // Do
something in the loop calculation
}
retval = d; //
Assign the output column vector to the return value
return retval; //
Return the output to Octave
}
--
View this message in context:
http://www.nabble.com/Problem-creating-compiled-oct-file-tp25727690p25738985.html
Sent from the Octave - General mailing list archive at Nabble.com.