help-octave
[Top][All Lists]
Advanced

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

feval/octave_value_list segmentation fault


From: s0672742
Subject: feval/octave_value_list segmentation fault
Date: Thu, 30 Dec 2010 03:26:38 -0800 (PST)

Dear all,
I've been using octave in my c++ for quite a while now and the usual
scenario develops something which was working fine doesn't work any more:

I call octave methods with feval in various classes and this worked fine
until now. Let me give you an examples which works fine on my machine and
the one which doesn't.

example 1: basic use of feval in main.cpp

#  ---------  start of main.cpp ------------- #

#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>

using namespace std;

int main(const int argc, char ** argv){

          octave_main(0, argv, 1);

          ColumnVector colvect(2);
          colvect(0) = 2;
          colvect(1) = 3;

        octave_value input = colvect;
        octave_value_list output;
        output = feval("mean",input,1);
        Matrix abs_m = output(0).matrix_value();

        cout<< abs_m << endl;
}

This successfully prints 2.5. Now we using this in a class and called in
main I get a segmentation fault when octave_main
is called.

example 2 use feval in other classes 

--- test.h and test.cpp shown as one -----

#ifndef TEST_H_
#define TEST_H_

#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/oct-obj.h>

class Test{

public:

Matrix mean(ColumnVector m){

        octave_value input = m;
        octave_value_list output;
        output = feval("mean",input,1);
        Matrix abs_m = output(0).matrix_value();
        Matrix abs_m(1,1);
        return abs_m;
};


#endif /* TEST_H_ */

------ main.cpp ---------

 
#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>

#include "test.h"

using namespace std;

Test *test;

int main(const int argc, char ** argv){

      octave_main(argc, argv, 1);

          ColumnVector colvect(2);
          colvect(0) = 2;
          colvect(1) = 3;

     test = new Test();
     
  cout<< test->mean(colvect) << endl;
}


When I run the second example I get a  segmentation fault. This is very
strange, I did not use to get this error, I'm currently
using octave3.2.3. Has anybody came across something similar or has an idea
about solving this ?


-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/feval-octave-value-list-segmentation-fault-tp3168164p3168164.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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