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
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue