/// <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 Complex32 a, Complex32 b, int decimalPlaces) { return(AlmostEqualNormRelative(a.Norm(), b.Norm(), a.NormOfDifference(b), decimalPlaces)); }
/// <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 Complex32 a, Complex32 b, double maximumError) { return(AlmostEqualNormRelative(a.Norm(), b.Norm(), a.NormOfDifference(b), maximumError)); }
/// <summary> /// Checks whether two Complex 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 Complex32 a, Complex32 b) { return(AlmostEqualNormRelative(a.Norm(), b.Norm(), a.NormOfDifference(b), DefaultSingleAccuracy)); }
/// <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 Complex32 a, Complex32 b, double maximumAbsoluteError) { return(AlmostEqualNorm(a.Norm(), b.Norm(), a.NormOfDifference(b), maximumAbsoluteError)); }