You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2012/09/28 18:43:21 UTC

svn commit: r1391539 [2/2] - in /commons/sandbox/nabla/trunk/src: main/java/org/apache/commons/nabla/forward/analysis/ main/java/org/apache/commons/nabla/forward/arithmetic/ main/java/org/apache/commons/nabla/forward/functions/ main/java/org/apache/com...

Copied: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/LogGeneratorTest.java (from r1391537, commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/LogGeneratorTest.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/LogGeneratorTest.java?p2=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/LogGeneratorTest.java&p1=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/LogGeneratorTest.java&r1=1391537&r2=1391539&rev=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/LogGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/LogGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -14,14 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.forward.functions;
+package org.apache.commons.nabla.forward;
 
 import org.apache.commons.math3.analysis.UnivariateFunction;
 import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
 import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
+import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.nabla.AbstractMathTest;
 import org.apache.commons.nabla.DifferentiationException;
-import org.apache.commons.nabla.forward.ForwardModeDifferentiator;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -30,16 +30,16 @@ public class LogGeneratorTest extends Ab
     @Test
     public void testReference(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.log(t); }
+            public double value(double t) { return FastMath.log(t); }
             public double firstDerivative(double t) { return 1 / t; }
-        }, 0.1, 10, 50, 0.0);
+        }, 0.1, 10, 50, 3.0e-16);
     }
 
     @Test
     public void testSingularity() throws DifferentiationException {
         UnivariateDifferentiableFunction derivative =
             new ForwardModeDifferentiator().differentiate(new UnivariateFunction() {
-                public double value(double t) { return Math.log(t); }
+                public double value(double t) { return FastMath.log(t); }
             });
 
         double dPlus = derivative.value(new DerivativeStructure(1, 1, 0.0, 1.0)).getPartialDerivative(1);

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/LogGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/LogGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/PowGeneratorTest.java (from r1391537, commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/PowGeneratorTest.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/PowGeneratorTest.java?p2=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/PowGeneratorTest.java&p1=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/PowGeneratorTest.java&r1=1391537&r2=1391539&rev=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/PowGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/PowGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -14,8 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.forward.functions;
+package org.apache.commons.nabla.forward;
 
+import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.nabla.AbstractMathTest;
 import org.junit.Test;
 
@@ -24,24 +25,24 @@ public class PowGeneratorTest extends Ab
     @Test
     public void testReference1(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.pow(t, 3.0); }
-            public double firstDerivative(double t) { return 3 * Math.pow(t, 2.0); }
+            public double value(double t) { return FastMath.pow(t, 3.0); }
+            public double firstDerivative(double t) { return 3 * FastMath.pow(t, 2.0); }
         }, -2, 2, 50, 2e-15);
     }
 
     @Test
     public void testReference2(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.pow(3.0, t); }
-            public double firstDerivative(double t) { return Math.log(3) * Math.pow(3, t); }
+            public double value(double t) { return FastMath.pow(3.0, t); }
+            public double firstDerivative(double t) { return FastMath.log(3) * FastMath.pow(3, t); }
         }, -2, 2, 50, 0.0);
     }
 
     @Test
     public void testReference12(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.pow(t, t); }
