/************************************************************************* AP library Copyright (c) 2003-2009 Sergey Bochkanov (ALGLIB project). >>> LICENSE >>> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation (www.fsf.org); either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A copy of the GNU General Public License is available at http://www.fsf.org/licensing/licenses >>> END OF LICENSE >>> *************************************************************************/ namespace AP { /******************************************************************** Class defining a complex number with double precision. ********************************************************************/ public struct Complex { public double x; public double y; public Complex(double _x) { x = _x; y = 0; } public Complex(double _x, double _y) { x = _x; y = _y; } public static implicit operator Complex(double _x) { return new Complex(_x); } public static bool operator==(Complex lhs, Complex rhs) { return ((double)lhs.x==(double)rhs.x) & ((double)lhs.y==(double)rhs.y); } public static bool operator!=(Complex lhs, Complex rhs) { return ((double)lhs.x!=(double)rhs.x) | ((double)lhs.y!=(double)rhs.y); } public static Complex operator+(Complex lhs) { return lhs; } public static Complex operator-(Complex lhs) { return new Complex(-lhs.x,-lhs.y); } public static Complex operator+(Complex lhs, Complex rhs) { return new Complex(lhs.x+rhs.x,lhs.y+rhs.y); } public static Complex operator-(Complex lhs, Complex rhs) { return new Complex(lhs.x-rhs.x,lhs.y-rhs.y); } public static Complex operator*(Complex lhs, Complex rhs) { return new Complex(lhs.x*rhs.x-lhs.y*rhs.y, lhs.x*rhs.y+lhs.y*rhs.x); } public static Complex operator/(Complex lhs, Complex rhs) { Complex result; double e; double f; if( System.Math.Abs(rhs.y)yabs ? xabs : yabs; v = xabs