[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calling other functions from .oct files
From: |
Geraint |
Subject: |
Re: Calling other functions from .oct files |
Date: |
01 May 2003 08:07:52 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
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
-------------------------------------------------------------
- Re: Calling other functions from .oct files, Heber Farnsworth, 2003/05/01
- Re: Calling other functions from .oct files, Peter Williams, 2003/05/01
- Re: Calling other functions from .oct files,
Geraint <=
- Re: Calling other functions from .oct files, Peter Williams, 2003/05/01
- Re: Calling other functions from .oct files, John W. Eaton, 2003/05/01
- Re: Calling other functions from .oct files, Paul Kienzle, 2003/05/01
- Re: Calling other functions from .oct files, John W. Eaton, 2003/05/01
- Re: Calling other functions from .oct files, Paul Kienzle, 2003/05/02