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 2008/04/15 15:25:35 UTC

svn commit: r648243 [2/2] - in /commons/sandbox/nabla/trunk/src/test: ./ java/ java/org/ java/org/apache/ java/org/apache/commons/ java/org/apache/commons/nabla/ java/org/apache/commons/nabla/automatic/ java/org/apache/commons/nabla/automatic/analysis/...

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/HypotGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/HypotGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/HypotGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/HypotGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class HypotGeneratorTest extends AbstractMathTest {
+
+    public void testReference1(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.hypot(t, 3.0); }
+            public double fPrime(double t) { return t / Math.hypot(t, 3.0); }
+        }, -2, 2, 50, 2e-15);
+    }
+
+    public void testReference2(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.hypot(3.0, t); }
+            public double fPrime(double t) { return t / Math.hypot(t, 3.0); }
+        }, -2, 2, 50, 0.0);
+    }
+
+    public void testReference12Aligned(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.hypot(t, t); }
+            public double fPrime(double t) { return Math.sqrt(2); }
+        }, 0.1, 10, 20, 3.0e-16);
+    }
+
+    public void testReference12Shifted(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.hypot(t, t + 1); }
+            public double fPrime(double t) { return (2 * t + 1) / Math.hypot(t, t + 1); }
+        }, 0.1, 10, 20, 3.0e-16);
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/HypotGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log10GeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log10GeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log10GeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log10GeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class Log10GeneratorTest extends AbstractMathTest {
+
+    public void testReference(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.log10(t); }
+            public double fPrime(double t) { return 1 / (Math.log(10) * t); }
+        }, 0.1, 10, 50, 0.0);
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log10GeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log1pGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log1pGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log1pGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log1pGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class Log1pGeneratorTest extends AbstractMathTest {
+
+    public void testReference(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.log1p(t); }
+            public double fPrime(double t) { return 1 / (1 + t); }
+        }, -0.2, 0.2, 50, 0.0);
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log1pGeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/LogGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/LogGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/LogGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/LogGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class LogGeneratorTest extends AbstractMathTest {
+
+    public void testReference(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.log(t); }
+            public double fPrime(double t) { return 1 / t; }
+        }, 0.1, 10, 50, 0.0);
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/PowGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/PowGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/PowGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/PowGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class PowGeneratorTest extends AbstractMathTest {
+
+    public void testReference1(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.pow(t, 3.0); }
+            public double fPrime(double t) { return 3 * Math.pow(t, 2.0); }
+        }, -2, 2, 50, 2e-15);
+    }
+
+    public void testReference2(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.pow(3.0, t); }
+            public double fPrime(double t) { return Math.log(3) * Math.pow(3, t); }
+        }, -2, 2, 50, 0.0);
+    }
+
+    public void testReference12(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.pow(t, t); }
+            public double fPrime(double t) { return (1 + Math.log(t)) * Math.pow(t, t); }
+        }, 0.1, 10, 20, 0);
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class SinGeneratorTest extends AbstractMathTest {
+
+    public void testReference(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.sin(t); }
+            public double fPrime(double t) { return Math.cos(t); }
+        }, 0, 2 * Math.PI, 20, 0.0);
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinhGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinhGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinhGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinhGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class SinhGeneratorTest extends AbstractMathTest {
+
+    public void testReference(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.sinh(t); }
+            public double fPrime(double t) { return Math.cosh(t); }
+        }, -10, 10, 50, 0.0);
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SqrtGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SqrtGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SqrtGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SqrtGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class SqrtGeneratorTest extends AbstractMathTest {
+
+    public void testReference(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.sqrt(t); }
+            public double fPrime(double t) { return 1 / (2 * Math.sqrt(t)); }
+        }, 0.001, 10, 50, 0.0);
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class TanGeneratorTest extends AbstractMathTest {
+
+    public void testReference(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.tan(t); }
+            public double fPrime(double t) { return 1 + Math.tan(t) * Math.tan(t); }
+        }, 0, 2 * Math.PI, 20, 0.0);
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanhGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanhGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanhGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanhGeneratorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class TanhGeneratorTest extends AbstractMathTest {
+
+    public void testReference(){
+        checkReference(new ReferenceFunction() {
+            public double f(double t) { return Math.tanh(t); }
+            public double fPrime(double t) { return 1 - Math.tanh(t) * Math.tanh(t); }
+        }, -10, 10, 50, 0.0);
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.core;
+
+import org.apache.commons.nabla.AbstractStaticFunctionsTest;
+import org.apache.commons.nabla.core.DifferentialPair;
+
+public class DifferentialPairTest extends AbstractStaticFunctionsTest {
+
+    public void testConstant() {
+        DifferentialPair p = DifferentialPair.newConstant(1.5);
+        assertEquals(1.5, p.getU0(), 1.0e-15);
+        assertEquals(0.0, p.getU1(), 1.0e-15);
+    }
+
+    public void testVariable() {
+        DifferentialPair p = DifferentialPair.newVariable(1.5);
+        assertEquals(1.5, p.getU0(), 1.0e-15);
+        assertEquals(1.0, p.getU1(), 1.0e-15);
+    }
+
+    public void testConstructor() {
+        DifferentialPair p = new DifferentialPair(1.5, -1.3);
+        assertEquals(1.5, p.getU0(), 1.0e-15);
+        assertEquals(-1.3, p.getU1(), 1.0e-15);
+    }
+
+    public void testMonadicOperations() {
+        defaultMonadicTest("negate");
+        defaultMonadicTest("square");
+        defaultMonadicTest("cube");
+    }
+
+    public void testDiadicOperations() {
+        defaultDiadicTest("add");
+        defaultDiadicTest("subtract");
+        defaultDiadicTest("multiply");
+        defaultDiadicTest("divide");
+        checkDiadicFunction(getNablaClass(), getJavaClass(), "remainder",
+                            1023, 1024, 2, 250, 251, 2, 1.0e-15, 1e-10);
+    }
+
+    protected Class<?> getJavaClass() {
+        return SimpleOperations.class;
+    }
+
+    protected Class<?> getNablaClass() {
+        return DifferentialPair.class;
+    }
+
+    protected static class SimpleOperations {
+        public static double add(double a, int b) {
+            return a + b;
+        }
+
+        public static double add(int a, double b) {
+            return a + b;
+        }
+
+        public static double add(double a, long b) {
+            return a + b;
+        }
+
+        public static double add(long a, double b) {
+            return a + b;
+        }
+
+        public static double add(double a, double b) {
+            return a + b;
+        }
+
+        public static double subtract(double a, int b) {
+            return a - b;
+        }
+
+        public static double subtract(int a, double b) {
+            return a - b;
+        }
+
+        public static double subtract(double a, long b) {
+            return a - b;
+        }
+
+        public static double subtract(long a, double b) {
+            return a - b;
+        }
+
+        public static double subtract(double a, double b) {
+            return a - b;
+        }
+
+        public static double multiply(double a, int b) {
+            return a * b;
+        }
+
+        public static double multiply(int a, double b) {
+            return a * b;
+        }
+
+        public static double multiply(double a, long b) {
+            return a * b;
+        }
+
+        public static double multiply(long a, double b) {
+            return a * b;
+        }
+
+        public static double multiply(double a, double b) {
+            return a * b;
+        }
+
+        public static double divide(double a, int b) {
+            return a / b;
+        }
+
+        public static double divide(int a, double b) {
+            return a / b;
+        }
+
+        public static double divide(double a, long b) {
+            return a / b;
+        }
+
+        public static double divide(long a, double b) {
+            return a / b;
+        }
+
+        public static double divide(double a, double b) {
+            return a / b;
+        }
+
+        public static double remainder(double a, int b) {
+            return a % b;
+        }
+
+        public static double remainder(int a, double b) {
+            return a % b;
+        }
+
+        public static double remainder(double a, long b) {
+            return a % b;
+        }
+
+        public static double remainder(long a, double b) {
+            return a % b;
+        }
+
+        public static double remainder(double a, double b) {
+            return a % b;
+        }
+
+        public static double negate(double a) {
+            return -a;
+        }
+
+        public static double square(double a) {
+            return a * a;
+        }
+
+        public static double cube(double a) {
+            return a * a * a;
+        }
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.differences;
+
+import java.util.Random;
+
+import org.apache.commons.nabla.Polynomial;
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.core.DifferentialPair;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.apache.commons.nabla.core.UnivariateDerivative;
+import org.apache.commons.nabla.differences.FiniteDifferencesDifferentiator;
+
+import junit.framework.TestCase;
+
+public abstract class AbstractFiniteDifferencesTest extends TestCase {
+
+    protected abstract FiniteDifferencesDifferentiator buildDifferentiator(double h);
+    protected abstract int getOrder();
+
+    /** Check the reference implementation for polynomials. */
+    public void testReference() {
+
+        Polynomial legendre5  = new Polynomial(new double[] { 63, 0, -70, 0, 15, 0 });
+        assertEquals(17155.92466365559104, legendre5.f(Math.PI), 1.0e-9);
+        assertEquals(28626.24675148200242, legendre5.fPrime(Math.PI), 1.0e-8);
+
+        Polynomial legendre4  = new Polynomial(new double[] { 35, 0, -30, 0, 3 });
+        assertEquals(3116.230054157404545, legendre4.f(Math.PI), 1.0e-10);
+        assertEquals(4152.383176026587230, legendre4.fPrime(Math.PI), 1.0e-9);
+
+        Polynomial chebyshev7 = new Polynomial(new double[] { 64, 0, -112, 0, 56, 0, -7, 0 });
+        assertEquals(160738.9222272848309, chebyshev7.f(Math.PI), 1.0e-8);
+        assertEquals(377804.3612820780352, chebyshev7.fPrime(Math.PI), 1.0e-7);
+
+        Polynomial laguerre3  = new Polynomial(new double[] { -1, 9, -18, 6 });
+        assertEquals(7.271495164888129102, laguerre3.f(Math.PI), 1.0e-13);
+        assertEquals(8.939854561348202436, laguerre3.fPrime(Math.PI), 1.0e-12);
+
+    }
+
+    /** The differentiation schemes of order p should compute exact differentials
+     * for polynomials up to degree p.
+     */
+    public void testExactPolynomialDifferentiation() throws DifferentiationException {
+        for (int k = 0; k <= getOrder(); ++k) {
+            ReferenceFunction reference = Polynomial.randomPolynomial(random, k);
+            UnivariateDerivative derivative = buildDifferentiator(0.1).differentiate(reference);
+            for (DifferentialPair t : transcendentals) {
+                double error = derivative.f(t).getU1() - reference.fPrime(t.getU0());
+                assertEquals(0, error, 1.0e-13 * Math.abs(reference.fPrime(t.getU0())));
+            }
+        }
+    }
+
+    /** The derivative instances are bound to their primitive
+     * and should follow their updates transparently. */
+    public void testPrimitiveBinding() throws DifferentiationException {
+
+        // compute the differential once only
+        Polynomial reference = Polynomial.randomPolynomial(random, 3);
+        FiniteDifferencesDifferentiator differentiator = buildDifferentiator(0.1);
+        UnivariateDerivative derivative = differentiator.differentiate(reference);
+        double errorScaleFactor = differentiator.getSignedErrorScaleFactor();
+
+
+        // compute the differential values from this initial state
+        DifferentialPair[] beforeChange =
+            new DifferentialPair[transcendentals.length];
+        for (int i = 0; i < transcendentals.length; ++i) {
+            DifferentialPair t = transcendentals[i];
+            beforeChange[i] = derivative.f(t);
+            assertEquals(0, beforeChange[i].getU1() - reference.fPrime(t.getU0()), 100 * Math.abs(errorScaleFactor));
+        }
+
+        // change the primitive WITHOUT recomputing the differential
+        ((Polynomial) derivative.getPrimitive()).addToSelf(Polynomial.randomPolynomial(random, 4));
+
+        // compute the new values reusing the original differential
+        DifferentialPair[] afterChange =
+            new DifferentialPair[transcendentals.length];
+        for (int i = 0; i < transcendentals.length; ++i) {
+            DifferentialPair t = transcendentals[i];
+            afterChange[i] = derivative.f(t);
+            assertEquals(0, afterChange[i].getU1() - reference.fPrime(t.getU0()), 100 * Math.abs(errorScaleFactor));
+        }
+
+        // check the change was important
+        for (int i = 0; i < transcendentals.length; ++i) {
+            DifferentialPair change =
+                DifferentialPair.subtract(beforeChange[i], afterChange[i]);
+            assertTrue(Math.abs(change.getU0()) > 10000.0 * Math.abs(errorScaleFactor));
+            assertTrue(Math.abs(change.getU1()) > 10000.0 * Math.abs(errorScaleFactor));
+        }
+
+    }
+
+    /** Check the differentials values in a range.
+     * @param reference reference differential
+     * @param h finite differences step
+     * @param lower lower bound of the test range
+     * @param upper upper bound of the test range
+     * @param n number of test points in the range
+     * @param epsilon tolerance on the differentials values
+     */
+    protected void checkValues(ReferenceFunction reference, double h,
+                               double lower, double upper, int n,
+                               double epsilon) {
+        try {
+            UnivariateDerivative derivative = buildDifferentiator(h).differentiate(reference);
+            int n1 = n - 1;
+            for (int i = 0; i < n; ++i) {
+                double t = ((n1 - i) * lower + i * upper) / n1;
+                assertEquals(reference.fPrime(t),
+                             derivative.f(DifferentialPair.newVariable(t)).getU1(),
+                             epsilon);
+            }
+        } catch (DifferentiationException de) {
+            fail(de.getMessage());
+        }
+    }
+
+    /** Check the error order at some point.
+     * @param reference reference differential
+     * @param t abscissa of the test point
+     * @param hMin minimal step
+     * @param hMax minimal step
+     * @param n number of steps to try
+     * @param error expected order-normalized error
+     * @param epsilon tolerance on the expected extremal values
+     */
+    protected void checkOrder(ReferenceFunction reference,
+                              double t, double hMin, double hMax, int n,
+                              double error, double epsilon) {
+        try {
+            int n1 = n - 1;
+            for (int i = 0; i < n; ++i) {
+                double h = ((n1 - i) * hMin + i * hMax) / n1;
+                FiniteDifferencesDifferentiator fds = buildDifferentiator(h);
+                UnivariateDerivative derivative = fds.differentiate(reference);
+                double rawError =
+                    derivative.f(DifferentialPair.newVariable(t)).getU1() - reference.fPrime(t);
+                double orderNormalizedError = Math.abs(rawError / fds.getSignedErrorScaleFactor());
+                assertEquals(error, orderNormalizedError, epsilon);
+            }
+        } catch (DifferentiationException de) {
+            fail(de.getMessage());
+        }
+    }
+
+    protected ReferenceFunction hugeDifferentialsFunction() {
+        return new ReferenceFunction() {
+            public double f(double t) {
+                return Math.sin(3 * Math.tan(t * t) - Math.log(t));
+            }
+            public double fPrime(double t) {
+                double t2 = t * t;
+                double cosT2 = Math.cos(t2);
+                double tanT2 = Math.tan(t2);
+                return (6 * t / (cosT2 * cosT2) - 1 / t) * Math.cos(3 * tanT2 - Math.log(t));
+            }
+        };
+    }
+
+    public void setUp() {
+        random = new Random(0x6c05e9f92868d664l);
+        transcendentals = new DifferentialPair[] {
+                                                  DifferentialPair.newVariable(Math.PI),
+                                                  DifferentialPair.newVariable(Math.E),
+                                                  DifferentialPair.newVariable(Math.pow(2, Math.sqrt(2)))
+        };
+
+    }
+
+    public void tearDown() {
+        random = null;
+        transcendentals = null;
+    }
+
+    protected Random random;
+    private DifferentialPair[] transcendentals;
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/EightPointsSchemeTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/EightPointsSchemeTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/EightPointsSchemeTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/EightPointsSchemeTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.differences;
+
+import org.apache.commons.nabla.Polynomial;
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.differences.EightPointsScheme;
+import org.apache.commons.nabla.differences.FiniteDifferencesDifferentiator;
+
+public class EightPointsSchemeTest extends AbstractFiniteDifferencesTest {
+
+    public void testApproximatePolynomialDifferentiation() {
+
+        ReferenceFunction reference = Polynomial.randomPolynomial(random, 9);
+        checkValues(reference, 0.1, -1.0, 1.0, 100, 3.0e-4);
+        checkOrder(reference, Math.PI, 0.05, 0.1, 100, 266000, 10000);
+
+        reference = Polynomial.randomPolynomial(random, 10);
+        checkValues(reference, 0.1, -1.0, 1.0, 100, 2.0e-3);
+        checkOrder(reference, Math.PI, 0.05, 0.1, 10, 8280000, 15500);
+
+    }
+
+    public void testHugeDifferentialsFunction() {
+        ReferenceFunction reference = hugeDifferentialsFunction();
+        checkValues(reference, 0.05, 0.3, 0.7, 100, 0.005);
+        checkOrder(reference, 0.5, 0.01, 0.02, 10, 61200000, 1300000);
+    }
+
+    protected FiniteDifferencesDifferentiator buildDifferentiator(double h) {
+        return new EightPointsScheme(h);
+    }
+
+    protected int getOrder() {
+        return 8;
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/FourPointsSchemeTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/FourPointsSchemeTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/FourPointsSchemeTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/FourPointsSchemeTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.differences;
+
+import org.apache.commons.nabla.Polynomial;
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.differences.FiniteDifferencesDifferentiator;
+import org.apache.commons.nabla.differences.FourPointsScheme;
+
+public class FourPointsSchemeTest extends AbstractFiniteDifferencesTest {
+
+    public void testApproximatePolynomialDifferentiation() {
+
+        ReferenceFunction reference = Polynomial.randomPolynomial(random, 5);
+        checkValues(reference, 0.1, -1.0, 1.0, 100, 3.0e-4);
+        checkOrder(reference, Math.PI, 0.05, 0.1, 100, 7.261, 1.0e-3);
+
+        reference = Polynomial.randomPolynomial(random, 6);
+        checkValues(reference, 0.1, -1.0, 1.0, 100, 2.0e-3);
+        checkOrder(reference, Math.PI, 0.05, 0.1, 10, 131.682, 1.0e-3);
+
+    }
+
+    public void testHugeDifferentialsFunction() {
+        ReferenceFunction reference = hugeDifferentialsFunction();
+        checkValues(reference, 0.05, 0.3, 0.7, 100, 0.005);
+        checkOrder(reference, 0.5, 0.01, 0.02, 10, 130.548, 0.084);
+    }
+
+    protected FiniteDifferencesDifferentiator buildDifferentiator(double h) {
+        return new FourPointsScheme(h);
+    }
+
+    protected int getOrder() {
+        return 4;
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/SixPointsSchemeTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/SixPointsSchemeTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/SixPointsSchemeTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/SixPointsSchemeTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.differences;
+
+import org.apache.commons.nabla.Polynomial;
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.differences.FiniteDifferencesDifferentiator;
+import org.apache.commons.nabla.differences.SixPointsScheme;
+
+public class SixPointsSchemeTest extends AbstractFiniteDifferencesTest {
+
+    public void testApproximatePolynomialDifferentiation() {
+
+        ReferenceFunction reference = Polynomial.randomPolynomial(random, 7);
+        checkValues(reference, 0.1, -1.0, 1.0, 100, 3.0e-4);
+        checkOrder(reference, Math.PI, 0.05, 0.1, 100, 3659.4, 0.5);
+
+        reference = Polynomial.randomPolynomial(random, 8);
+        checkValues(reference, 0.1, -1.0, 1.0, 100, 2.0e-3);
+        checkOrder(reference, Math.PI, 0.05, 0.1, 10, 90415.25, 0.75);
+
+    }
+
+    public void testHugeDifferentialsFunction() {
+        ReferenceFunction reference = hugeDifferentialsFunction();
+        checkValues(reference, 0.05, 0.3, 0.7, 100, 0.005);
+        checkOrder(reference, 0.5, 0.01, 0.012, 10, 55685, 256);
+    }
+
+    protected FiniteDifferencesDifferentiator buildDifferentiator(double h) {
+        return new SixPointsScheme(h);
+    }
+
+    protected int getOrder() {
+        return 6;
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/TwoPointsSchemeTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/TwoPointsSchemeTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/TwoPointsSchemeTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/TwoPointsSchemeTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.differences;
+
+import org.apache.commons.nabla.Polynomial;
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.differences.FiniteDifferencesDifferentiator;
+import org.apache.commons.nabla.differences.TwoPointsScheme;
+
+
+public class TwoPointsSchemeTest extends AbstractFiniteDifferencesTest {
+
+    public void testApproximatePolynomialDifferentiation() {
+
+        ReferenceFunction reference = Polynomial.randomPolynomial(random, 3);
+        checkValues(reference, 0.1, -1.0, 1.0, 100, 1.0e-2);
+        checkOrder(reference, Math.PI, 0.05, 0.1, 10, 4.356, 1.0e-3);
+
+        reference = Polynomial.randomPolynomial(random, 4);
+        checkValues(reference, 0.1, -1.0, 1.0, 100, 2.0e-2);
+        checkOrder(reference, Math.PI, 0.05, 0.1, 10, 28.078, 1.0e-3);
+
+    }
+
+    public void testHugeDifferentialsFunction() {
+        ReferenceFunction reference = hugeDifferentialsFunction();
+        checkValues(reference, 0.05, 0.3, 0.7, 100, 0.09);
+        checkOrder(reference, 0.5, 0.01, 0.02, 10, 42.907, 0.013);
+    }
+
+    protected FiniteDifferencesDifferentiator buildDifferentiator(double h) {
+        return new TwoPointsScheme(h);
+    }
+
+    protected int getOrder() {
+        return 2;
+    }
+
+}

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