Example #1
0
        public static ComplexD operator -(double b, ComplexD a)
        {
            ComplexD c = -1.0f * a;
            c.Add(b);

            return c;
        }
Example #2
0
        public static ComplexD operator +(ComplexD a, double b)
        {
            ComplexD c = a;
            c.Add(b);

            return c;
        }
Example #3
0
        public static ComplexD operator -(ComplexD a, double b)
        {
            ComplexD c = a;
            c.Subtract(b);

            return c;
        }
Example #4
0
        public static ComplexD operator *(ComplexD a, ComplexD b)
        {
            ComplexD c = a;
            c.Multiply(b);

            return c;
        }
Example #5
0
        public static ComplexD operator !(ComplexD a)
        {
            ComplexD c = a;
            c.Conjugate();

            return c;
        }
Example #6
0
        public static ComplexD operator *(double b, ComplexD a)
        {
            ComplexD c = a;
            c.Multiply(b);

            return c;
        }
Example #7
0
        /// <summary>
        /// Calculates both Square-Roots of a complex number
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public ComplexD[] Sqrt(ComplexD number)
        {
            ComplexD res0 = ComplexD.CreateRadial((double)System.Math.Sqrt(number.Norm), number.Argument / 2.0f);
            ComplexD res1 = ComplexD.CreateRadial((double)System.Math.Sqrt(number.Norm), number.Argument / 2.0f + (double)Constant.Pi);

            return new ComplexD[2] { res0, res1 };
        }
Example #8
0
        public static ComplexD operator /(ComplexD a, ComplexD b)
        {
            ComplexD c = a;
            c.Divide(b);

            return c;
        }
        public static ComplexD operator /(ComplexD a, double b)
        {
            ComplexD c = a;

            c.Divide(b);

            return(c);
        }
Example #10
0
        /// <summary>
        /// Multiplies a complex number with this
        /// </summary>
        /// <param name="number"></param>
        public void Multiply(ComplexD number)
        {
            double real = Real;
            double imag = Imag;

            Real = real * number.Real - imag * number.Imag;
            Imag = real * number.Imag + imag * number.Real;
        }
        public static ComplexD operator -(ComplexD a, ComplexD b)
        {
            ComplexD c = a;

            c.Subtract(b);

            return(c);
        }
        public static ComplexD operator +(ComplexD a, ComplexD b)
        {
            ComplexD c = a;

            c.Add(b);

            return(c);
        }
        public static ComplexD operator /(double a, ComplexD b)
        {
            ComplexD c = a;

            c.Divide(b);

            return(c);
        }
        public static ComplexD operator *(ComplexD a, double b)
        {
            ComplexD c = a;

            c.Multiply(b);

            return(c);
        }
Example #15
0
        /// <summary>
        /// Exponentiates a complex by another
        /// </summary>
        /// <returns></returns>
        public static ComplexD Pow(ComplexD number, ComplexD exponent)
        {
            double r = number.Norm;
            double phi = number.Argument;

            double a = exponent.Real;
            double b = exponent.Imag;

            return ComplexD.CreateRadial((double)System.Math.Exp(System.Math.Log(r) * a - b * phi), a * phi + b * (double)System.Math.Log(r));
        }
Example #16
0
        /// <summary>
        /// Divides this by a complex number
        /// </summary>
        /// <param name="number"></param>
        public void Divide(ComplexD number)
        {
            double t = 1 / number.NormSquared;

            double real = Real;
            double imag = Imag;

            Real = t * (real * number.Real + imag * number.Imag);
            Imag = t * (imag * number.Real - real * number.Imag);
        }
Example #17
0
        /// <summary>
        /// Calculates e^Complex
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static ComplexD Exp(ComplexD number)
        {
            ComplexD c = ComplexD.Zero;

            double factor = (double)System.Math.Pow(Constant.E, number.Real);

            c.Real = factor * (double)System.Math.Cos(number.Imag);
            c.Imag = factor * (double)System.Math.Sin(number.Imag);

            return c;
        }
Example #18
0
        /// <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 ComplexD[] Root(ComplexD number, int order)
        {
            ComplexD[] values = new ComplexD[order];

            double phi = number.Argument / 2.0f;
            double dphi = (double)Constant.PiTimesTwo / (double)order;
            double r = (double)System.Math.Pow(number.Norm, 1.0f / order);

            for (int i = 1; i < order; i++)
            {
                values[i] = ComplexD.CreateRadial(r, phi + dphi * i);
            }

            return values;
        }
Example #19
0
 /// <summary>
 /// Adds a complex number to this
 /// </summary>
 /// <param name="number"></param>
 public void Add(ComplexD number)
 {
     Real += number.Real;
     Imag += number.Imag;
 }
Example #20
0
 /// <summary>
 /// Subtracts a complex number from this
 /// </summary>
 /// <param name="number"></param>
 public void Subtract(ComplexD number)
 {
     Real -= number.Real;
     Imag -= number.Imag;
 }
Example #21
0
 /// <summary>
 /// Exponentiates a complex by a real number
 /// </summary>
 /// <returns></returns>
 public static ComplexD Pow(ComplexD number, double scalar)
 {
     number.Pow(scalar);
     return number;
 }
Example #22
0
 /// <summary>
 /// Natural Logartihm for complex numbers
 /// </summary>
 /// <param name="number"></param>
 /// <returns></returns>
 public static ComplexD Log(ComplexD number)
 {
     return ComplexD.CreateOrthogonal((double)System.Math.Log(number.Norm), number.Argument);
 }