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 [1/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/...
Author: luc
Date: Tue Apr 15 06:25:28 2008
New Revision: 648243
URL: http://svn.apache.org/viewvc?rev=648243&view=rev
Log:
added test files for Nabla
(not complete, as tests are never complete enough)
Added:
commons/sandbox/nabla/trunk/src/test/
commons/sandbox/nabla/trunk/src/test/java/
commons/sandbox/nabla/trunk/src/test/java/org/
commons/sandbox/nabla/trunk/src/test/java/org/apache/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractNablaTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMathTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaStrictMathTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/Polynomial.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/ReferenceFunction.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/ErrorReporterTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DAddGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DDivGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DMulGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DNegGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DRemGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DSubGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcosGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcoshGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinhGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Atan2GeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanhGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CbrtGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CosGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CoshGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/ExpGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Expm1GeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/HypotGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log10GeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Log1pGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/LogGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/PowGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SinhGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/SqrtGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/TanhGeneratorTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/EightPointsSchemeTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/FourPointsSchemeTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/SixPointsSchemeTest.java (with props)
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/TwoPointsSchemeTest.java (with props)
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractNablaTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractNablaTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractNablaTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractNablaTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,105 @@
+/*
+ * 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;
+
+public abstract class AbstractNablaTest extends AbstractStaticFunctionsTest {
+
+ public void testExponential() {
+ defaultMonadicTest("exp");
+ defaultMonadicTest("expm1");
+ defaultMonadicTest("log");
+ defaultMonadicTest("log1p");
+ defaultMonadicTest("log10");
+ }
+
+ public void testCircular() {
+ defaultMonadicTest("cos");
+ defaultMonadicTest("sin");
+ defaultMonadicTest("tan");
+ defaultMonadicTest("acos");
+ defaultMonadicTest("asin");
+ defaultMonadicTest("atan");
+ checkDiadicFunction(getNablaClass(), getJavaClass(), "atan2",
+ -0.1, 0.3, 3, -0.7, 0.7, 15, 1.0e-15, 1.0e-12);
+ checkDiadicFunction(getNablaClass(), getJavaClass(), "hypot",
+ -0.1, 0.3, 3, -0.7, 0.7, 15, 1.0e-15, 1.0e-12);
+ }
+
+ public void testHyperbolic() {
+
+ defaultMonadicTest("cosh");
+ defaultMonadicTest("sinh");
+ defaultMonadicTest("tanh");
+
+ checkMonadicFunction(getNablaClass(), getClass(), "acosh",
+ 1.1, 1.3, 10, 1.0e-20, 2.0e-12);
+ checkMonadicFunction(getNablaClass(), getClass(), "asinh",
+ 1.1, 1.3, 10, 1.0e-20, 2.0e-12);
+ checkMonadicFunction(getNablaClass(), getClass(), "atanh",
+ 0.1, 0.3, 10, 1.0e-20, 2.0e-12);
+
+ }
+
+ public void testPower() {
+ defaultMonadicTest("sqrt");
+ defaultMonadicTest("cbrt");
+ checkDiadicFunction(getNablaClass(), getJavaClass(), "pow",
+ 0.1, 0.3, 3, 0.7, 1.5, 15, 1.0e-15, 1.0e-11);
+ checkDiadicFunction(getNablaClass(), getJavaClass(), "hypot",
+ 0.1, 0.3, 3, 0.7, 1.5, 15, 1.0e-15, 1.0e-11);
+ }
+
+ public void testSign() {
+ defaultMonadicTest("abs");
+ defaultMonadicTest("signum");
+ defaultDiadicTest("copySign");
+ }
+
+ public void testNeighborhood() {
+ defaultMonadicTest("floor");
+ defaultMonadicTest("rint");
+ defaultMonadicTest("ceil");
+ defaultMonadicTest("nextUp");
+ defaultDiadicTest("nextAfter");
+ }
+
+ public void testEncoding() {
+ defaultMonadicTest("ulp");
+ checkFunction(getNablaClass(), getJavaClass(),
+ new Class<?>[] { Double.TYPE, Integer.TYPE }, "scalb",
+ new double[][] {
+ { 0.1, 5 }, { 0.2, 5 }, { 0.3, 5 },
+ { 0.1, 6 }, { 0.2, 6 }, { 0.3, 6 },
+ { 0.1, 7 }, { 0.2, 7 }, { 0.3, 7 }
+ }, 1.0e-20, 1.0e-12);
+ checkDiadicFunction(getNablaClass(), getJavaClass(), "IEEEremainder",
+ 0.1, 0.3, 3, 12, 17, 3, 1.0e-15, 1.0e-8);
+ }
+
+ public void testConversion() {
+ defaultMonadicTest("toDegrees");
+ defaultMonadicTest("toRadians");
+ }
+
+ public void testComparison() {
+ checkDiadicFunction(getNablaClass(), getJavaClass(), "max",
+ 0.1, 0.3, 3, 0.15, 0.35, 3, 1.0e-20, 1.0e-15);
+ checkDiadicFunction(getNablaClass(), getJavaClass(), "min",
+ 0.1, 0.3, 3, 0.15, 0.35, 3, 1.0e-20, 1.0e-15);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractNablaTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,260 @@
+/*
+ * 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;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.commons.nabla.core.DifferentialPair;
+import org.apache.commons.nabla.core.UnivariateDifferentiable;
+import org.apache.commons.nabla.differences.EightPointsScheme;
+
+import junit.framework.TestCase;
+
+public abstract class AbstractStaticFunctionsTest extends TestCase {
+
+ public AbstractStaticFunctionsTest() {
+ super();
+ }
+
+ public AbstractStaticFunctionsTest(String name) {
+ super(name);
+ }
+
+ /** Get the nabla class to test (either NablaMath or NablaStrictMath).
+ * @return nabla class
+ */
+ protected abstract Class<?> getNablaClass();
+
+ /** Get the java class to test (either Math or StrictMath).
+ * @return java class
+ */
+ protected abstract Class<?> getJavaClass();
+
+ protected void defaultMonadicTest(String name) {
+ checkMonadicFunction(getNablaClass(), getJavaClass(), name,
+ 0.1, 0.3, 10, 1.0e-20, 2.0e-12);
+ }
+
+ protected void defaultDiadicTest(String name) {
+ checkDiadicFunction(getNablaClass(), getJavaClass(), name,
+ 1.0, 4.0, 4, 2.0, 7.0, 6, 1.0e-15, 1.0e-11);
+ }
+
+ /** Check a monadic static function in a range.
+ * @param nablaClass class implementing the function with differentials
+ * @param javaClass class implementing the function without differentials
+ * @param name name of the function
+ * @param lower lower bound of the check interval
+ * @param upper upper bound of the check interval
+ * @param n number of check points
+ * @param valueTolerance tolerance on the value
+ * @param differentialTolerance tolerance on the differentials
+ */
+ protected void checkMonadicFunction(Class<?> nablaClass, Class<?> javaClass,
+ String name,
+ double lower, double upper, int n,
+ double valueTolerance,
+ double differentialTolerance) {
+
+ // build the sequence of arguments sets
+ double[][] argsSetsSequence = new double[n][];
+ for (int i = 0; i < n; ++i) {
+ double arg = (((n - 1) - i) * lower + i * upper) / (n - 1);
+ argsSetsSequence[i] = new double[] { arg };
+ }
+
+ // perform the check
+ checkFunction(nablaClass, javaClass, new Class<?>[] { Double.TYPE },
+ name, argsSetsSequence, valueTolerance, differentialTolerance);
+
+ }
+
+ /** Check a diadic static function in a range.
+ * @param nablaClass class implementing the function with differentials
+ * @param javaClass class implementing the function without differentials
+ * @param name name of the function
+ * @param lower1 lower bound of the check interval for the first argument
+ * @param upper1 upper bound of the check interval for the first argument
+ * @param n1 number of check points for the first argument
+ * @param lower2 lower bound of the check interval for the second argument
+ * @param upper2 upper bound of the check interval for the second argument
+ * @param n2 number of check points for the second argument
+ * @param valueTolerance tolerance on the value
+ * @param differentialTolerance tolerance on the differentials
+ */
+ protected void checkDiadicFunction(Class<?> nablaClass, Class<?> javaClass,
+ String name,
+ double lower1, double upper1, int n1,
+ double lower2, double upper2, int n2,
+ double valueTolerance,
+ double differentialTolerance) {
+
+ // build the sequence of arguments sets
+ double[][] argsSetsSequence = new double[n1 * n2][];
+ int k = 0;
+ for (int i = 0; i < n1; ++i) {
+ double arg1 = (((n1 - 1) - i) * lower1 + i * upper1) / (n1 - 1);
+ for (int j = 0; j < n2; ++j) {
+ double arg2 = (((n2 - 1) - j) * lower2 + j * upper2) / (n2 - 1);
+ argsSetsSequence[k++] = new double[] { arg1, arg2 };
+ }
+ }
+
+ // perform the check
+ checkFunction(nablaClass, javaClass, new Class<?>[] { Double.TYPE, Double.TYPE },
+ name, argsSetsSequence, valueTolerance, differentialTolerance);
+
+ }
+
+ /** Check a static function for a sequence of arguments sets.
+ * @param nablaClass class implementing the function with differentials
+ * @param javaClass class implementing the function without differentials
+ * @param javaTypes types of the parameters of the java reference method
+ * @param name name of the function
+ * @param argsSetsSequence sequence of arguments sets
+ * @param valueTolerance tolerance on the value
+ * @param differentialTolerance tolerance on the differential
+ */
+ protected void checkFunction(Class<?> nablaClass,
+ Class<?> javaClass, Class<?>[] javaTypes,
+ String name, double[][] argsSetsSequence,
+ double valueTolerance,
+ double differentialTolerance) {
+ try {
+
+ // get the reference java method
+ Method javaMethod = javaClass.getMethod(name, javaTypes);
+
+ // get the nabla methods we can test
+ Method[] nablaMethods = nablaClass.getMethods();
+ for (int i = 0; i < nablaMethods.length; ++i) {
+ if (nablaMethods[i].getName().equals(name) &&
+ (nablaMethods[i].getParameterTypes().length == argsSetsSequence[0].length)) {
+
+ // test this method
+ for (int j = 0; j < argsSetsSequence.length; ++j) {
+ checkValue(nablaMethods[i], javaMethod, argsSetsSequence[j], valueTolerance);
+ checkDifferential(nablaMethods[i], javaMethod, argsSetsSequence[j], differentialTolerance);
+ }
+
+ }
+ }
+
+ } catch (NoSuchMethodException nsme) {
+ fail(nsme.getMessage());
+ }
+
+ }
+
+ /** Check the value of the function.
+ * @param nablaMethod method with differential
+ * @param javaMethod method without differential
+ * @param argsSet arguments set
+ * @param valueTolerance tolerance on the value
+ */
+ private void checkValue(Method nablaMethod, Method javaMethod,
+ double[] argsSet, double valueTolerance) {
+ try {
+
+ // call the nabla method
+ Object[] nablaArgs = convert(nablaMethod.getParameterTypes(), argsSet);
+ DifferentialPair dp = (DifferentialPair) nablaMethod.invoke(null, nablaArgs);
+
+ // call the reference java method
+ Object[] javaArgs = convert(javaMethod.getParameterTypes(), argsSet);
+ double d = ((Double) javaMethod.invoke(null, javaArgs)).doubleValue();
+
+ // check the nabla and java classes compute the same function
+ assertEquals(d, dp.getU0(), valueTolerance);
+
+ } catch (InvocationTargetException ite) {
+ fail(ite.getMessage());
+ } catch (IllegalAccessException iae) {
+ fail(iae.getMessage());
+ }
+ }
+
+ /** Check the differential of the function.
+ * @param nablaMethod method with differential
+ * @param javaMethod method without differential
+ * @param argsSet arguments set
+ * @param differentialTolerance tolerance on the differential
+ */
+ private void checkDifferential(Method nablaMethod, final Method javaMethod,
+ double[] argsSet,
+ double differentialTolerance) {
+ try {
+
+ // compute the differential as implemented by the nabla function
+ final Object[] converted = convert(nablaMethod.getParameterTypes(), argsSet);
+ DifferentialPair nablaDP = (DifferentialPair) nablaMethod.invoke(null, converted);
+
+ // compute the reference differential by finite differences on the java function
+ // (in fact, this reference differential will be LESS accurate than the nabla one ...)
+ DifferentialPair differencesDP = new EightPointsScheme(1.0e-3).differentiate(new UnivariateDifferentiable() {
+ public double f(double x) {
+ try {
+ Object[] changed = new Object[converted.length];
+ for (int i = 0; i < converted.length; ++i) {
+ if (converted[i] instanceof DifferentialPair) {
+ DifferentialPair a = (DifferentialPair) converted[i];
+ changed[i] = new Double(a.getU0() + x * a.getU1());
+ } else {
+ changed[i] = converted[i];
+ }
+ }
+ return ((Double) javaMethod.invoke(null, changed)).doubleValue();
+ } catch (Exception e) {
+ return Double.NaN;
+ }
+ }
+ }).f(DifferentialPair.newVariable(0.0));
+
+ // check the nabla and java classes compute the same differential
+ assertEquals(differencesDP.getU1(), nablaDP.getU1(),
+ differentialTolerance);
+
+ } catch (InvocationTargetException ite) {
+ fail(ite.getMessage());
+ } catch (IllegalAccessException iae) {
+ fail(iae.getMessage());
+ }
+ }
+
+ /** Converts an arguments array, with types conversion as needed.
+ * @param types types of the arguments
+ * @param values raw values of the arguments
+ * @return an arguments array
+ */
+ private Object[] convert(Class<?>[] types, double[] values) {
+ Object[] arguments = new Object[values.length];
+ for (int i = 0; i < values.length; ++i) {
+ if (types[i].equals(DifferentialPair.class)) {
+ arguments[i] = DifferentialPair.newVariable(values[i]);
+ } else if (types[i].equals(Double.TYPE)) {
+ arguments[i] = new Double(values[i]);
+ } else if (types[i].equals(Integer.TYPE)) {
+ arguments[i] = new Integer((int) values[i]);
+ } else if (types[i].equals(Long.TYPE)) {
+ arguments[i] = new Long((long) values[i]);
+ }
+ }
+ return arguments;
+ }
+
+}
\ No newline at end of file
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMathTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMathTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMathTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMathTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import org.apache.commons.nabla.NablaMath;
+
+
+public class NablaMathTest extends AbstractNablaTest {
+
+ protected Class<?> getNablaClass() {
+ return NablaMath.class;
+ }
+
+ protected Class<?> getJavaClass() {
+ return Math.class;
+ }
+
+ public static double acosh(double a) {
+ return Math.log(a + Math.sqrt(a - 1) * Math.sqrt(a + 1));
+ }
+
+ public static double asinh(double a) {
+ return Math.log(a + Math.sqrt(a * a + 1));
+ }
+
+ public static double atanh(double a) {
+ return (Math.log1p(a) - Math.log1p(-a)) / 2;
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMathTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaStrictMathTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaStrictMathTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaStrictMathTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaStrictMathTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import org.apache.commons.nabla.NablaStrictMath;
+
+
+public class NablaStrictMathTest extends AbstractNablaTest {
+
+ protected Class<?> getNablaClass() {
+ return NablaStrictMath.class;
+ }
+
+ protected Class<?> getJavaClass() {
+ return StrictMath.class;
+ }
+
+ public static double acosh(double a) {
+ return StrictMath.log(a + StrictMath.sqrt(a - 1) * StrictMath.sqrt(a + 1));
+ }
+
+ public static double asinh(double a) {
+ return StrictMath.log(a + StrictMath.sqrt(a * a + 1));
+ }
+
+ public static double atanh(double a) {
+ return (StrictMath.log1p(a) - StrictMath.log1p(-a)) / 2;
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaStrictMathTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/Polynomial.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/Polynomial.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/Polynomial.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/Polynomial.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,70 @@
+/*
+ * 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;
+
+import java.util.Random;
+
+public class Polynomial implements ReferenceFunction {
+
+ /** Build a random polynomial.
+ * @param random random generator to use
+ * @param degree
+ * @return a random polynomial
+ */
+ public static Polynomial randomPolynomial(Random random, int degree) {
+ double[] coeffs = new double[degree+1];
+ for (int i = 0; i < coeffs.length; ++i) {
+ coeffs[i] = random.nextDouble();
+ }
+ return new Polynomial(coeffs);
+ }
+
+ /** Build a polynomial from its coefficients.
+ * @param coeffs coefficients array in <em>decreasing degree</em> order
+ */
+ public Polynomial(double[] coeffs) {
+ this.coeffs = coeffs;
+ }
+
+ public void addToSelf(Polynomial other) {
+ double[] newCoeffs = new double[Math.max(coeffs.length, other.coeffs.length)];
+ System.arraycopy(coeffs, 0, newCoeffs, 0, coeffs.length);
+ for (int i = 0; i < other.coeffs.length; ++i) {
+ newCoeffs[i] += other.coeffs[i];
+ }
+ coeffs = newCoeffs;
+ }
+
+ public double f(double t) {
+ double y = 0;
+ for (int i = 0; i < coeffs.length; ++i) {
+ y = y * t + coeffs[i];
+ }
+ return y;
+ }
+
+ public double fPrime(double t) {
+ double d = 0;
+ for (int i = 0; i < coeffs.length - 1; ++i) {
+ d = d * t + (coeffs.length - 1 - i) * coeffs[i];
+ }
+ return d;
+ }
+
+ private double[] coeffs;
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/Polynomial.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/ReferenceFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/ReferenceFunction.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/ReferenceFunction.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/ReferenceFunction.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,23 @@
+/*
+ * 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;
+
+import org.apache.commons.nabla.core.UnivariateDifferentiable;
+
+public interface ReferenceFunction extends UnivariateDifferentiable {
+ public double fPrime(double t);
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/ReferenceFunction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.analysis.AutomaticDifferentiator;
+import org.apache.commons.nabla.core.DifferentialPair;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.apache.commons.nabla.core.UnivariateDerivative;
+
+import junit.framework.TestCase;
+
+public abstract class AbstractMathTest extends TestCase {
+
+ protected void checkReference(ReferenceFunction reference,
+ double t0, double t1, int n,
+ double threshold) {
+ try {
+ AutomaticDifferentiator differentiator = new AutomaticDifferentiator();
+ differentiator.addMathImplementation(MathExtensions.class);
+ UnivariateDerivative derivative = differentiator.differentiate(reference);
+ for (int i = 0; i < n; ++i) {
+ double t = ((n - 1 - i) * t0 + i * t1) / (n - 1);
+ DifferentialPair dpT = DifferentialPair.newVariable(t);
+ assertEquals(reference.fPrime(t), derivative.f(dpT).getU1(), threshold);
+ }
+ } catch (DifferentiationException de) {
+ fail(de.getMessage());
+ }
+ }
+
+ public static class MathExtensions {
+ public static double acosh(double a) {
+ return Math.log(a + Math.sqrt(a - 1) * Math.sqrt(a + 1));
+ }
+ public static double asinh(double a) {
+ return Math.log(a + Math.sqrt(a * a + 1));
+ }
+ public static double atanh(double a) {
+ return (Math.log1p(a) - Math.log1p(-a)) / 2;
+ }
+ public static double sqrt(double a) {
+ return Math.sqrt(a);
+ }
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,106 @@
+/*
+ * 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.analysis;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class AutomaticDifferentiatorTest extends AbstractMathTest {
+
+ public void testSingleCall() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.cos(t); }
+ public double fPrime(double t) { return -Math.sin(t); }
+ }, 0, 2 * Math.PI, 20, 0.0);
+ }
+
+ public void testEmbeddedCalls() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.exp(Math.sin(t)); }
+ public double fPrime(double t) { return Math.cos(t) * Math.exp(Math.sin(t)); }
+ }, 0.1, 10, 20, 0);
+ }
+
+ public void testParameterIndependent() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return 1; }
+ public double fPrime(double t) { return 0; }
+ }, 0.1, 5, 20, 2.0e-12);
+ }
+
+ public void testSimpleExpression() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return 1.0 / t; }
+ public double fPrime(double t) { return -1 / (t * t); }
+ }, 0.1, 5, 20, 2.0e-12);
+ }
+
+ public void testMul() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t * t; }
+ public double fPrime(double t) { return 2 * t; }
+ }, 0.1, 5, 20, 2.0e-12);
+ }
+
+ public void testPolynomialExpression() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return (((4 * t + 2) * t + 1) * t - 2) * t + 5; }
+ public double fPrime(double t) { return ((16 * t + 6) * t + 2) * t - 2; }
+ }, 0.1, 5, 20, 2.0e-12);
+ }
+
+ public void testNarrowing() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t - (int) t; }
+ public double fPrime(double t) { return 1; }
+ }, 0.1, 5, 20, 0);
+ }
+
+ public void testLocalVariables() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { double threeT = 3 * t; return threeT * threeT; }
+ public double fPrime(double t) { return 18 * t; }
+ }, -5, 5, 20, 2.0e-14);
+ }
+
+ public void testLoopLdc() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) {
+ double result = 2.0;
+ for (int i = 0; i < 3; ++i) {
+ result *= t;
+ }
+ return result;
+ }
+ public double fPrime(double t) { return 6 * t * t; }
+ }, -5, 5, 20, 4.0e-14);
+ }
+
+ public void testLoopDcons() {
+ checkReference(new ReferenceFunction() {
+ public double f(double t) {
+ double result = 1.0;
+ for (int i = 0; i < 3; ++i) {
+ result *= t;
+ }
+ return result;
+ }
+ public double fPrime(double t) { return 3 * t * t; }
+ }, -5, 5, 20, 4.0e-14);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/ErrorReporterTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/ErrorReporterTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/ErrorReporterTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/ErrorReporterTest.java Tue Apr 15 06:25:28 2008
@@ -0,0 +1,59 @@
+/*
+ * 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.analysis;
+
+import org.apache.commons.nabla.automatic.analysis.ErrorReporter;
+import org.apache.commons.nabla.core.DifferentiationException;
+
+import junit.framework.TestCase;
+
+public class ErrorReporterTest extends TestCase {
+
+ public void testReport() {
+ ErrorReporter reporter = new ErrorReporter();
+ assertFalse(reporter.hasError());
+ wrappingFunction(false, reporter);
+ assertFalse(reporter.hasError());
+ try {
+ reporter.reportErrors();
+ } catch (DifferentiationException de) {
+ fail("unexpected exception caught");
+ }
+ wrappingFunction(true, reporter);
+ assertTrue(reporter.hasError());
+ try {
+ reporter.reportErrors();
+ fail("an exception should have been thrown");
+ } catch (DifferentiationException de) {
+ // expected behavior
+ }
+ }
+
+ private void wrappingFunction(boolean doThrow, ErrorReporter reporter) {
+ try {
+ if (doThrow) {
+ throwException();
+ }
+ } catch (DifferentiationException de) {
+ reporter.register(de);
+ }
+ }
+
+ private void throwException() throws DifferentiationException {
+ throw new DifferentiationException("dummy message", new Object[0]);
+ }
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/ErrorReporterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DAddGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DAddGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DAddGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DAddGeneratorTest.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.arithmetic;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class DAddGeneratorTest extends AbstractMathTest {
+
+ public void testReference1(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t + 5; }
+ public double fPrime(double t) { return 1; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+ public void testReference2(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return 5 + t; }
+ public double fPrime(double t) { return 1; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+ public void testReference12(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t + t; }
+ public double fPrime(double t) { return 2; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DAddGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DDivGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DDivGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DDivGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DDivGeneratorTest.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.arithmetic;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class DDivGeneratorTest extends AbstractMathTest {
+
+ public void testReference1(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t / 5; }
+ public double fPrime(double t) { return 1.0 / 5.0; }
+ }, 0.1, 10, 30, 0.0);
+ }
+
+ public void testReference2(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return 5 / t; }
+ public double fPrime(double t) { return -5 / (t * t); }
+ }, 0.5, 10, 30, 1e-15);
+ }
+
+ public void testReference12(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t / t; }
+ public double fPrime(double t) { return 0; }
+ }, 0.1, 10, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DDivGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DMulGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DMulGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DMulGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DMulGeneratorTest.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.arithmetic;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class DMulGeneratorTest extends AbstractMathTest {
+
+ public void testReference1(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t * 5; }
+ public double fPrime(double t) { return 5; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+ public void testReference2(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return 5 * t; }
+ public double fPrime(double t) { return 5; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+ public void testReference12(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t * t; }
+ public double fPrime(double t) { return 2 * t; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DMulGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DNegGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DNegGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DNegGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DNegGeneratorTest.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.arithmetic;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class DNegGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return -t; }
+ public double fPrime(double t) { return -1; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DNegGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DRemGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DRemGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DRemGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DRemGeneratorTest.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.arithmetic;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class DRemGeneratorTest extends AbstractMathTest {
+
+ public void testReference1(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t % 5; }
+ public double fPrime(double t) { return 1.0; }
+ }, 0.1, 10, 30, 0.0);
+ }
+
+ public void testReference2(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return 5 % t; }
+ public double fPrime(double t) { return ((5 % t) - 5) / t; }
+ }, 0.5, 10, 30, 1e-15);
+ }
+
+ public void testReference12(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t % t; }
+ public double fPrime(double t) { return 0; }
+ }, 0.1, 10, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DRemGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DSubGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DSubGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DSubGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DSubGeneratorTest.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.arithmetic;
+
+import org.apache.commons.nabla.ReferenceFunction;
+import org.apache.commons.nabla.automatic.AbstractMathTest;
+
+public class DSubGeneratorTest extends AbstractMathTest {
+
+ public void testReference1(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t - 5; }
+ public double fPrime(double t) { return 1; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+ public void testReference2(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return 5 - t; }
+ public double fPrime(double t) { return -1; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+ public void testReference12(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return t - t; }
+ public double fPrime(double t) { return 0; }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/arithmetic/DSubGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcosGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcosGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcosGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcosGeneratorTest.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 AcosGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.acos(t); }
+ public double fPrime(double t) { return -1 / Math.sqrt(1 - t * t); }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcosGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcoshGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcoshGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcoshGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcoshGeneratorTest.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 AcoshGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return MathExtensions.acosh(t); }
+ public double fPrime(double t) { return 1 / Math.sqrt(t * t - 1); }
+ }, 1.01, 5, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AcoshGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinGeneratorTest.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 AsinGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.asin(t); }
+ public double fPrime(double t) { return 1 / Math.sqrt(1 - t * t); }
+ }, -0.99, 0.99, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinhGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinhGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinhGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinhGeneratorTest.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 AsinhGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return MathExtensions.asinh(t); }
+ public double fPrime(double t) { return 1 / Math.sqrt(t * t + 1); }
+ }, -5, 5, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AsinhGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Atan2GeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Atan2GeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Atan2GeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Atan2GeneratorTest.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 Atan2GeneratorTest extends AbstractMathTest {
+
+ public void testReference1(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.atan2(t, 3.0); }
+ public double fPrime(double t) { return 3 / (t * t + 9); }
+ }, -2, 2, 50, 2e-15);
+ }
+
+ public void testReference2(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.atan2(3.0, t); }
+ public double fPrime(double t) { return -3 / (t * t + 9); }
+ }, -2, 2, 50, 0.0);
+ }
+
+ public void testReference12Aligned(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.atan2(t, t); }
+ public double fPrime(double t) { return 0; }
+ }, 0.1, 10, 20, 0);
+ }
+
+ public void testReference12Shifted(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.atan2(t, t + 1); }
+ public double fPrime(double t) { return 1 / (2 * t * (t + 1) + 1); }
+ }, 0.1, 10, 20, 2.0e-16);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Atan2GeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanGeneratorTest.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 AtanGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.atan(t); }
+ public double fPrime(double t) { return 1 / (1 + t * t); }
+ }, -1.5, 1.5, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanhGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanhGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanhGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanhGeneratorTest.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 AtanhGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return MathExtensions.atanh(t); }
+ public double fPrime(double t) { return 1 / (1 - t * t); }
+ }, -5, 5, 30, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/AtanhGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CbrtGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CbrtGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CbrtGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CbrtGeneratorTest.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 CbrtGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.cbrt(t); }
+ public double fPrime(double t) { return 1 / (3 * (Math.cbrt(t) * Math.cbrt(t))); }
+ }, -5, 5, 50, 0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CbrtGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CosGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CosGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CosGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CosGeneratorTest.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 CosGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.cos(t); }
+ public double fPrime(double t) { return -Math.sin(t); }
+ }, 0, 2 * Math.PI, 20, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CosGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CoshGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CoshGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CoshGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CoshGeneratorTest.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 CoshGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.cosh(t); }
+ public double fPrime(double t) { return Math.sinh(t); }
+ }, -10, 10, 50, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/CoshGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/ExpGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/ExpGeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/ExpGeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/ExpGeneratorTest.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 ExpGeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.exp(t); }
+ public double fPrime(double t) { return Math.exp(t); }
+ }, -5, 5, 50, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/ExpGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Expm1GeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Expm1GeneratorTest.java?rev=648243&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Expm1GeneratorTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Expm1GeneratorTest.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 Expm1GeneratorTest extends AbstractMathTest {
+
+ public void testReference(){
+ checkReference(new ReferenceFunction() {
+ public double f(double t) { return Math.expm1(t); }
+ public double fPrime(double t) { return 1 + Math.expm1(t); }
+ }, -5, 5, 50, 0.0);
+ }
+
+}
Propchange: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/functions/Expm1GeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native