Java Code Examples for org.apache.commons.math3.util.FastMath#nextUp()

The following examples show how to use org.apache.commons.math3.util.FastMath#nextUp() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComplexTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testFloatingPointEquals() {
    double re = -3.21;
    double im = 456789e10;

    final Complex x = new Complex(re, im);
    Complex y = new Complex(re, im);

    Assert.assertTrue(x.equals(y));
    Assert.assertTrue(Complex.equals(x, y));

    final int maxUlps = 5;
    for (int i = 0; i < maxUlps; i++) {
        re = FastMath.nextUp(re);
        im = FastMath.nextUp(im);
    }
    y = new Complex(re, im);
    Assert.assertTrue(Complex.equals(x, y, maxUlps));

    re = FastMath.nextUp(re);
    im = FastMath.nextUp(im);
    y = new Complex(re, im);
    Assert.assertFalse(Complex.equals(x, y, maxUlps));
}
 
Example 2
Source File: ComplexTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testFloatingPointEquals() {
    double re = -3.21;
    double im = 456789e10;

    final Complex x = new Complex(re, im);
    Complex y = new Complex(re, im);

    Assert.assertTrue(x.equals(y));
    Assert.assertTrue(Complex.equals(x, y));

    final int maxUlps = 5;
    for (int i = 0; i < maxUlps; i++) {
        re = FastMath.nextUp(re);
        im = FastMath.nextUp(im);
    }
    y = new Complex(re, im);
    Assert.assertTrue(Complex.equals(x, y, maxUlps));

    re = FastMath.nextUp(re);
    im = FastMath.nextUp(im);
    y = new Complex(re, im);
    Assert.assertFalse(Complex.equals(x, y, maxUlps));
}
 
Example 3
Source File: QuaternionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public final void testObjectEquals() {
    final double one = 1;
    final Quaternion q1 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q1.equals(q1));

    final Quaternion q2 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q2.equals(q1));

    final Quaternion q3 = new Quaternion(one, FastMath.nextUp(one), one, one);
    Assert.assertFalse(q3.equals(q1));
}
 
Example 4
Source File: QuaternionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public final void testObjectEquals() {
    final double one = 1;
    final Quaternion q1 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q1.equals(q1));

    final Quaternion q2 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q2.equals(q1));

    final Quaternion q3 = new Quaternion(one, FastMath.nextUp(one), one, one);
    Assert.assertFalse(q3.equals(q1));
}
 
Example 5
Source File: QuaternionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public final void testObjectEquals() {
    final double one = 1;
    final Quaternion q1 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q1.equals(q1));

    final Quaternion q2 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q2.equals(q1));

    final Quaternion q3 = new Quaternion(one, FastMath.nextUp(one), one, one);
    Assert.assertFalse(q3.equals(q1));
}
 
Example 6
Source File: QuaternionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public final void testObjectEquals() {
    final double one = 1;
    final Quaternion q1 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q1.equals(q1));

    final Quaternion q2 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q2.equals(q1));

    final Quaternion q3 = new Quaternion(one, FastMath.nextUp(one), one, one);
    Assert.assertFalse(q3.equals(q1));
}
 
Example 7
Source File: QuaternionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public final void testObjectEquals() {
    final double one = 1;
    final Quaternion q1 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q1.equals(q1));

    final Quaternion q2 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q2.equals(q1));

    final Quaternion q3 = new Quaternion(one, FastMath.nextUp(one), one, one);
    Assert.assertFalse(q3.equals(q1));
}
 
Example 8
Source File: QuaternionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public final void testObjectEquals() {
    final double one = 1;
    final Quaternion q1 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q1.equals(q1));

    final Quaternion q2 = new Quaternion(one, one, one, one);
    Assert.assertTrue(q2.equals(q1));

    final Quaternion q3 = new Quaternion(one, FastMath.nextUp(one), one, one);
    Assert.assertFalse(q3.equals(q1));
}