Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B49D318EF0 for ; Sat, 2 Jan 2016 19:07:06 +0000 (UTC) Received: (qmail 17909 invoked by uid 500); 2 Jan 2016 19:07:01 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 17717 invoked by uid 500); 2 Jan 2016 19:07:01 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 17689 invoked by uid 99); 2 Jan 2016 19:07:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jan 2016 19:07:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3BF87DFF70; Sat, 2 Jan 2016 19:07:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: luc@apache.org To: commits@commons.apache.org Date: Sat, 02 Jan 2016 19:07:03 -0000 Message-Id: <9f7bdf9a36e6415c9afd7f9f1fa51144@git.apache.org> In-Reply-To: <0cfcc8d4c9034b77baabd91fdba7622a@git.apache.org> References: <0cfcc8d4c9034b77baabd91fdba7622a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [03/14] [math] Javadoc fixes; added tests to confirm NaN behavior. Javadoc fixes; added tests to confirm NaN behavior. Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/a5ccf599 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/a5ccf599 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/a5ccf599 Branch: refs/heads/3.6-release Commit: a5ccf5998af87deafd822b40686de4ed75019c19 Parents: 77f0f20 Author: Phil Steitz Authored: Fri Jan 1 15:07:07 2016 -0700 Committer: Phil Steitz Committed: Fri Jan 1 15:07:07 2016 -0700 ---------------------------------------------------------------------- .../apache/commons/math3/complex/Complex.java | 154 ++++++++----------- .../apache/commons/math3/util/Precision.java | 39 +++-- .../commons/math3/complex/ComplexTest.java | 18 +++ 3 files changed, 108 insertions(+), 103 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/a5ccf599/src/main/java/org/apache/commons/math3/complex/Complex.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/complex/Complex.java b/src/main/java/org/apache/commons/math3/complex/Complex.java index c8bd211..bf43120 100644 --- a/src/main/java/org/apache/commons/math3/complex/Complex.java +++ b/src/main/java/org/apache/commons/math3/complex/Complex.java @@ -32,7 +32,7 @@ import org.apache.commons.math3.util.Precision; /** * Representation of a Complex number, i.e. a number which has both a * real and imaginary part. - *
+ *

* Implementations of arithmetic operations handle {@code NaN} and * infinite values according to the rules for {@link java.lang.Double}, i.e. * {@link #equals} is an equivalence relation for all instances that have @@ -42,16 +42,14 @@ import org.apache.commons.math3.util.Precision; *

  • {@code 1 + NaNi}
  • *
  • {@code NaN + i}
  • *
  • {@code NaN + NaNi}
  • - * - * Note that this is in contradiction with the IEEE-754 standard for floating + *

    + * Note that this contradicts the IEEE-754 standard for floating * point numbers (according to which the test {@code x == x} must fail if * {@code x} is {@code NaN}). The method * {@link org.apache.commons.math3.util.Precision#equals(double,double,int) * equals for primitive double} in {@link org.apache.commons.math3.util.Precision} * conforms with IEEE-754 while this class conforms with the standard behavior - * for Java object types. - *
    - * Implements Serializable since 2.0 + * for Java object types.

    * */ public class Complex implements FieldElement, Serializable { @@ -138,12 +136,9 @@ public class Complex implements FieldElement, Serializable { * Returns a {@code Complex} whose value is * {@code (this + addend)}. * Uses the definitional formula - *
    -     *  
    -     *   (a + bi) + (c + di) = (a+c) + (b+d)i
    -     *  
    -     * 
    - *
    + *

    + * {@code (a + bi) + (c + di) = (a+c) + (b+d)i} + *

    * If either {@code this} or {@code addend} has a {@code NaN} value in * either part, {@link #NaN} is returned; otherwise {@code Infinite} * and {@code NaN} values are returned in the parts of the result @@ -180,17 +175,17 @@ public class Complex implements FieldElement, Serializable { } /** - * Return the conjugate of this complex number. + * Returns the conjugate of this complex number. * The conjugate of {@code a + bi} is {@code a - bi}. - *
    + *

    * {@link #NaN} is returned if either the real or imaginary * part of this Complex number equals {@code Double.NaN}. - *
    + *

    * If the imaginary part is infinite, and the real part is not * {@code NaN}, the returned value has infinite imaginary part * of the opposite sign, e.g. the conjugate of * {@code 1 + POSITIVE_INFINITY i} is {@code 1 - NEGATIVE_INFINITY i}. - * + *

    * @return the conjugate of this Complex object. */ public Complex conjugate() { @@ -216,7 +211,7 @@ public class Complex implements FieldElement, Serializable { * * prescaling of operands to limit the effects of overflows and * underflows in the computation. - *
    + *

    * {@code Infinite} and {@code NaN} values are handled according to the * following rules, applied in the order presented: *

      @@ -401,7 +396,7 @@ public class Complex implements FieldElement, Serializable { * Returns {@code true} if, both for the real part and for the imaginary * part, there is no double value strictly between the arguments or the * difference between them is within the range of allowed error - * (inclusive). + * (inclusive). Returns {@code false} if either of the arguments is NaN. * * @param x First value (cannot be {@code null}). * @param y Second value (cannot be {@code null}). @@ -421,7 +416,7 @@ public class Complex implements FieldElement, Serializable { * Returns {@code true} if, both for the real part and for the imaginary * part, there is no double value strictly between the arguments or the * relative difference between them is smaller or equal to the given - * tolerance. + * tolerance. Returns {@code false} if either of the arguments is NaN. * * @param x First value (cannot be {@code null}). * @param y Second value (cannot be {@code null}). @@ -500,21 +495,19 @@ public class Complex implements FieldElement, Serializable { * Returns a {@code Complex} whose value is {@code this * factor}. * Implements preliminary checks for {@code NaN} and infinity followed by * the definitional formula: - *
      -     *  
      -     *   (a + bi)(c + di) = (ac - bd) + (ad + bc)i
      -     *  
      -     * 
      + *

      + * {@code (a + bi)(c + di) = (ac - bd) + (ad + bc)i} + *

      * Returns {@link #NaN} if either {@code this} or {@code factor} has one or * more {@code NaN} parts. - *
      + *

      * Returns {@link #INF} if neither {@code this} nor {@code factor} has one * or more {@code NaN} parts and if either {@code this} or {@code factor} * has one or more infinite parts (same result is returned regardless of * the sign of the components). - *
      + *

      * Returns finite values in components of the result per the definitional - * formula in all remaining cases. + * formula in all remaining cases.

      * * @param factor value to be multiplied by this {@code Complex}. * @return {@code this * factor}. @@ -580,7 +573,7 @@ public class Complex implements FieldElement, Serializable { /** * Returns a {@code Complex} whose value is {@code (-this)}. * Returns {@code NaN} if either real or imaginary - * part of this Complex number equals {@code Double.NaN}. + * part of this Complex number is {@code Double.NaN}. * * @return {@code -this}. */ @@ -596,11 +589,9 @@ public class Complex implements FieldElement, Serializable { * Returns a {@code Complex} whose value is * {@code (this - subtrahend)}. * Uses the definitional formula - *
      -     *  
      -     *   (a + bi) - (c + di) = (a-c) + (b-d)i
      -     *  
      -     * 
      + *

      + * {@code (a + bi) - (c + di) = (a-c) + (b-d)i} + *

      * If either {@code this} or {@code subtrahend} has a {@code NaN]} value in either part, * {@link #NaN} is returned; otherwise infinite and {@code NaN} values are * returned in the parts of the result according to the rules for @@ -641,11 +632,9 @@ public class Complex implements FieldElement, Serializable { * * inverse cosine of this complex number. * Implements the formula: - *
      -     *  
      -     *   acos(z) = -i (log(z + i (sqrt(1 - z2))))
      -     *  
      -     * 
      + *

      + * {@code acos(z) = -i (log(z + i (sqrt(1 - z2))))} + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite. * @@ -665,13 +654,11 @@ public class Complex implements FieldElement, Serializable { * * inverse sine of this complex number. * Implements the formula: - *
      -     *  
      -     *   asin(z) = -i (log(sqrt(1 - z2) + iz))
      -     *  
      -     * 
      + *

      + * {@code asin(z) = -i (log(sqrt(1 - z2) + iz))} + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the - * input argument is {@code NaN} or infinite. + * input argument is {@code NaN} or infinite.

      * * @return the inverse sine of this complex number. * @since 1.2 @@ -689,13 +676,11 @@ public class Complex implements FieldElement, Serializable { * * inverse tangent of this complex number. * Implements the formula: - *
      -     *  
      -     *   atan(z) = (i/2) log((i + z)/(i - z))
      -     *  
      -     * 
      + *

      + * {@code atan(z) = (i/2) log((i + z)/(i - z))} + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the - * input argument is {@code NaN} or infinite. + * input argument is {@code NaN} or infinite.

      * * @return the inverse tangent of this complex number * @since 1.2 @@ -712,27 +697,24 @@ public class Complex implements FieldElement, Serializable { /** * Compute the * - * cosine - * of this complex number. + * cosine of this complex number. * Implements the formula: - *
      -     *  
      -     *   cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i
      -     *  
      -     * 
      + *

      + * {@code cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i} + *

      * where the (real) functions on the right-hand side are * {@link FastMath#sin}, {@link FastMath#cos}, * {@link FastMath#cosh} and {@link FastMath#sinh}. - *
      + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
      + *

      * Infinite values in real or imaginary parts of the input may result in - * infinite or NaN values returned in parts of the result. + * infinite or NaN values returned in parts of the result.

      *
            *  Examples:
            *  
      -     *   cos(1 ± INFINITY i) = 1 ∓ INFINITY i
      +     *   cos(1 ± INFINITY i) = 1 \u2213 INFINITY i
            *   cos(±INFINITY + i) = NaN + NaN i
            *   cos(±INFINITY ± INFINITY i) = NaN + NaN i
            *  
      @@ -757,16 +739,16 @@ public class Complex implements FieldElement, Serializable  {
            * Implements the formula:
            * 
            *  
      -     *   cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i}
      +     *   cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i
            *  
            * 
      * where the (real) functions on the right-hand side are * {@link FastMath#sin}, {@link FastMath#cos}, * {@link FastMath#cosh} and {@link FastMath#sinh}. - *
      + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
      + *

      * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. *
      @@ -803,10 +785,10 @@ public class Complex implements FieldElement, Serializable  {
            * where the (real) functions on the right-hand side are
            * {@link FastMath#exp}, {@link FastMath#cos}, and
            * {@link FastMath#sin}.
      -     * 
      + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
      + *

      * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. *
      @@ -845,10 +827,10 @@ public class Complex implements FieldElement, Serializable  {
            * where ln on the right hand side is {@link FastMath#log},
            * {@code |a + bi|} is the modulus, {@link Complex#abs},  and
            * {@code arg(a + bi) = }{@link FastMath#atan2}(b, a).
      -     * 
      + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
      + *

      * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. *
      @@ -886,13 +868,13 @@ public class Complex implements FieldElement, Serializable  {
            * 
      * where {@code exp} and {@code log} are {@link #exp} and * {@link #log}, respectively. - *
      + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN} or infinite, or if {@code y} - * equals {@link Complex#ZERO}. + * equals {@link Complex#ZERO}.

      * * @param x exponent to which this {@code Complex} is to be raised. - * @return this{@code x}. + * @return thisx. * @throws NullArgumentException if x is {@code null}. * @since 1.2 */ @@ -927,10 +909,10 @@ public class Complex implements FieldElement, Serializable { * where the (real) functions on the right-hand side are * {@link FastMath#sin}, {@link FastMath#cos}, * {@link FastMath#cosh} and {@link FastMath#sinh}. - *
      + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
      + *

      * Infinite values in real or imaginary parts of the input may result in * infinite or {@code NaN} values returned in parts of the result. *

      @@ -967,10 +949,10 @@ public class Complex implements FieldElement, Serializable  {
            * where the (real) functions on the right-hand side are
            * {@link FastMath#sin}, {@link FastMath#cos},
            * {@link FastMath#cosh} and {@link FastMath#sinh}.
      -     * 
      + *

      * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
      + *

      * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. *

      @@ -1008,10 +990,10 @@ public class Complex implements FieldElement, Serializable  {
            * 
    • {@code |a + bi| = }{@link Complex#abs}(a + bi)
    • *
    • {@code sign(b) = }{@link FastMath#copySign(double,double) copySign(1d, b)} *
    - *
    + *

    * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
    + *

    * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. *
    @@ -1053,10 +1035,10 @@ public class Complex implements FieldElement, Serializable  {
          * number.
          * Computes the result directly as
          * {@code sqrt(ONE.subtract(z.multiply(z)))}.
    -     * 
    + *

    * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
    + *

    * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. * @@ -1080,10 +1062,10 @@ public class Complex implements FieldElement, Serializable { * where the (real) functions on the right-hand side are * {@link FastMath#sin}, {@link FastMath#cos}, {@link FastMath#cosh} and * {@link FastMath#sinh}. - *
    + *

    * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
    + *

    * Infinite (or critical) values in real or imaginary parts of the input may * result in infinite or NaN values returned in parts of the result. *
    @@ -1131,10 +1113,10 @@ public class Complex implements FieldElement, Serializable  {
          * where the (real) functions on the right-hand side are
          * {@link FastMath#sin}, {@link FastMath#cos}, {@link FastMath#cosh} and
          * {@link FastMath#sinh}.
    -     * 
    + *

    * Returns {@link Complex#NaN} if either real or imaginary part of the * input argument is {@code NaN}. - *
    + *

    * Infinite values in real or imaginary parts of the input may result in * infinite or NaN values returned in parts of the result. *
    @@ -1177,7 +1159,7 @@ public class Complex implements FieldElement, Serializable  {
          * The value returned is between -PI (not inclusive)
          * and PI (inclusive), with negative values returned for numbers with
          * negative imaginary parts.
    -     * 
    + *

    * If either real or imaginary part (or both) is NaN, NaN is returned. * Infinite parts are handled as {@code Math.atan2} handles them, * essentially treating finite parts as zero in the presence of an @@ -1202,14 +1184,14 @@ public class Complex implements FieldElement, Serializable { * for {@code k=0, 1, ..., n-1}, where {@code abs} and {@code phi} * are respectively the {@link #abs() modulus} and * {@link #getArgument() argument} of this complex number. - *
    + *

    * If one or both parts of this complex number is NaN, a list with just * one element, {@link #NaN} is returned. * if neither part is NaN, but at least one part is infinite, the result * is a one-element list containing {@link #INF}. * * @param n Degree of root. - * @return a List of all {@code n}-th roots of {@code this}. + * @return a List of all {@code n}-th roots of {@code this}. * @throws NotPositiveException if {@code n <= 0}. * @since 2.0 */ http://git-wip-us.apache.org/repos/asf/commons-math/blob/a5ccf599/src/main/java/org/apache/commons/math3/util/Precision.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/util/Precision.java b/src/main/java/org/apache/commons/math3/util/Precision.java index 49fd15c..180ad4f 100644 --- a/src/main/java/org/apache/commons/math3/util/Precision.java +++ b/src/main/java/org/apache/commons/math3/util/Precision.java @@ -99,7 +99,8 @@ public class Precision { * @param eps the amount of error to allow when checking for equality * @return

    • 0 if {@link #equals(double, double, double) equals(x, y, eps)}
    • *
    • < 0 if !{@link #equals(double, double, double) equals(x, y, eps)} && x < y
    • - *
    • > 0 if !{@link #equals(double, double, double) equals(x, y, eps)} && x > y
    + *
  • > 0 if !{@link #equals(double, double, double) equals(x, y, eps)} && x > y or + * either argument is NaN
  • */ public static int compareTo(double x, double y, double eps) { if (equals(x, y, eps)) { @@ -117,7 +118,7 @@ public class Precision { * point numbers are considered equal. * Adapted from - * Bruce Dawson + * Bruce Dawson. Returns {@code false} if either of the arguments is NaN. * * @param x first value * @param y second value @@ -125,7 +126,8 @@ public class Precision { * values between {@code x} and {@code y}. * @return
    • 0 if {@link #equals(double, double, int) equals(x, y, maxUlps)}
    • *
    • < 0 if !{@link #equals(double, double, int) equals(x, y, maxUlps)} && x < y
    • - *
    • > 0 if !{@link #equals(double, double, int) equals(x, y, maxUlps)} && x > y
    + *
  • > 0 if !{@link #equals(double, double, int) equals(x, y, maxUlps)} && x > y + * or either argument is NaN
  • */ public static int compareTo(final double x, final double y, final int maxUlps) { if (equals(x, y, maxUlps)) { @@ -149,7 +151,7 @@ public class Precision { } /** - * Returns true if both arguments are NaN or neither is NaN and they are + * Returns true if both arguments are NaN or they are * equal as defined by {@link #equals(float,float) equals(x, y, 1)}. * * @param x first value @@ -162,8 +164,9 @@ public class Precision { } /** - * Returns true if both arguments are equal or within the range of allowed - * error (inclusive). + * Returns true if the arguments are equal or within the range of allowed + * error (inclusive). Returns {@code false} if either of the arguments + * is NaN. * * @param x first value * @param y second value @@ -176,7 +179,7 @@ public class Precision { } /** - * Returns true if both arguments are NaN or are equal or within the range + * Returns true if the arguments are both NaN, are equal, or are within the range * of allowed error (inclusive). * * @param x first value @@ -191,14 +194,14 @@ public class Precision { } /** - * Returns true if both arguments are equal or within the range of allowed + * Returns true if the arguments are equal or within the range of allowed * error (inclusive). * Two float numbers are considered equal if there are {@code (maxUlps - 1)} * (or fewer) floating point numbers between them, i.e. two adjacent floating * point numbers are considered equal. * Adapted from - * Bruce Dawson + * Bruce Dawson. Returns {@code false} if either of the arguments is NaN. * * @param x first value * @param y second value @@ -242,7 +245,7 @@ public class Precision { } /** - * Returns true if both arguments are NaN or if they are equal as defined + * Returns true if the arguments are both NaN or if they are equal as defined * by {@link #equals(float,float,int) equals(x, y, maxUlps)}. * * @param x first value @@ -270,7 +273,7 @@ public class Precision { } /** - * Returns true if both arguments are NaN or neither is NaN and they are + * Returns true if the arguments are both NaN or they are * equal as defined by {@link #equals(double,double) equals(x, y, 1)}. * * @param x first value @@ -285,7 +288,8 @@ public class Precision { /** * Returns {@code true} if there is no double value strictly between the * arguments or the difference between them is within the range of allowed - * error (inclusive). + * error (inclusive). Returns {@code false} if either of the arguments + * is NaN. * * @param x First value. * @param y Second value. @@ -299,8 +303,9 @@ public class Precision { /** * Returns {@code true} if there is no double value strictly between the - * arguments or the relative difference between them is smaller or equal - * to the given tolerance. + * arguments or the relative difference between them is less than or equal + * to the given tolerance. Returns {@code false} if either of the arguments + * is NaN. * * @param x First value. * @param y Second value. @@ -321,7 +326,7 @@ public class Precision { } /** - * Returns true if both arguments are NaN or are equal or within the range + * Returns true if the arguments are both NaN, are equal or are within the range * of allowed error (inclusive). * * @param x first value @@ -336,7 +341,7 @@ public class Precision { } /** - * Returns true if both arguments are equal or within the range of allowed + * Returns true if the arguments are equal or within the range of allowed * error (inclusive). *

    * Two float numbers are considered equal if there are {@code (maxUlps - 1)} @@ -346,7 +351,7 @@ public class Precision { *

    * Adapted from - * Bruce Dawson + * Bruce Dawson. Returns {@code false} if either of the arguments is NaN. *

    * * @param x first value http://git-wip-us.apache.org/repos/asf/commons-math/blob/a5ccf599/src/test/java/org/apache/commons/math3/complex/ComplexTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/complex/ComplexTest.java b/src/test/java/org/apache/commons/math3/complex/ComplexTest.java index 7cf7962..bb34a48 100644 --- a/src/test/java/org/apache/commons/math3/complex/ComplexTest.java +++ b/src/test/java/org/apache/commons/math3/complex/ComplexTest.java @@ -565,6 +565,15 @@ public class ComplexTest { } @Test + public void testFloatingPointEqualsWithAllowedDeltaNaN() { + final Complex x = new Complex(0, Double.NaN); + final Complex y = new Complex(Double.NaN, 0); + Assert.assertFalse(Complex.equals(x, Complex.ZERO, 0.1)); + Assert.assertFalse(Complex.equals(x, x, 0.1)); + Assert.assertFalse(Complex.equals(x, y, 0.1)); + } + + @Test public void testFloatingPointEqualsWithRelativeTolerance() { final double tol = 1e-4; final double re = 1; @@ -577,6 +586,15 @@ public class ComplexTest { } @Test + public void testFloatingPointEqualsWithRelativeToleranceNaN() { + final Complex x = new Complex(0, Double.NaN); + final Complex y = new Complex(Double.NaN, 0); + Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, Complex.ZERO, 0.1)); + Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, x, 0.1)); + Assert.assertFalse(Complex.equalsWithRelativeTolerance(x, y, 0.1)); + } + + @Test public void testEqualsTrue() { Complex x = new Complex(3.0, 4.0); Complex y = new Complex(3.0, 4.0);