// Decompiled with JetBrains decompiler // Type: Microsoft.Scripting.Math.Complex64 // Assembly: FiestaShark, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null // MVID: 12469781-3753-4869-9C1A-117F1862B52C // Assembly location: E:\Fiesta\Emus\DragonFiesta\Tools\FiestaShark-Farbod\FiestaShark.exe using System; using System.Globalization; namespace Microsoft.Scripting.Math { public struct Complex64 { private readonly double real; private readonly double imag; public static Complex64 MakeImaginary(double imag) { return new Complex64(0.0, imag); } public static Complex64 MakeReal(double real) { return new Complex64(real, 0.0); } public static Complex64 Make(double real, double imag) { return new Complex64(real, imag); } public Complex64(double real) : this(real, 0.0) { } public Complex64(double real, double imag) { this.real = real; this.imag = imag; } public bool IsZero { get { return this.real == 0.0 && this.imag == 0.0; } } public double Real { get { return this.real; } } public double Imag { get { return this.imag; } } public Complex64 Conjugate() { return new Complex64(this.real, -this.imag); } public override string ToString() { if (this.real == 0.0) return this.imag.ToString((IFormatProvider) CultureInfo.InvariantCulture.NumberFormat) + "j"; return this.imag < 0.0 ? string.Format((IFormatProvider) CultureInfo.InvariantCulture.NumberFormat, "({0}{1}j)", (object) this.real, (object) this.imag) : string.Format((IFormatProvider) CultureInfo.InvariantCulture.NumberFormat, "({0}+{1}j)", (object) this.real, (object) this.imag); } public static implicit operator Complex64(int i) { return Complex64.MakeReal((double) i); } public static implicit operator Complex64(uint i) { return Complex64.MakeReal((double) i); } public static implicit operator Complex64(short i) { return Complex64.MakeReal((double) i); } public static implicit operator Complex64(ushort i) { return Complex64.MakeReal((double) i); } public static implicit operator Complex64(long l) { return Complex64.MakeReal((double) l); } public static implicit operator Complex64(ulong i) { return Complex64.MakeReal((double) i); } public static implicit operator Complex64(sbyte i) { return Complex64.MakeReal((double) i); } public static implicit operator Complex64(byte i) { return Complex64.MakeReal((double) i); } public static implicit operator Complex64(float f) { return Complex64.MakeReal((double) f); } public static implicit operator Complex64(double d) { return Complex64.MakeReal(d); } public static implicit operator Complex64(BigInteger i) { if ((object) i == null) throw new ArgumentException(MathResources.InvalidArgument, nameof (i)); return Complex64.MakeReal(i.ToFloat64()); } public static bool operator ==(Complex64 x, Complex64 y) { return x.real == y.real && x.imag == y.imag; } public static bool operator !=(Complex64 x, Complex64 y) { return x.real != y.real || x.imag != y.imag; } public static Complex64 Add(Complex64 x, Complex64 y) { return x + y; } public static Complex64 operator +(Complex64 x, Complex64 y) { return new Complex64(x.real + y.real, x.imag + y.imag); } public static Complex64 Subtract(Complex64 x, Complex64 y) { return x - y; } public static Complex64 operator -(Complex64 x, Complex64 y) { return new Complex64(x.real - y.real, x.imag - y.imag); } public static Complex64 Multiply(Complex64 x, Complex64 y) { return x * y; } public static Complex64 operator *(Complex64 x, Complex64 y) { return new Complex64(x.real * y.real - x.imag * y.imag, x.real * y.imag + x.imag * y.real); } public static Complex64 Divide(Complex64 x, Complex64 y) { return x / y; } public static Complex64 operator /(Complex64 a, Complex64 b) { if (b.IsZero) throw new DivideByZeroException(MathResources.ComplexDivizionByZero); double real; double imag; if (System.Math.Abs(b.real) >= System.Math.Abs(b.imag)) { double num1 = b.imag / b.real; double num2 = b.real + num1 * b.imag; real = (a.real + a.imag * num1) / num2; imag = (a.imag - a.real * num1) / num2; } else { double num1 = b.real / b.imag; double num2 = b.imag + num1 * b.real; real = (a.real * num1 + a.imag) / num2; imag = (a.imag * num1 - a.real) / num2; } return new Complex64(real, imag); } public static Complex64 Mod(Complex64 x, Complex64 y) { return x % y; } public static Complex64 operator %(Complex64 x, Complex64 y) { if ((ValueType) x == null) throw new ArgumentException(MathResources.InvalidArgument, nameof (x)); if ((ValueType) y == null) throw new ArgumentException(MathResources.InvalidArgument, nameof (y)); if (y == (Complex64) 0) throw new DivideByZeroException(); throw new NotImplementedException(); } public static Complex64 Negate(Complex64 x) { return -x; } public static Complex64 operator -(Complex64 x) { return new Complex64(-x.real, -x.imag); } public static Complex64 Plus(Complex64 x) { return +x; } public static Complex64 operator +(Complex64 x) { return x; } public static double Hypot(double x, double y) { if (x < 0.0) x = -x; if (y < 0.0) y = -y; if (x == 0.0) return y; if (y == 0.0) return x; if (x < y) { double num = y; y = x; x = num; } y /= x; return x * System.Math.Sqrt(1.0 + y * y); } public double Abs() { return Complex64.Hypot(this.real, this.imag); } public Complex64 Power(Complex64 y) { double real1 = y.real; double imag1 = y.imag; int num1 = (int) real1; if ((double) num1 == real1 && num1 >= 0 && imag1 == 0.0) { Complex64 complex64_1 = new Complex64(1.0); if (num1 == 0) return complex64_1; Complex64 complex64_2 = this; for (; num1 != 0; num1 >>= 1) { if ((num1 & 1) != 0) complex64_1 *= complex64_2; complex64_2 *= complex64_2; } return complex64_1; } if (this.IsZero) return !y.IsZero ? Complex64.MakeReal(0.0) : Complex64.MakeReal(1.0); double real2 = this.real; double imag2 = this.imag; double num2 = real2 * real2 + imag2 * imag2; double num3 = System.Math.Atan2(imag2, real2); double num4 = System.Math.Pow(num2, real1 / 2.0) * System.Math.Exp(-imag1 * num3); double num5 = real1 * num3 + 0.5 * imag1 * System.Math.Log(num2); return new Complex64(num4 * System.Math.Cos(num5), num4 * System.Math.Sin(num5)); } public override int GetHashCode() { return (int) this.real + (int) this.imag * 1000003; } public override bool Equals(object obj) { return obj is Complex64 complex64 && this == complex64; } } }