/* * See http://www.asterisk.org for more information about * the Asterisk project. Please do not directly contact * any of the maintainers of this project for assistance; * the project provides a web site, mailing lists and IRC * channels for your use. * * This program is free software, distributed under the terms of * the GNU General Public License Version 2 as published by the * Free Software Foundation. See the LICENSE file included with * this program for more details. */ 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; }