Search in sources :

Example 31 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class DDBasicTest method testAddMult2.

public void testAddMult2() {
    checkAddMult2(new DD(3));
    checkAddMult2(DD.PI);
}
Also used : DD(com.revolsys.geometry.math.DD)

Example 32 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class DDComputeTest method testPiByMachin.

public void testPiByMachin() {
    // System.out.println("--------------------------------");
    // System.out.println("Computing Pi by Machin's rule");
    final DD testE = computePiByMachin();
    final double err = Math.abs(testE.subtract(DD.PI).doubleValue());
    // System.out.println("Difference from DoubleDouble.PI = " + err);
    assertTrue(err < 8 * DD.EPS);
}
Also used : DD(com.revolsys.geometry.math.DD)

Example 33 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class DDComputeTest method computeEByTaylorSeries.

/**
 * Uses Taylor series to compute e
 *
 * e = 1 + 1 + 1/2! + 1/3! + 1/4! + ...
 *
 * @return an approximation to e
 */
private DD computeEByTaylorSeries() {
    DD s = DD.valueOf(2.0);
    DD t = DD.valueOf(1.0);
    double n = 1.0;
    int i = 0;
    while (t.doubleValue() > DD.EPS) {
        i++;
        n += 1.0;
        t = t.divide(DD.valueOf(n));
        s = s.add(t);
    // System.out.println(i + ": " + s);
    }
    return s;
}
Also used : DD(com.revolsys.geometry.math.DD)

Example 34 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class DDComputeTest method testEByTaylorSeries.

public void testEByTaylorSeries() {
    // System.out.println("--------------------------------");
    // System.out.println("Computing e by Taylor series");
    final DD testE = computeEByTaylorSeries();
    final double err = Math.abs(testE.subtract(DD.E).doubleValue());
    // System.out.println("Difference from DoubleDouble.E = " + err);
    assertTrue(err < 64 * DD.EPS);
}
Also used : DD(com.revolsys.geometry.math.DD)

Aggregations

DD (com.revolsys.geometry.math.DD)34 Stopwatch (com.revolsys.geometry.util.Stopwatch)3 Point (com.revolsys.geometry.model.Point)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1