Exemplo n.º 1
0
 /// <summary>
 /// Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers
 /// are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
 /// </summary>
 /// <param name="a">The first value.</param>
 /// <param name="b">The second value.</param>
 /// <param name="decimalPlaces">The number of decimal places.</param>
 public static bool AlmostEqualRelative(this Complex a, Complex b, int decimalPlaces)
 {
     return(AlmostEqualNormRelative(Complex.AbsSquared(a), Complex.AbsSquared(b), Complex.AbsSquared(a - b), decimalPlaces));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Compares two complex and determines if they are equal within
 /// the specified maximum error.
 /// </summary>
 /// <param name="a">The first value.</param>
 /// <param name="b">The second value.</param>
 /// <param name="maximumError">The accuracy required for being almost equal.</param>
 public static bool AlmostEqualRelative(this Complex a, Complex b, double maximumError)
 {
     return(AlmostEqualNormRelative(Complex.AbsSquared(a), Complex.AbsSquared(b), Complex.AbsSquared(a - b), maximumError));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Checks whether two Compex numbers are almost equal.
 /// </summary>
 /// <param name="a">The first number</param>
 /// <param name="b">The second number</param>
 /// <returns>true if the two values differ by no more than 10 * 2^(-52); false otherwise.</returns>
 public static bool AlmostEqualRelative(this Complex a, Complex b)
 {
     return(AlmostEqualNormRelative(Complex.AbsSquared(a), Complex.AbsSquared(b), Complex.AbsSquared(a - b), DefaultDoubleAccuracy));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Compares two complex and determines if they are equal within
 /// the specified maximum error.
 /// </summary>
 /// <param name="a">The first value.</param>
 /// <param name="b">The second value.</param>
 /// <param name="maximumAbsoluteError">The accuracy required for being almost equal.</param>
 public static bool AlmostEqual(this Complex a, Complex b, double maximumAbsoluteError)
 {
     return(AlmostEqualNorm(Complex.AbsSquared(a), Complex.AbsSquared(b), Complex.AbsSquared(a - b), maximumAbsoluteError));
 }