help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling other functions from .oct files


From: Peter Williams
Subject: Re: Calling other functions from .oct files
Date: Thu, 1 May 2003 03:15:59 -0400
User-agent: KMail/1.5.1

That did the trick.  I'm looking to speed up some monte carlos that 
I've got and the real bottleneck is updating the paths.  This should 
be enough to get me started.  Thanks for the help everybody.

Pete

On Thursday 01 May 2003 03:07, Geraint wrote:
> Peter Williams <address@hidden> writes:
> > Here's how I tried to get this working
> >
> > #include <octave/oct.h>
> > #include <string.h>
> >
> > using namespace std;
> > DEFUN_DLD (my_call_test, args, ,"Test a call")
> >
> > {
> >
> >   ColumnVector NumRands(2);
> >   NumRands(0) = 9000;
> >   NumRands(1) = 1;
> >   octave_value_list x, unis;
> >   x(0) = octave_value(NumRands);
> >   string ranfunc = "rand"
> >   unis = feval(ranfunc,x,1);
> >
> >   return octave_value (unis);
> >
> > }
> >
> > Here's the error message that I'm getting
> >
> > mkoctfile my_call_test.cpp
> > my_call_test.cpp: In function `octave_value_list
> > Fmy_call_test(const octave_value_list&, int)':
> > my_call_test.cpp:15: parse error before `=' token
> >
> > Do I need to include something else? I modified the snipet you
> > sent me to declare unis as an octave_value_list, and line 15 is
> > the one with the feval statement.
> >
> > Thanks,
> > Pete
>
> Pete,
>
> using octave-2.1.36, <octave/parse.h> must be included to use the
> function "feval". There is also a semi-colon missing at the end of
> the definition of ranfunc.
>
> The code compiles for me with these changes:
>
> *** my_call_test-old.cc       Thu May  1 07:47:57 2003
> --- my_call_test.cc   Thu May  1 07:50:43 2003
> ***************
> *** 1,5 ****
> --- 1,6 ----
>
>   #include <octave/oct.h>
> + #include <octave/parse.h>
>   #include <string.h>
>
>   using namespace std;
> ***************
> *** 12,18 ****
>     NumRands(1) = 1;
>     octave_value_list x, unis;
>     x(0) = octave_value(NumRands);
> !   string ranfunc = "rand"
>     unis = feval(ranfunc,x,1);
>
>     return octave_value (unis);
> --- 13,19 ----
>     NumRands(1) = 1;
>     octave_value_list x, unis;
>     x(0) = octave_value(NumRands);
> !   string ranfunc = "rand";
>     unis = feval(ranfunc,x,1);
>
>     return octave_value (unis);
>
>
> It is possible to return an octave_value_list directly, so I would
> assign the result to unis(0) and return unis, but this is not
> necessary for compilation.
>
> #include <octave/oct.h>
> #include <octave/parse.h>
> #include <string.h>
>
> using namespace std;
> DEFUN_DLD (my_call_test, args, ,"Test a call")
>
> {
>   ColumnVector NumRands(2);
>   NumRands(0) = 9000;
>   NumRands(1) = 1;
>   octave_value_list x, unis;
>   x(0) = octave_value(NumRands);
>   string ranfunc = "rand";
>   unis(0) = feval(ranfunc,x,1);
>
>   return unis;
> }
>
>
> Geraint.



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]