harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r440604 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/ main/native/luni/linux/ main/native/luni/shared/ main/native/luni/windows/ test/java/org/apache/harmony/luni/tests/java/lang/
Date Wed, 06 Sep 2006 03:58:06 GMT
Author: pyang
Date: Tue Sep  5 20:58:05 2006
New Revision: 440604

URL: http://svn.apache.org/viewvc?view=rev&rev=440604
Log:
Patch applied for HARMONY-1388 ([classlib][luni] new method java.lang.Math.cbrt, java.lang.StrictMath.cbrt)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StrictMath.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/linux/libhyluni.exp
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/math.c
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/hyluni.def
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java?view=diff&rev=440604&r1=440603&r2=440604
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java
Tue Sep  5 20:58:05 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -129,6 +129,17 @@
 	 * @return the arc tangent of d1/d2.
 	 */
 	public static native double atan2(double d1, double d2);
+    
+    /**
+     * Answers the closest double approximation of the cube root of the
+     * argument. The final result should be within 1ulp of the one returned by
+     * StrictMath.
+     * 
+     * @param d
+     *            the value to compute cube root of
+     * @return the cube root of the argument.
+     */
+    public static native double cbrt(double d);
 
 	/**
 	 * Answers the double conversion of the most negative (i.e. closest to

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StrictMath.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StrictMath.java?view=diff&rev=440604&r1=440603&r2=440604
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StrictMath.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StrictMath.java
Tue Sep  5 20:58:05 2006
@@ -1,4 +1,4 @@
-/* Copyright 2001, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2001, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -134,6 +134,16 @@
 	 * @return the arc tangent of d1/d2.
 	 */
 	public static native double atan2(double d1, double d2);
