Example #1
0
 public static double Square(ComplexNumber c)
 {
     return(c.Real * c.Real + c.Img * c.Img);
 }
Example #2
0
 public bool Approximates(ComplexNumber c, double eps)
 {
     return(Math.Abs(Real - c.Real) < eps && Math.Abs(Img - c.Img) < eps);
 }
Example #3
0
 /// <summary>
 /// Absolute value is the distance from the origin to the point on the complex plan represented by this ComplexNumber.
 /// </summary>
 public static double Abs(ComplexNumber c)
 {
     return(c.Img == 0 ? Math.Abs(c.Real) : Math.Sqrt(Square(c)));
 }
Example #4
0
 public static bool ApproxEqual(ComplexNumber c1, ComplexNumber c2, double eps)
 {
     return((double.IsNaN(c1.Real) && double.IsNaN(c2.Real) || Math.Abs(c1.Real - c2.Real) <= eps) &&
            (double.IsNaN(c1.Img) && double.IsNaN(c2.Img) || Math.Abs(c1.Img - c2.Img) <= eps));
 }