AForge.Math.Complex.Divide C# (CSharp) Method

Divide() public static method

Divides one complex number by another complex number.
Can not divide by zero.
public static Divide ( Complex a, Complex b ) : Complex
a Complex A instance.
b Complex A instance.
return Complex
        public static Complex Divide(Complex a, Complex b)
        {
            double aRe = a.Re, aIm = a.Im;
            double bRe = b.Re, bIm = b.Im;
            double modulusSquared = bRe*bRe + bIm*bIm;

            if (modulusSquared == 0)
            {
                throw new DivideByZeroException("Can not divide by zero.");
            }

            double invModulusSquared = 1/modulusSquared;

            return new Complex(
                (aRe*bRe + aIm*bIm)*invModulusSquared,
                (aIm*bRe - aRe*bIm)*invModulusSquared);
        }

Same methods

Complex::Divide ( Complex a, double s ) : Complex
Complex::Divide ( double s, Complex a ) : Complex
Complex::Divide ( Complex a, Complex b, Complex &result ) : void
Complex::Divide ( Complex a, double s, Complex &result ) : void
Complex::Divide ( double s, Complex a, Complex &result ) : void

Usage Example

Beispiel #1
0
 /// <summary>
 /// Divides one complex number by another complex number.
 /// </summary>
 ///
 /// <param name="a">A <see cref="Complex"/> instance.</param>
 /// <param name="b">A <see cref="Complex"/> instance.</param>
 ///
 /// <returns>A new Complex instance containing the result.</returns>
 /// <returns>Returns new <see cref="Complex"/> instance containing the result of division.</returns>
 ///
 public static Complex operator /(Complex a, Complex b)
 {
     return(Complex.Divide(a, b));
 }
All Usage Examples Of AForge.Math.Complex::Divide