use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDBasicTest method testMultiplyDivide.
public void testMultiplyDivide() {
checkMultiplyDivide(DD.PI, DD.E, 1e-30);
checkMultiplyDivide(DD.TWO_PI, DD.E, 1e-30);
checkMultiplyDivide(DD.PI_2, DD.E, 1e-30);
checkMultiplyDivide(new DD(39.4), new DD(10), 1e-30);
}
use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDBasicTest method testSqrt.
public void testSqrt() {
// the appropriate error bound is determined empirically
checkSqrt(DD.PI, 1e-30);
checkSqrt(DD.E, 1e-30);
checkSqrt(new DD(999.0), 1e-28);
}
use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDBasicTest method checkAddMult2.
private void checkAddMult2(final DD dd) {
final DD sum = dd.add(dd);
final DD prod = dd.multiply(new DD(2.0));
checkErrorBound("AddMult2", sum, prod, 0.0);
}
use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDBasicTest method checkBinomialSquare.
/**
* Computes (a+b)^2 in two different ways and compares the result.
* For correct results, a and b should be integers.
*
* @param a
* @param b
*/
void checkBinomialSquare(final double a, final double b) {
// binomial square
final DD add = new DD(a);
final DD bdd = new DD(b);
final DD aPlusb = add.add(bdd);
final DD abSq = aPlusb.multiply(aPlusb);
// System.out.println("(a+b)^2 = " + abSq);
// expansion
final DD a2dd = add.multiply(add);
final DD b2dd = bdd.multiply(bdd);
final DD ab = add.multiply(bdd);
final DD sum = b2dd.add(ab).add(ab);
// System.out.println("2ab+b^2 = " + sum);
final DD diff = abSq.subtract(a2dd);
// System.out.println("(a+b)^2 - a^2 = " + diff);
final DD delta = diff.subtract(sum);
// System.out.println();
// System.out.println("A = " + a + ", B = " + b);
// System.out.println("[DD] 2ab+b^2 = " + sum + " (a+b)^2 - a^2 = "
// + diff + " delta = " + delta);
printBinomialSquareDouble(a, b);
final boolean isSame = diff.equals(sum);
assertTrue(isSame);
final boolean isDeltaZero = delta.isZero();
assertTrue(isDeltaZero);
}
use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDBasicTest method checkPow.
private void checkPow(final double x, final int exp, final double errBound) {
final DD xdd = new DD(x);
final DD pow = xdd.pow(exp);
// System.out.println("Pow(" + x + ", " + exp + ") = " + pow);
final DD pow2 = slowPow(xdd, exp);
final double err = pow.subtract(pow2).doubleValue();
final boolean isOK = err < errBound;
if (!isOK) {
// System.out.println("Test slowPow value " + pow2);
}
assertTrue(err <= errBound);
}
Aggregations