public static __ct__ operator !(__ct__ a) { __ct__ c = a; c.Conjugate(); return(c); }
public static __ct__ operator *(__ft__ b, __ct__ a) { __ct__ c = a; c.Multiply(b); return(c); }
public static __ct__ operator /(__ft__ a, __ct__ b) { __ct__ c = a; c.Divide(b); return(c); }
public static __ct__ operator -(__ct__ a, __ft__ b) { __ct__ c = a; c.Subtract(b); return(c); }
public static __ct__ operator -(__ft__ b, __ct__ a) { __ct__ c = -1.0f * a; c.Add(b); return(c); }
/// <summary> /// Multiplies a complex number with this /// </summary> /// <param name="number"></param> public void Multiply(__ct__ number) { __ft__ real = Real; __ft__ imag = Imag; Real = real * number.Real - imag * number.Imag; Imag = real * number.Imag + imag * number.Real; }
public static __ct__ operator +(__ct__ a, __ft__ b) { __ct__ c = a; c.Add(b); return(c); }
/// <summary> /// Calculates both Square-Roots of a complex number /// </summary> /// <param name="number"></param> /// <returns></returns> public __ct__[] Sqrt(__ct__ number) { __ct__ res0 = __ct__.CreateRadial((__ft__)System.Math.Sqrt(number.Norm), number.Argument / 2.0f); __ct__ res1 = __ct__.CreateRadial((__ft__)System.Math.Sqrt(number.Norm), number.Argument / 2.0f + (__ft__)Constant.Pi); return(new __ct__[2] { res0, res1 }); }
/// <summary> /// Exponentiates a complex by another /// </summary> /// <returns></returns> public static __ct__ Pow(__ct__ number, __ct__ exponent) { __ft__ r = number.Norm; __ft__ phi = number.Argument; __ft__ a = exponent.Real; __ft__ b = exponent.Imag; return(__ct__.CreateRadial((__ft__)System.Math.Exp(System.Math.Log(r) * a - b * phi), a * phi + b * (__ft__)System.Math.Log(r))); }
/// <summary> /// Divides this by a complex number /// </summary> /// <param name="number"></param> public void Divide(__ct__ number) { __ft__ t = 1 / number.NormSquared; __ft__ real = Real; __ft__ imag = Imag; Real = t * (real * number.Real + imag * number.Imag); Imag = t * (imag * number.Real - real * number.Imag); }
/// <summary> /// Calculates e^Complex /// </summary> /// <param name="number"></param> /// <returns></returns> public static __ct__ Exp(__ct__ number) { __ct__ c = __ct__.Zero; __ft__ factor = (__ft__)System.Math.Pow(Constant.E, number.Real); c.Real = factor * (__ft__)System.Math.Cos(number.Imag); c.Imag = factor * (__ft__)System.Math.Sin(number.Imag); return(c); }
/// <summary> /// Calculates the n-th Root of a Complex number and returns n Solutions /// </summary> /// <param name="number"></param> /// <param name="order">n</param> /// <returns></returns> public __ct__[] Root(__ct__ number, int order) { __ct__[] values = new __ct__[order]; __ft__ phi = number.Argument / 2.0f; __ft__ dphi = (__ft__)Constant.PiTimesTwo / (__ft__)order; __ft__ r = (__ft__)System.Math.Pow(number.Norm, 1.0f / order); for (int i = 1; i < order; i++) { values[i] = __ct__.CreateRadial(r, phi + dphi * i); } return(values); }
/// <summary> /// Natural Logartihm for complex numbers /// </summary> /// <param name="number"></param> /// <returns></returns> public static __ct__ Log(__ct__ number) { return(__ct__.CreateOrthogonal((__ft__)System.Math.Log(number.Norm), number.Argument)); }
/// <summary> /// Exponentiates a complex by a real number /// </summary> /// <returns></returns> public static __ct__ Pow(__ct__ number, __ft__ scalar) { number.Pow(scalar); return(number); }
/// <summary> /// Subtracts a complex number from this /// </summary> /// <param name="number"></param> public void Subtract(__ct__ number) { Real -= number.Real; Imag -= number.Imag; }
/// <summary> /// Adds a complex number to this /// </summary> /// <param name="number"></param> public void Add(__ct__ number) { Real += number.Real; Imag += number.Imag; }