+    
+     /**
+     * Answers the closest double approximation of the cube root of the
+     * argument. 
+     * 
+     * @param d
+     *             the value to compute cube root of
+     * @return the cube root of the argument.
+     */
+    public static native double cbrt(double d);
 
 	/**
 	 * Answers the double conversion of the most negative (i.e. closest to

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/linux/libhyluni.exp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/linux/libhyluni.exp?view=diff&rev=440604&r1=440603&r2=440604
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/linux/libhyluni.exp
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/linux/libhyluni.exp
Tue Sep  5 20:58:05 2006
@@ -94,6 +94,7 @@
 		Java_java_lang_Math_asin;
 		Java_java_lang_Math_atan;
 		Java_java_lang_Math_atan2;
+		Java_java_lang_Math_cbrt;
 		Java_java_lang_Math_ceil;
 		Java_java_lang_Math_cos;
 		Java_java_lang_Math_exp;
@@ -110,6 +111,7 @@
 		Java_java_lang_StrictMath_asin;
 		Java_java_lang_StrictMath_atan;
 		Java_java_lang_StrictMath_atan2;
+		Java_java_lang_StrictMath_cbrt;
 		Java_java_lang_StrictMath_ceil;
 		Java_java_lang_StrictMath_cos;
 		Java_java_lang_StrictMath_exp;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/math.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/math.c?view=diff&rev=440604&r1=440603&r2=440604
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/math.c
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/math.c
Tue Sep  5 20:58:05 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
 jdouble internal_tan (jdouble arg1);
 jdouble internal_sin (jdouble arg1);
 jdouble internal_rint (jdouble arg1);
+jdouble internal_cbrt (jdouble arg1);
 
 extern scaleUpDouble (double *, int);
 
@@ -92,6 +93,16 @@
 }
 
 jdouble
+internal_cbrt (jdouble arg1)
+{
+  jdouble result;
+
+  result = fdlibm_cbrt (arg1);
+
+  return result;
+}
+
+jdouble
 internal_ceil (jdouble arg1)
 {
   jdouble result;
@@ -237,6 +248,18 @@
                            jdouble arg2)
 {
   return internal_atan2 (arg1, arg2);
+}
+
+jdouble JNICALL
+Java_java_lang_StrictMath_cbrt (JNIEnv * env, jclass jclazz, jdouble arg1)
+{
+  return internal_cbrt (arg1);
+}
+
+jdouble JNICALL
+Java_java_lang_Math_cbrt (JNIEnv * env, jclass jclazz, jdouble arg1)
+{
+  return internal_cbrt (arg1);
 }
 
 jdouble JNICALL

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/hyluni.def
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/hyluni.def?view=diff&rev=440604&r1=440603&r2=440604
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/hyluni.def
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/hyluni.def
Tue Sep  5 20:58:05 2006
@@ -87,6 +87,7 @@
 	Java_java_lang_Math_asin
 	Java_java_lang_Math_atan
 	Java_java_lang_Math_atan2
+	Java_java_lang_Math_cbrt
 	Java_java_lang_Math_ceil
 	Java_java_lang_Math_cos
 	Java_java_lang_Math_exp
@@ -103,6 +104,7 @@
 	Java_java_lang_StrictMath_asin
 	Java_java_lang_StrictMath_atan
 	Java_java_lang_StrictMath_atan2
+	Java_java_lang_StrictMath_cbrt
 	Java_java_lang_StrictMath_ceil
 	Java_java_lang_StrictMath_cos
 	Java_java_lang_StrictMath_exp

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java?view=diff&rev=440604&r1=440603&r2=440604
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/MathTest.java
Tue Sep  5 20:58:05 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -112,6 +112,46 @@
 		assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
 				&& answer >= 9.9999999999999983E-1);
 	}
+    
+     /**
+     * @tests java.lang.Math#cbrt(double)
+     */
+    @SuppressWarnings("boxing")
+    public void test_cbrt_D() {
+        //Test for special situations
+        assertEquals("Should return Double.NaN", Double.NaN, Math
+                .cbrt(Double.NaN));
+        assertEquals("Should return Double.POSITIVE_INFINITY",
+                Double.POSITIVE_INFINITY, Math
+                        .cbrt(Double.POSITIVE_INFINITY));
+        assertEquals("Should return Double.NEGATIVE_INFINITY",
+                Double.NEGATIVE_INFINITY, Math
+                        .cbrt(Double.NEGATIVE_INFINITY));
+        assertEquals("Should return 0.0", 0.0, Math.cbrt(0.0));
+        assertEquals("Should return +0.0", +0.0, Math.cbrt(+0.0));
+        assertEquals("Should return -0.0", -0.0, Math.cbrt(-0.0));
+
+        assertEquals("Should return 3.0", 3.0, Math.cbrt(27.0));
+        assertEquals("Should return 23.111993172558684", 23.111993172558684,
+                Math.cbrt(12345.6));
+        assertEquals("Should return 5.643803094122362E102",
+                5.643803094122362E102, Math.cbrt(Double.MAX_VALUE));
+        assertEquals("Should return 0.01", 0.01, Math.cbrt(0.000001));
+
+        assertEquals("Should return -3.0", -3.0, Math.cbrt(-27.0));
+        assertEquals("Should return -23.111993172558684", -23.111993172558684,
+                Math.cbrt(-12345.6));
+        assertEquals("Should return 1.7031839360032603E-108",
+                1.7031839360032603E-108, Math.cbrt(Double.MIN_VALUE));
+        assertEquals("Should return -0.01", -0.01, Math.cbrt(-0.000001));
+        
+        try{
+            Math.cbrt((Double)null);
+            fail("Should throw NullPointerException");
+        }catch(NullPointerException e){
+            //expected
+        }
+    }
 
 	/**
 	 * @tests java.lang.Math#ceil(double)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java?view=diff&rev=440604&r1=440603&r2=440604
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/StrictMathTest.java
Tue Sep  5 20:58:05 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -108,6 +108,46 @@
 		assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
 				&& answer >= 9.9999999999999983E-1);
 	}
+    
+    /**
+     * @tests java.lang.StrictMath#cbrt(double)
+     */
+    @SuppressWarnings("boxing")
+    public void test_cbrt_D() {
+        // Test for special situations
+        assertEquals("Should return Double.NaN", Double.NaN, StrictMath
+                .cbrt(Double.NaN));
+        assertEquals("Should return Double.POSITIVE_INFINITY",
+                Double.POSITIVE_INFINITY, StrictMath
+                        .cbrt(Double.POSITIVE_INFINITY));
+        assertEquals("Should return Double.NEGATIVE_INFINITY",
+                Double.NEGATIVE_INFINITY, StrictMath
+                        .cbrt(Double.NEGATIVE_INFINITY));
+        assertEquals("Should return 0.0", 0.0, StrictMath.cbrt(0.0));
+        assertEquals("Should return +0.0", +0.0, StrictMath.cbrt(+0.0));
+        assertEquals("Should return -0.0", -0.0, StrictMath.cbrt(-0.0));
+
+        assertEquals("Should return 3.0", 3.0, StrictMath.cbrt(27.0));
+        assertEquals("Should return 23.111993172558684", 23.111993172558684,
+                StrictMath.cbrt(12345.6));
+        assertEquals("Should return 5.643803094122362E102",
+                5.643803094122362E102, StrictMath.cbrt(Double.MAX_VALUE));
+        assertEquals("Should return 0.01", 0.01, StrictMath.cbrt(0.000001));
+
+        assertEquals("Should return -3.0", -3.0, StrictMath.cbrt(-27.0));
+        assertEquals("Should return -23.111993172558684", -23.111993172558684,
+                StrictMath.cbrt(-12345.6));
+        assertEquals("Should return 1.7031839360032603E-108",
+                1.7031839360032603E-108, StrictMath.cbrt(Double.MIN_VALUE));
+        assertEquals("Should return -0.01", -0.01, StrictMath.cbrt(-0.000001));
+        
+        try{
+            StrictMath.cbrt((Double)null);
+            fail("Should throw NullPointerException");
+        }catch(NullPointerException e){
+            //expected
+        }
+    }
 
 	/**
 	 * @tests java.lang.StrictMath#ceil(double)



Mime
View raw message