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
This commit is contained in:
parent
8834047dcd
commit
e01cfd70c7
11 changed files with 87 additions and 15 deletions
|
|
@ -14,6 +14,11 @@ Version 4.0.0 (in progress)
|
|||
declared as such)
|
||||
smart-pointer classes deriving from parent smart-pointers
|
||||
|
||||
2017-10-02: wsfulton
|
||||
[Javascript, Python, Ruby] Issue #732 - Missing type information for std::complex
|
||||
in std_complex.i meant that previously std::complex always had to be fully qualified
|
||||
in order to be wrapped with the appropriate typemaps.
|
||||
|
||||
2017-09-29: wsfulton
|
||||
Issue #1100 - Allow an instantiated template to have the same name in the target
|
||||
language as the C++ template name, for example, this is now possible:
|
||||
|
|
|
|||
|
|
@ -26,19 +26,30 @@
|
|||
return std::conj(a);
|
||||
}
|
||||
|
||||
#if 1
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct ComplexPair
|
||||
{
|
||||
std::complex<double> z1, z2;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@ public class complextest_runme {
|
|||
if ( complextest.Conjf(a) != Complex.Conjugate(a) )
|
||||
throw new Exception("std::complex<float> test failed");
|
||||
|
||||
if ( complextest.Conj2(a) != Complex.Conjugate(a) )
|
||||
throw new Exception("std::complex<double> test failed");
|
||||
|
||||
if ( complextest.Conjf2(a) != Complex.Conjugate(a) )
|
||||
throw new Exception("std::complex<float> test failed");
|
||||
|
||||
var vec = new VectorStdCplx();
|
||||
vec.Add(new Complex(1, 2));
|
||||
vec.Add(new Complex(2, 3));
|
||||
|
|
|
|||
|
|
@ -8,8 +8,16 @@ a_c = complextest.Conj(a);
|
|||
if (a_c.toString() != expected.toString())
|
||||
throw "Error in Conj(a)";
|
||||
|
||||
a_c_f = complextest.Conjf(a);
|
||||
if (a_c_f.toString() != expected.toString())
|
||||
a_c = complextest.Conjf(a);
|
||||
if (a_c.toString() != expected.toString())
|
||||
throw "Error in Conjf(a)";
|
||||
|
||||
a_c = complextest.Conj2(a);
|
||||
if (a_c.toString() != expected.toString())
|
||||
throw "Error in Conj(a)";
|
||||
|
||||
a_c = complextest.Conjf2(a);
|
||||
if (a_c.toString() != expected.toString())
|
||||
throw "Error in Conjf(a)";
|
||||
|
||||
v = new complextest.VectorStdCplx();
|
||||
|
|
|
|||
|
|
@ -15,10 +15,15 @@ if (complextest.Conjf(a) != a.conjugate())
|
|||
error("bad complex mapping")
|
||||
endif
|
||||
|
||||
if (complextest.Conj2(a) != a.conjugate())
|
||||
error("bad complex mapping")
|
||||
endif
|
||||
|
||||
if (complextest.Conjf2(a) != a.conjugate())
|
||||
error("bad complex mapping")
|
||||
endif
|
||||
|
||||
|
||||
v = (complex(1,2), complex(2,3), complex(4,3), 1);
|
||||
|
||||
try
|
||||
complextest.Copy_h(v);
|
||||
catch
|
||||
end_try_catch
|
||||
complextest.Copy_h(v);
|
||||
|
|
|
|||
|
|
@ -8,13 +8,17 @@ if complextest.Conj(a) != a.conjugate():
|
|||
if complextest.Conjf(a) != a.conjugate():
|
||||
raise RuntimeError, "bad complex mapping"
|
||||
|
||||
if complextest.Conj2(a) != a.conjugate():
|
||||
raise RuntimeError, "bad complex mapping"
|
||||
|
||||
if complextest.Conjf2(a) != a.conjugate():
|
||||
raise RuntimeError, "bad complex mapping"
|
||||
|
||||
|
||||
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
|
||||
|
||||
try:
|
||||
complextest.Copy_h(v)
|
||||
except:
|
||||
pass
|
||||
if len(complextest.Copy_h(v)) != 2:
|
||||
raise RuntimeError("Copy_h failed")
|
||||
|
||||
p = complextest.ComplexPair()
|
||||
p.z1 = complex(0, 1)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
#include <complex>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%naturalvar complex;
|
||||
template<typename T> class complex;
|
||||
%template() complex<double>;
|
||||
%template() complex<float>;
|
||||
}
|
||||
|
||||
/* defining the complex as/from converters */
|
||||
|
||||
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
#include <complex>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%naturalvar complex;
|
||||
template<typename T> class complex;
|
||||
%template() complex<double>;
|
||||
%template() complex<float>;
|
||||
}
|
||||
|
||||
/* defining the complex as/from converters */
|
||||
|
||||
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
#include <complex>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%naturalvar complex;
|
||||
template<typename T> class complex;
|
||||
%template() complex<double>;
|
||||
%template() complex<float>;
|
||||
}
|
||||
|
||||
/* defining the complex as/from converters */
|
||||
|
||||
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
#include <complex>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%naturalvar complex;
|
||||
template<typename T> class complex;
|
||||
%template() complex<double>;
|
||||
%template() complex<float>;
|
||||
}
|
||||
|
||||
/* defining the complex as/from converters */
|
||||
|
||||
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
|
||||
|
|
@ -18,5 +25,3 @@
|
|||
%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>);
|
||||
%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
#include <complex>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%naturalvar complex;
|
||||
template<typename T> class complex;
|
||||
%template() complex<double>;
|
||||
%template() complex<float>;
|
||||
}
|
||||
|
||||
/* defining the complex as/from converters */
|
||||
|
||||
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue