C++ code calling octave and the FAQ
Worik
worik.stanton at gmail.com
Fri Apr 4 17:05:42 CDT 2008
I was hoping that I could get some help with this, so I am asking again.
FAQ says...
#include <octave/oct.h>
...
ColumnVector NumRands(2);
NumRands(0) = 9000;
NumRands(1) = 1;
octave_value_list f_arg, f_ret;
f_arg(0) = octave_value(NumRands);
f_ret = feval("rand",f_arg,1);
Matrix unis(f_ret(0).matrix_value());
I competed this snippet into a programme thusly...
#include <octave/oct.h>
#include <octave/parse.h>
#include <iostream>
int main(){
ColumnVector NumRands(2);
NumRands(0) = 9000;
NumRands(1) = 1;
octave_value_list f_arg, f_ret;
f_arg(0) = octave_value(NumRands);
f_ret = feval("rand",f_arg,1);
Matrix unis(f_ret(0).matrix_value());
std::cout<<__FILE__<<":"<<__LINE__<<":"<<unis;
return 0;
}
Compiled it on my ubuntu box thus:
g++ -g3 -o test -O0 test.cc -L /usr/lib/octave-2.9.12 -loctave
-loctinterp
The call to feval segfaulted.
I am sure that this is very easy to solve. Is someone out there using
feval able to help me out with this?
Then we could update the FAQ.
cheers
Worik
--
They laughed at Einstein. They laughed at the Wright Brothers. They
laughed at Bozo the Clown.
More information about the Help-octave
mailing list