Segmentation fault when using .oct function

I created my own function and compile it as .oct. But everytime I run it I got this error

octave:1> finvhalf
panic: Segmentation fault — stopping myself…
attempting to save variables to `octave-core’…
save to `octave-core’ complete
Segmentation fault

The thing is that the output does not really tell what is the error. The compilation was successful as well. It turns out that my output from this function is a ColumnVector object, but I need to specify the size of this object. So in the initialization,

ColumnVector x(args(0).vector_value());
int len=x.length();
ColumnVector vret(len);

where vret is the variable name to return. This solves the problem.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: