diff options
author | matteo <matteo@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2003-03-17 18:11:45 +0000 |
---|---|---|
committer | matteo <matteo@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2003-03-17 18:11:45 +0000 |
commit | f04ea3143569dbadcdd5ed96e8feed0601464156 (patch) | |
tree | ba9a6a7e6bfd24d828419d8707209c8cc9f6798e /complex.h | |
parent | ef7de3f35f2ef572c106a972b7b16b0e947e620b (diff) |
lun mar 17 19:11:15 CET 2003
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@155 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'complex.h')
-rwxr-xr-x | complex.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/complex.h b/complex.h new file mode 100755 index 0000000..fd9de49 --- /dev/null +++ b/complex.h @@ -0,0 +1,63 @@ +struct c_complex + { double re, im; + }; + +struct complex + { double re, im; + complex(double r, double i = 0.0) { re = r; im = i; } + complex() { } /* uninitialized complex */ + complex(c_complex z) { re = z.re; im = z.im; } /* init from denotation */ + }; + +extern complex csqrt(complex), cexp(complex), expj(double); /* from complex.C */ +extern complex evaluate(complex[], int, complex[], int, complex); /* from complex.C */ + +inline double hypot(complex z) { return ::hypot(z.im, z.re); } +inline double atan2(complex z) { return ::atan2(z.im, z.re); } + +inline complex cconj(complex z) + { z.im = -z.im; + return z; + } + +inline complex operator * (double a, complex z) + { z.re *= a; z.im *= a; + return z; + } + +inline complex operator / (complex z, double a) + { z.re /= a; z.im /= a; + return z; + } + +inline void operator /= (complex &z, double a) + { z = z / a; + } + +extern complex operator * (complex, complex); +extern complex operator / (complex, complex); + +inline complex operator + (complex z1, complex z2) + { z1.re += z2.re; + z1.im += z2.im; + return z1; + } + +inline complex operator - (complex z1, complex z2) + { z1.re -= z2.re; + z1.im -= z2.im; + return z1; + } + +inline complex operator - (complex z) + { return 0.0 - z; + } + +inline bool operator == (complex z1, complex z2) + { return (z1.re == z2.re) && (z1.im == z2.im); + } + +inline complex sqr(complex z) + { return z*z; + } + |