Hi all,
I am a new user (aka newbie) to the octace c++, meaning i just use the c++ library for my code.
I have a couple of questions. For someone experienced i can imagine this wud be a piece of cake:-)
1) Is there a way to plot using octave calls from within c++ program e.g. using feval..?? That wud be very handy:-)
a simple example:
#include <iostream>
#include <oct.h>
using namespace std;
int main(argc, argv)
{
octave_main (argc, argv, 1);//this throws the octave message but can be avoided
ColumnVector x(2), y(2);
x(0) =1; x(1)=2;
y(0) =10; y(1)=20;
octave_value_list f_arg, f_ret;
f_arg(0) = octave_value(x);
f_arg(1) = octave_value(y);
f_ret=feval("plot",f_arg,1);
if (!error_state )
{
cout << "ok" <<endl;
double out = f_ret(0).double_value();
}
else
std::cout << "error\n";
}
the above compiles and runs but no plot figure apperas. for other functions like "rand" i get a proper result.
actually i just managed to call functions within c++ using feval.
Some comments here:
octave_main is needed otherwise i get a segmentation fault. this means that the example in octave wiki compiles but doesn't run. can anyone give an insight to this? i saw posts with people allocating symbol tables or initiliazing symbol tables and others. in addition, the executable runs only in the bin folder of octave (i use octave_gcc on windows xp). in any other case i get message that "rand" or whatever feval function doesn't exist despite the fact that i put all the necessary dll in the folder or add the bin folder of octave in the system path. Strange isn't it?
2) If i define one ColumnVector and one RowVector, the rows() and columns() member functions report same numbers.
e.g.
RowVector row(10);
cout << row.rows() << " " << row.cols() << endl;
ColumnVector col(10);
cout << col.rows() << " " << col.cols() << endl;
it reports the same:
10 1
10 1
Isn't it a bug?? Shouldn' t the first one report "1 10"??
In this context what is the best way to insert new data in a Matrix in case u dont know in advance the size of the matrix?
3) Are there any plans for writing proper documentation for octave c++ functions? I like the api (although a little bit limited e.g. Matrix type is only double and only 2D).
Thank you for your time,
Regards,
tarabas