From f32f60c997d57ba70a977804cdfb07068557033f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 24 May 2006 17:14:45 +0000 Subject: re PR libgcj/27731 (Math cbrt(), cosh(), expm1(), hypot(), log1p(), sinh() and tanh() not implemented) PR libgcj/27731: * java/lang/natMath.cc (cbrt, cosh, expm1, hypot, log1p, sinh, tanh): New methods. * java/lang/Math.java (cbrt, cosh, expm1, hypot, log1p, sinh, tanh): Declare. From-SVN: r114045 --- libjava/java/lang/Math.java | 149 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 1 deletion(-) (limited to 'libjava/java/lang/Math.java') diff --git a/libjava/java/lang/Math.java b/libjava/java/lang/Math.java index 6f68480..836b8bd 100644 --- a/libjava/java/lang/Math.java +++ b/libjava/java/lang/Math.java @@ -1,5 +1,5 @@ /* java.lang.Math -- common mathematical functions, native allowed - Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -650,6 +650,87 @@ public final class Math /** *

+ * Take a cube root. If the argument is NaN, an infinity or + * zero, then the original value is returned. The returned result is + * within 1 ulp of the exact result. For a finite value, x, + * the cube root of -x is equal to the negation of the cube root + * of x. + *

+ *

+ * For a square root, use sqrt. For other roots, use + * pow(a, 1 / rootNumber). + *

+ * + * @param a the numeric argument + * @return the cube root of the argument + * @see #sqrt(double) + * @see #pow(double, double) + * @since 1.5 + */ + public static native double cbrt(double a); + + /** + *

+ * Returns the hyperbolic cosine of the given value. For a value, + * x, the hyperbolic cosine is (ex + + * e-x)/2 + * with e being Euler's number. The returned + * result is within 2.5 ulps of the exact result. + *

+ *

+ * If the supplied value is NaN, then the original value is + * returned. For either infinity, positive infinity is returned. + * The hyperbolic cosine of zero is 1.0. + *

+ * + * @param a the numeric argument + * @return the hyperbolic cosine of a. + * @since 1.5 + */ + public static native double cosh(double a); + + /** + *

+ * Returns ea - 1. For values close to 0, the + * result of expm1(a) + 1 tend to be much closer to the + * exact result than simply exp(x). The result is within + * 1 ulp of the exact result, and results are semi-monotonic. For finite + * inputs, the returned value is greater than or equal to -1.0. Once + * a result enters within half a ulp of this limit, the limit is returned. + *

+ *

+ * For NaN, positive infinity and zero, the original value + * is returned. Negative infinity returns a result of -1.0 (the limit). + *

+ * + * @param a the numeric argument + * @return ea - 1 + * @since 1.5 + */ + public static native double expm1(double a); + + /** + *

+ * Returns the hypotenuse, a2 + b2, + * without intermediate overflow or underflow. The returned result is + * within 1 ulp of the exact result. If one parameter is held constant, + * then the result in the other parameter is semi-monotonic. + *

+ *

+ * If either of the arguments is an infinity, then the returned result + * is positive infinity. Otherwise, if either argument is NaN, + * then NaN is returned. + *

+ * + * @param a the first parameter. + * @param b the second parameter. + * @return the hypotenuse matching the supplied parameters. + * @since 1.5 + */ + public static native double hypot(double a, double b); + + /** + *

* Returns the base 10 logarithm of the supplied value. The returned * result is within 1 ulp of the exact result, and the results are * semi-monotonic. @@ -670,6 +751,28 @@ public final class Math /** *

+ * Returns the natural logarithm resulting from the sum of the argument, + * a and 1. For values close to 0, the + * result of log1p(a) tend to be much closer to the + * exact result than simply log(1.0+a). The returned + * result is within 1 ulp of the exact result, and the results are + * semi-monotonic. + *

+ *

+ * Arguments of either NaN or less than -1 return + * NaN. An argument of positive infinity or zero + * returns the original argument. Negative infinity is returned from an + * argument of -1. + *

+ * + * @param a the numeric argument. + * @return the natural logarithm of a + 1. + * @since 1.5 + */ + public static native double log1p(double a); + + /** + *

* Returns the sign of the argument as follows: *

*