[Top][All Lists]

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

Octave segfaults on .oct file + more troubles

From: Martijn Brouwer
Subject: Octave segfaults on .oct file + more troubles
Date: Sun, 2 Nov 2003 00:23:01 +0100

I have problems compiling and running an .oct file with the following code:

#include <oct.h>
#include <complex>
#include <cmath>
using namespace std;

#define pi 3.141592654

DEFUN_DLD(lgm, args, ,"Calculates layer matrix from layer thickness, 
wavelength, refractive index and cos(th)") {
        complex<double> n(args(0).complex_value());
        double d=args(1).double_value();
        double l=args(2).double_value();
        complex<double> cosan(args(3).complex_value());
//      complex<double> expbeta=exp(-2*pi*n*d*cosan/l);
//      complex<double> expbeta=2
        double expbeta=2;

        ComplexMatrix LGM;
19    LGM(1,1)=1/expbeta;

        return octave_value(LGM);

Soc n and cosan are complex doubles, and d and l are real doubles. expbeta is 
real or complex, depending on which line I enable.
Next I create a complex matrix that is returned.
The code as shown above compiles correctly, but when I make expbeta an 
complex<double>, mkoctfile returns the following message: In function `octave_value_list Flgm(const octave_value_list&, int)': no match for `std::complex<double>& = octave_value' operator
/usr/include/c++/3.2/complex:798: candidates are: std::complex<double>&
/usr/include/c++/3.2/complex:738:                 std::complex<double>&
   std::complex<double>::operator=(const std::complex<double>&)

Apparently, mkoctfile thinks that expbeta is an octave value. What am I doing 
wrong here?

Even more serious problems I get when I try to use this funtion. When I compile 
with g++ 3.2, octave says:

error: /home/martijn/analysis/programs/ellipsometry/ifmrp.oct is not a valid 
shared library
error: `ifmrp' undefined near line 1 column 1

When I try g++ 3.3, octave segfaults! I guess on of the problems here might be 
that I have to comple dynamical loaded functions with the same compiler as 
octave has been compiled with. But it does not work with either compiler. 2.95 
gives even tons of error messages.
Can somebody shed some light on this troubles?


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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