swig/Examples/test-suite/complextest.i
William S Fulton e01cfd70c7 Add missing declaration for std::complex
Fixes missing type information for std::complex in scripting languages.
Closes #732.

Update Javascript and Octave complextest, although they don't actually
get run as they don't work
2017-10-02 19:07:24 +01:00

77 lines
1.1 KiB
OpenEdge ABL

%module complextest
%include <complex.i>
#ifdef __cplusplus
%{
#include <algorithm>
#include <functional>
#include <numeric>
%}
%include <std_vector.i>
#if 1
%template(VectorStdCplx) std::vector<std::complex<double> >;
#endif
%inline
{
std::complex<double> Conj(const std::complex<double>& a)
{
return std::conj(a);
}
std::complex<float> Conjf(const std::complex<float>& a)
{
return std::conj(a);
}
std::vector<std::complex<double> > Copy_h(const std::vector<std::complex<double> >& a)
{
std::vector<std::complex<double> > b(a.size()/2);
std::copy(a.begin(), a.begin()+a.size()/2, b.begin());
return b;
}
using namespace std;
struct ComplexPair
{
std::complex<double> z1;
complex<double> z2;
};
complex<double> Conj2(const complex<double>& a)
{
return std::conj(a);
}
complex<float> Conjf2(const complex<float>& a)
{
return std::conj(a);
}
}
#else
%{
%}
%inline
{
complex Conj(complex a)
{
return conj(a);
}
complex float Conjf(float complex a)
{
return conj(a);
}
}
#endif