-            public double firstDerivative(double t) { return (1 + Math.log(t)) * Math.pow(t, t); }
+            public double value(double t) { return FastMath.pow(t, t); }
+            public double firstDerivative(double t) { return (1 + FastMath.log(t)) * FastMath.pow(t, t); }
         }, 0.1, 10, 20, 0);
     }
 

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/PowGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/PowGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinGeneratorTest.java (from r1391537, commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SinGeneratorTest.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinGeneratorTest.java?p2=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinGeneratorTest.java&p1=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SinGeneratorTest.java&r1=1391537&r2=1391539&rev=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SinGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -14,8 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.forward.functions;
+package org.apache.commons.nabla.forward;
 
+import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.nabla.AbstractMathTest;
 import org.junit.Test;
 
@@ -24,9 +25,9 @@ public class SinGeneratorTest extends Ab
     @Test
     public void testReference(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.sin(t); }
-            public double firstDerivative(double t) { return Math.cos(t); }
-        }, 0, 2 * Math.PI, 20, 0.0);
+            public double value(double t) { return FastMath.sin(t); }
+            public double firstDerivative(double t) { return FastMath.cos(t); }
+        }, 0, 2 * FastMath.PI, 20, 2.0e-16);
     }
 
 }

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinhGeneratorTest.java (from r1391537, commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SinhGeneratorTest.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinhGeneratorTest.java?p2=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinhGeneratorTest.java&p1=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SinhGeneratorTest.java&r1=1391537&r2=1391539&rev=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SinhGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinhGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -14,8 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.forward.functions;
+package org.apache.commons.nabla.forward;
 
+import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.nabla.AbstractMathTest;
 import org.junit.Test;
 
@@ -24,9 +25,9 @@ public class SinhGeneratorTest extends A
     @Test
     public void testReference(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.sinh(t); }
-            public double firstDerivative(double t) { return Math.cosh(t); }
-        }, -10, 10, 50, 0.0);
+            public double value(double t) { return FastMath.sinh(t); }
+            public double firstDerivative(double t) { return FastMath.cosh(t); }
+        }, -10, 10, 50, 2.0e-16);
     }
 
 }

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinhGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SinhGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SqrtGeneratorTest.java (from r1391537, commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SqrtGeneratorTest.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SqrtGeneratorTest.java?p2=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SqrtGeneratorTest.java&p1=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SqrtGeneratorTest.java&r1=1391537&r2=1391539&rev=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SqrtGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SqrtGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -14,14 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.forward.functions;
+package org.apache.commons.nabla.forward;
 
 import org.apache.commons.math3.analysis.UnivariateFunction;
 import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
 import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
+import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.nabla.AbstractMathTest;
 import org.apache.commons.nabla.DifferentiationException;
-import org.apache.commons.nabla.forward.ForwardModeDifferentiator;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -30,16 +30,16 @@ public class SqrtGeneratorTest extends A
     @Test
     public void testReference(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.sqrt(t); }
-            public double firstDerivative(double t) { return 1 / (2 * Math.sqrt(t)); }
-        }, 0.001, 10, 50, 0.0);
+            public double value(double t) { return FastMath.sqrt(t); }
+            public double firstDerivative(double t) { return 1 / (2 * FastMath.sqrt(t)); }
+        }, 0.001, 10, 50, 2.0e-15);
     }
 
     @Test
     public void testSingularity() throws DifferentiationException {
         UnivariateDifferentiableFunction derivative =
             new ForwardModeDifferentiator().differentiate(new UnivariateFunction() {
-                public double value(double t) { return Math.sqrt(t); }
+                public double value(double t) { return FastMath.sqrt(t); }
             });
 
         double dPlus = derivative.value(new DerivativeStructure(1, 1, 0.0, 1.0)).getPartialDerivative(1);

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SqrtGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/SqrtGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanGeneratorTest.java (from r1391537, commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/TanGeneratorTest.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanGeneratorTest.java?p2=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanGeneratorTest.java&p1=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/TanGeneratorTest.java&r1=1391537&r2=1391539&rev=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/TanGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -14,8 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.forward.functions;
+package org.apache.commons.nabla.forward;
 
+import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.nabla.AbstractMathTest;
 import org.junit.Test;
 
@@ -24,9 +25,9 @@ public class TanGeneratorTest extends Ab
     @Test
     public void testReference(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.tan(t); }
-            public double firstDerivative(double t) { return 1 + Math.tan(t) * Math.tan(t); }
-        }, 0, 2 * Math.PI, 20, 0.0);
+            public double value(double t) { return FastMath.tan(t); }
+            public double firstDerivative(double t) { return 1 + FastMath.tan(t) * FastMath.tan(t); }
+        }, 0, 2 * FastMath.PI, 20, 0.0);
     }
 
 }

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanhGeneratorTest.java (from r1391537, commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/TanhGeneratorTest.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanhGeneratorTest.java?p2=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanhGeneratorTest.java&p1=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/TanhGeneratorTest.java&r1=1391537&r2=1391539&rev=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/TanhGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanhGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -14,8 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.forward.functions;
+package org.apache.commons.nabla.forward;
 
+import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.nabla.AbstractMathTest;
 import org.junit.Test;
 
@@ -24,9 +25,9 @@ public class TanhGeneratorTest extends A
     @Test
     public void testReference(){
         checkReference(new ReferenceFunction() {
-            public double value(double t) { return Math.tanh(t); }
-            public double firstDerivative(double t) { return 1 - Math.tanh(t) * Math.tanh(t); }
-        }, -10, 10, 50, 0.0);
+            public double value(double t) { return FastMath.tanh(t); }
+            public double firstDerivative(double t) { return 1 - FastMath.tanh(t) * FastMath.tanh(t); }
+        }, -10, 10, 50, 2.0e-16);
     }
 
 }

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanhGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/TanhGeneratorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java?rev=1391539&r1=1391538&r2=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -26,7 +26,7 @@ public class DDivGeneratorTest extends A
         checkReference(new ReferenceFunction() {
             public double value(double t) { return t / 5; }
             public double firstDerivative(double t) { return 1.0 / 5.0; }
-        }, 0.1, 10, 30, 0.0);
+        }, 0.1, 10, 30, 1.0e-20);
     }
 
     @Test
