My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const dword COMPLEX_V = 20;

struct Complex : std::complex<double>
{
typedef std::complex<double> C;

Complex() {}
Complex(double r) : C(r) {}
Complex(double r, double i) : C(r,i) {}
Complex(const C& c) : C(c) {}

Complex(const Nuller&) : C(DOUBLE_NULL, DOUBLE_NULL) {}
operator Value() const { return RichValue<Complex>(*this); }
Complex(const Value& v) : C(IsNumber(v) ? Complex((double)v) : RichValue<Complex>::Extract(v)) {}

bool operator==(const Complex& c) const { return (const C&)(*this) == (const C&)c; }
bool operator!=(const Complex& c) const { return (const C&)(*this) != (const C&)c; }

void Serialize(Stream& s);
void Xmlize(XmlIO& xio);
void Jsonize(JsonIO& jio);
};

template<> inline bool IsNull(const Complex& r) { return r.real() < DOUBLE_NULL_LIM || r.imag() < DOUBLE_NULL_LIM; }
template<> inline unsigned GetHashValue(const Complex& x) { return CombineHash(x.real(), x.imag()); }
template<> inline String AsString(const std::complex<double>& x) { return String().Cat() << "(" << x.real() << "," << x.imag() << ")"; }
template<> inline String AsString(const Complex& x) { return AsString((const std::complex<double>&)x); }

template<> inline dword ValueTypeNo(const Complex*) { return COMPLEX_V; }

inline const Complex& Nvl(const Complex& a, const Complex& b) { return IsNull(a) ? b : a; }

inline bool IsPolyEqual(const Complex& x, const Value& v) {
return IsNumber(v) && x.imag() == 0 && x.real() == (double)v;
}

VALUE_COMPARE(Complex)
NTL_MOVEABLE(Complex)

Change log

r4647 by cxl on Mar 3, 2012   Diff
.developing SvoValue
Go to: 
Project members, sign in to write a code review

Older revisions

r4583 by cxl on Feb 13, 2012   Diff
.Core: ScanTime
r3891 by cxl on Sep 19, 2011   Diff
Core: AsString for std::complex
r3625 by cxl on Jul 6, 2011   Diff
*Core: Complex fix
All revisions of this file

File info

Size: 1619 bytes, 38 lines
Powered by Google Project Hosting