@@ -34,7 +34,7 @@ public class DDivGeneratorTest extends A
         checkReference(new ReferenceFunction() {
             public double value(double t) { return 5 / t; }
             public double firstDerivative(double t) { return -5 / (t * t); }
-        }, 0.5, 10, 30, 1e-15);
+        }, 0.5, 10, 30, 9e-16);
     }
 
     @Test
@@ -42,7 +42,7 @@ public class DDivGeneratorTest extends A
         checkReference(new ReferenceFunction() {
             public double value(double t) { return t / t; }
             public double firstDerivative(double t) { return 0; }
-        }, 0.1, 10, 30, 0.0);
+        }, 0.1, 10, 30, 2.0e-16);
     }
 
 }

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java?rev=1391539&r1=1391538&r2=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -26,7 +26,7 @@ public class DMulGeneratorTest extends A
         checkReference(new ReferenceFunction() {
             public double value(double t) { return t * 5; }
             public double firstDerivative(double t) { return 5; }
-        }, -0.99, 0.99, 30, 0.0);
+        }, -0.99, 0.99, 30, 1.0e-20);
     }
 
     @Test
@@ -34,7 +34,7 @@ public class DMulGeneratorTest extends A
         checkReference(new ReferenceFunction() {
             public double value(double t) { return 5 * t; }
             public double firstDerivative(double t) { return 5; }
-        }, -0.99, 0.99, 30, 0.0);
+        }, -0.99, 0.99, 30, 1.0e-20);
     }
 
     @Test
@@ -42,7 +42,7 @@ public class DMulGeneratorTest extends A
         checkReference(new ReferenceFunction() {
             public double value(double t) { return t * t; }
             public double firstDerivative(double t) { return 2 * t; }
-        }, -0.99, 0.99, 30, 0.0);
+        }, -0.99, 0.99, 30, 1.0e-20);
     }
 
 }

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DRemGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DRemGeneratorTest.java?rev=1391539&r1=1391538&r2=1391539&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DRemGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DRemGeneratorTest.java Fri Sep 28 16:43:18 2012
@@ -26,7 +26,7 @@ public class DRemGeneratorTest extends A
         checkReference(new ReferenceFunction() {
             public double value(double t) { return t % 5; }
             public double firstDerivative(double t) { return 1.0; }
-        }, 0.1, 10, 30, 0.0);
+        }, 0.1, 10, 30, 1.0e-20);
     }
 
     @Test
@@ -42,7 +42,7 @@ public class DRemGeneratorTest extends A
         checkReference(new ReferenceFunction() {
             public double value(double t) { return t % t; }
             public double firstDerivative(double t) { return 0; }
-        }, 0.1, 10, 30, 0.0);
+        }, 0.1, 10, 30, 1.0e-20);
     }
 
 }