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

svn commit: r1391531 [1/2] - in /commons/sandbox/nabla/trunk/src: main/java/org/apache/commons/nabla/ main/java/org/apache/commons/nabla/caching/ main/java/org/apache/commons/nabla/core/ main/java/org/apache/commons/nabla/forward/ main/java/org/apache/...

Author: luc
Date: Fri Sep 28 16:38:56 2012
New Revision: 1391531

URL: http://svn.apache.org/viewvc?rev=1391531&view=rev
Log:
Use Apache Commons Math features: differentiation package.

This is the start of a major overhaul of Nabla. We replace the custom
DifferentialPair and associated interfaces with Apache Commons Math
DerivativeStructure and associated interfaces.

This change will highly simplify bytecode modifications because we
will simply call DerivativeStructure methods, not implement derivation
chain rule by ourselves. This change will also greatly improve Nabla
features as DerivativeStructure supports any derivation order and any
number of parameters, while DifferentialPair supported only first
derivation order with respect to one parameter.

This commit is only a start to set up the basic structure (changing
interfaces, signatures and so on). It is *not* a functional commit as
the bytecode changes have not been updated to use the new features. This
means that the library state just after this commit is Work In Progress.
It does compile, but almost all the tests fail!

Added:
    commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/
    commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/localization/
    commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/localization/NablaMessages_fr.properties   (with props)
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMessagesTest.java   (with props)
Removed:
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/Descriptors.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaMath.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaStrictMath.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/DifferentialPair.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/UnivariateDerivative.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/UnivariateDifferentiable.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/UnivariateDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/package-info.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractNablaTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMathTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaStrictMathTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/Polynomial.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/ReferenceFunction.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java
Modified:
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/caching/FetchDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/ForwardModeAlgorithmicDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ForwardModeClassDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer1.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer12.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer2.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer1.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer12.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer2.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer1.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer12.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer2.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer1.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer12.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer2.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer1.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer12.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer2.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DLoadTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DReturnTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DStoreTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2Transformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X1Transformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer1.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer12.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer2.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/NarrowingTransformer.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/WideningTransformer.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractMathTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/ForwardAlgorithmicDifferentiatorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DAddGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DNegGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DRemGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DSubGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/AcosGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/AcoshGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/AsinGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/AsinhGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/Atan2GeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/AtanGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/AtanhGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/CbrtGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/CosGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/CoshGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/ExpGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/Expm1GeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/HypotGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/Log10GeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/Log1pGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/LogGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/PowGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SinGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SinhGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/SqrtGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/TanGeneratorTest.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/functions/TanhGeneratorTest.java

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/caching/FetchDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/caching/FetchDifferentiator.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/caching/FetchDifferentiator.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/caching/FetchDifferentiator.java Fri Sep 28 16:38:56 2012
@@ -16,20 +16,18 @@
  */
 package org.apache.commons.nabla.caching;
 
-import org.apache.commons.nabla.core.DifferentiationException;
-import org.apache.commons.nabla.core.UnivariateDerivative;
-import org.apache.commons.nabla.core.UnivariateDifferentiable;
-import org.apache.commons.nabla.core.UnivariateDifferentiator;
+import org.apache.commons.math3.analysis.UnivariateVectorFunction;
+import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableVectorFunction;
+import org.apache.commons.math3.analysis.differentiation.UnivariateVectorFunctionDifferentiator;
 
 /** Differentiator that fetches classes already differentiated by
  * {@link org.apache.commons.nabla.forward.ForwardModeAlgorithmicDifferentiator}.
  * @see org.apache.commons.nabla.forward.ForwardModeAlgorithmicDifferentiator
  */
-public class FetchDifferentiator implements UnivariateDifferentiator {
+public class FetchDifferentiator implements UnivariateVectorFunctionDifferentiator {
 
     /** {@inheritDoc} */
-    public UnivariateDerivative differentiate(final UnivariateDifferentiable d)
-        throws DifferentiationException {
+    public UnivariateDifferentiableVectorFunction differentiate(UnivariateVectorFunction function) {
 
         // TODO implement differentiation by fetching an already derived class
         return null;

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/ForwardModeAlgorithmicDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/ForwardModeAlgorithmicDifferentiator.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/ForwardModeAlgorithmicDifferentiator.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/ForwardModeAlgorithmicDifferentiator.java Fri Sep 28 16:38:56 2012
@@ -24,10 +24,11 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.commons.nabla.Descriptors;
-import org.apache.commons.nabla.core.UnivariateDerivative;
-import org.apache.commons.nabla.core.UnivariateDifferentiable;
-import org.apache.commons.nabla.core.UnivariateDifferentiator;
+import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
+import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
+import org.apache.commons.math3.analysis.differentiation.UnivariateFunctionDifferentiator;
+import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.nabla.DifferentiationException;
 import org.apache.commons.nabla.NablaMessages;
 import org.apache.commons.nabla.forward.analysis.ForwardModeClassDifferentiator;
@@ -36,7 +37,7 @@ import org.objectweb.asm.Type;
 import org.objectweb.asm.tree.ClassNode;
 
 /** Algorithmic differentiator class in forward mode based on bytecode analysis.
- * <p>This class is an implementation of the {@link UnivariateDifferentiator}
+ * <p>This class is an implementation of the {@link UnivariateFunctionDifferentiator}
  * interface that computes <em>exact</em> differentials completely automatically
  * and generate java classes and instances that compute the differential
  * of the function as if they were hand-coded and compiled.</p>
@@ -46,17 +47,17 @@ import org.objectweb.asm.tree.ClassNode;
  * use in an application without bringing the full nabla library and its
  * dependencies.</p>
  * <p>This differentiator can handle only pure bytecode methods and known methods
- * from math implementation classes like {@link java.lang.Math Math} or
- * {@link java.lang.StrictMath StrictMath}. Pure bytecode methods are analyzed
- * and converted. Methods from math implementation classes are only recognized
- * by class and name and replaced by predefined derivative code.</p>
+ * from math implementation classes like {@link java.lang.Math Math}, {@link
+ * java.lang.StrictMath StrictMath} or {@link FastMath}. Pure bytecode methods are
+ * analyzed and converted. Methods from math implementation classes are only
+ * recognized by class and name and replaced by predefined derivative code.</p>
  * @see org.apache.commons.nabla.caching.FetchDifferentiator
  */
-public class ForwardModeAlgorithmicDifferentiator implements UnivariateDifferentiator {
+public class ForwardModeAlgorithmicDifferentiator implements UnivariateFunctionDifferentiator {
 
-    /** UnivariateDifferentiable/UnivariateDerivative map. */
-    private final HashMap<Class<? extends UnivariateDifferentiable>,
-                          Class<? extends UnivariateDerivative>> map;
+    /** UnivariateFunction/UnivariateDifferentiableFunction map. */
+    private final HashMap<Class<? extends UnivariateFunction>,
+                          Class<? extends UnivariateDifferentiableFunction>> map;
 
     private final HashMap<String, byte[]> byteCodeMap;
 
@@ -67,12 +68,13 @@ public class ForwardModeAlgorithmicDiffe
      * <p>Build a ForwardAlgorithmicDifferentiator instance with an empty cache.</p>
      */
     public ForwardModeAlgorithmicDifferentiator() {
-        map = new HashMap<Class<? extends UnivariateDifferentiable>,
-        Class<? extends UnivariateDerivative>>();
+        map         = new HashMap<Class<? extends UnivariateFunction>,
+                                  Class<? extends UnivariateDifferentiableFunction>>();
         byteCodeMap = new HashMap<String, byte[]>();
         mathClasses = new HashSet<String>();
         addMathImplementation(Math.class);
         addMathImplementation(StrictMath.class);
+        addMathImplementation(FastMath.class);
     }
 
     /** Add an implementation class for mathematical functions.
@@ -97,17 +99,16 @@ public class ForwardModeAlgorithmicDiffe
     }
 
     /** {@inheritDoc} */
-    public UnivariateDerivative differentiate(final UnivariateDifferentiable d)
-        throws DifferentiationException {
+    public UnivariateDifferentiableFunction differentiate(final UnivariateFunction d) {
 
         // get the derivative class
-        final Class<? extends UnivariateDerivative> derivativeClass =
+        final Class<? extends UnivariateDifferentiableFunction> derivativeClass =
             getDerivativeClass(d.getClass());
 
         try {
 
             // create the instance
-            final Constructor<? extends UnivariateDerivative> constructor =
+            final Constructor<? extends UnivariateDifferentiableFunction> constructor =
                 derivativeClass.getConstructor(d.getClass());
             return constructor.newInstance(d);
 
@@ -137,12 +138,12 @@ public class ForwardModeAlgorithmicDiffe
      * @return derivative class
      * @throws DifferentiationException if the class cannot be differentiated
      */
-    private Class<? extends UnivariateDerivative>
-    getDerivativeClass(final Class<? extends UnivariateDifferentiable> differentiableClass)
+    private Class<? extends UnivariateDifferentiableFunction>
+    getDerivativeClass(final Class<? extends UnivariateFunction> differentiableClass)
         throws DifferentiationException {
 
         // lookup in the map if the class has already been differentiated
-        Class<? extends UnivariateDerivative> derivativeClass =
+        Class<? extends UnivariateDifferentiableFunction> derivativeClass =
             map.get(differentiableClass);
 
         // build the derivative class if it does not exist yet
@@ -166,8 +167,8 @@ public class ForwardModeAlgorithmicDiffe
      * @return derivative class
      * @throws DifferentiationException if the class cannot be differentiated
      */
-    private Class<? extends UnivariateDerivative>
-    createDerivativeClass(final Class<? extends UnivariateDifferentiable> differentiableClass)
+    private Class<? extends UnivariateDifferentiableFunction>
+    createDerivativeClass(final Class<? extends UnivariateFunction> differentiableClass)
         throws DifferentiationException {
         try {
 
@@ -185,7 +186,7 @@ public class ForwardModeAlgorithmicDiffe
             final String name = derived.name.replace('/', '.');
             derived.accept(writer);
             final byte[] bytecode = writer.toByteArray();
-            Class<? extends UnivariateDerivative> dClass =
+            Class<? extends UnivariateDifferentiableFunction> dClass =
                     new DerivativeLoader(differentiableClass).defineClass(name, bytecode);
             byteCodeMap.put(name, bytecode);
             return dClass;
@@ -202,7 +203,7 @@ public class ForwardModeAlgorithmicDiffe
         /** Simple constructor.
          * @param differentiableClass differentiable class
          */
-        public DerivativeLoader(final Class<? extends UnivariateDifferentiable> differentiableClass) {
+        public DerivativeLoader(final Class<? extends UnivariateFunction> differentiableClass) {
             super(differentiableClass.getClassLoader());
         }
 
@@ -212,9 +213,9 @@ public class ForwardModeAlgorithmicDiffe
          * @return a generated derivative class
          */
         @SuppressWarnings("unchecked")
-        public Class<? extends UnivariateDerivative>
+        public Class<? extends UnivariateDifferentiableFunction>
         defineClass(final String name, byte[] bytecode) {
-            return (Class<? extends UnivariateDerivative>) defineClass(name, bytecode, 0, bytecode.length);
+            return (Class<? extends UnivariateDifferentiableFunction>) defineClass(name, bytecode, 0, bytecode.length);
         }
     }
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ForwardModeClassDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ForwardModeClassDifferentiator.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ForwardModeClassDifferentiator.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/ForwardModeClassDifferentiator.java Fri Sep 28 16:38:56 2012
@@ -21,8 +21,8 @@ import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.util.Set;
 
-import org.apache.commons.nabla.core.UnivariateDerivative;
-import org.apache.commons.nabla.core.UnivariateDifferentiable;
+import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
 import org.apache.commons.nabla.DifferentiationException;
 import org.apache.commons.nabla.NablaMessages;
 import org.objectweb.asm.ClassReader;
@@ -60,7 +60,7 @@ public class ForwardModeClassDifferentia
     private final Set<String> mathClasses;
 
     /** Class to differentiate. */
-    private final Class<? extends UnivariateDifferentiable> primitiveClass;
+    private final Class<? extends UnivariateFunction> primitiveClass;
 
     /** Node of the class to differentiate. */
     private final ClassNode primitiveNode;
@@ -75,7 +75,7 @@ public class ForwardModeClassDifferentia
      * @exception DifferentiationException if class cannot be differentiated
      * @throws IOException if class cannot be read
      */
-    public ForwardModeClassDifferentiator(Class<? extends UnivariateDifferentiable> primitiveClass,
+    public ForwardModeClassDifferentiator(Class<? extends UnivariateFunction> primitiveClass,
                                           final Set<String> mathClasses)
         throws DifferentiationException, IOException {
 
@@ -89,8 +89,8 @@ public class ForwardModeClassDifferentia
         this.mathClasses = mathClasses;
         classNode = new ClassNode(Opcodes.ASM4);
 
-        // check the UnivariateDifferentiable interface is implemented
-        final Class<UnivariateDifferentiable> uDerClass = UnivariateDifferentiable.class;
+        // check the UnivariateFunction interface is implemented
+        final Class<UnivariateFunction> uFuncClass = UnivariateFunction.class;
         boolean isDifferentiable = false;
         for (String interf : primitiveNode.interfaces) {
             final String interfName = interf.replace('/', '.');
@@ -104,7 +104,7 @@ public class ForwardModeClassDifferentia
                                                    interfName, primitiveNode.name);
             }
             if (interfClass != null) {
-                isDifferentiable = isDifferentiable || uDerClass.isAssignableFrom(interfClass);
+                isDifferentiable = isDifferentiable || uFuncClass.isAssignableFrom(interfClass);
             }
         }
 
@@ -118,13 +118,12 @@ public class ForwardModeClassDifferentia
                         primitiveNode.name + "_NablaForwardModeUnivariateDerivative",
                         null, Type.getType(Object.class).getInternalName(),
                         new String[] {
-                            UnivariateDerivative.class.getName().replace('.', '/')
+                            UnivariateDifferentiableFunction.class.getName().replace('.', '/')
                         });
 
-        // primitive instance field and methods setting/getting it
+        // add boilerplate code
         addPrimitiveField();
         addConstructor();
-        addGetPrimitiveMethod();
         addGetPrimitiveFieldMethod();
 
     }
@@ -189,19 +188,6 @@ public class ForwardModeClassDifferentia
         classNode.methods.add(constructor);
     }
 
-    /** Add the {@link UnivariateDerivative#getPrimitive() getPrimitive()} method.
-     */
-    private void addGetPrimitiveMethod() {
-        final MethodNode method =
-            new MethodNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "getPrimitive",
-                           "()L" + primitiveNode.name + ";", null, null);
-        method.visitVarInsn(Opcodes.ALOAD, 0);
-        method.visitFieldInsn(Opcodes.GETFIELD, classNode.name, PRIMITIVE_FIELD, "L" + primitiveNode.name + ";");
-        method.visitInsn(Opcodes.ARETURN);
-        method.visitMaxs(0, 0);
-        classNode.methods.add(method);
-   }
-
     /** Add the getPrimitiveField method.
      */
     private void addGetPrimitiveFieldMethod() {

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/analysis/MethodDifferentiator.java Fri Sep 28 16:38:56 2012
@@ -26,7 +26,7 @@ import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.nabla.Descriptors;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
 import org.apache.commons.nabla.DifferentiationException;
 import org.apache.commons.nabla.NablaMessages;
 import org.apache.commons.nabla.forward.arithmetic.DAddTransformer1;
@@ -196,12 +196,14 @@ public class MethodDifferentiator {
         throws DifferentiationException {
         try {
 
-            // at start, "this" and one differential pair are already used
+            // at start, "this" and one DerivativeStructure are already used
             method.maxLocals  = 2 * (method.maxLocals + MAX_TEMP) - 1;
             usedLocals = new boolean[method.maxLocals];
             useLocal(0, 1);
             useLocal(1, 4);
 
+            final Type dsType = Type.getType(DerivativeStructure.class);
+
             // add spare cells to hold new variables if needed
             addSpareLocalVariables(method.instructions);
 
@@ -221,15 +223,25 @@ public class MethodDifferentiator {
             if (changes.isEmpty()) {
 
                 // the method does not depend on the parameter at all!
-                // we replace all "return d;" by "return DifferentialPair.newConstant(d);"
+                // we replace all "return d;" by "return new DerivativeStructure(parameters, order, d);"
                 for (final Iterator<AbstractInsnNode> i = method.instructions.iterator(); i.hasNext();) {
                     final AbstractInsnNode insn = i.next();
                     if (insn.getOpcode() == Opcodes.DRETURN) {
                         final InsnList list = new InsnList();
+                        list.add(new VarInsnNode(Opcodes.ALOAD, 1));
+                        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
+                                                    Type.getInternalName(DerivativeStructure.class),
+                                                    "getFreeParameters",
+                                                    Type.getMethodDescriptor(Type.INT_TYPE)));
+                        list.add(new VarInsnNode(Opcodes.ALOAD, 1));
                         list.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
-                                                    Descriptors.DP_NAME,
-                                                    "newConstant",
-                                                    Descriptors.D_RETURN_DP_DESCRIPTOR));
+                                                    Type.getInternalName(DerivativeStructure.class),
+                                                    "getOrder",
+                                                    Type.getMethodDescriptor(Type.INT_TYPE)));
+                        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
+                                                    Type.getInternalName(DerivativeStructure.class),
+                                                    "<init>",
+                                                    Type.getMethodDescriptor(dsType, Type.INT_TYPE, Type.INT_TYPE)));
                         list.add(new InsnNode(Opcodes.ARETURN));
                         method.instructions.insert(insn, list);
                         method.instructions.remove(insn);
@@ -239,7 +251,10 @@ public class MethodDifferentiator {
             } else {
 
                 // perform the code changes
-                changeCode(method.instructions, changes);
+                for (final AbstractInsnNode insn : changes) {
+                    method.instructions.insert(insn, getReplacement(insn));
+                    method.instructions.remove(insn);
+                }
 
                 // trim generated instructions list
                 new SwappedDloadTrimmer().trim(method.instructions);
@@ -251,8 +266,8 @@ public class MethodDifferentiator {
             // remove the local variables added at the beginning and not used
             removeUnusedSpareLocalVariables(method.instructions);
 
-            // change the method properties to the derivative ones
-            method.desc       = Descriptors.DP_RETURN_DP_DESCRIPTOR;
+            // set the method properties
+            method.desc       = Type.getMethodDescriptor(dsType, dsType);
             method.access    |= Opcodes.ACC_SYNTHETIC;
             method.maxLocals  = maxVariables();
 
@@ -268,7 +283,7 @@ public class MethodDifferentiator {
     }
 
     /** Add spare cells for new local variables.
-     * <p>In order to ease conversion from double values to differential pairs,
+     * <p>In order to ease conversion from double values to derivative structures,
      * we start by reserving one spare cell between each original local variables.
      * So we have to modify the indices in all instructions referencing local
      * variables in the original code, to take into account the renumbering
@@ -361,7 +376,7 @@ public class MethodDifferentiator {
             for (final AbstractInsnNode consumer : value.getConsumers()) {
 
                 // an instruction consuming a converted value and producing
-                // a double must be changed to produce a differential pair,
+                // a double must be changed to produce a derivative structure,
                 // get the double values produced and add them to the changed set
                 pending.addAll(getProducedAndNotConvertedDoubleValues(consumer));
 
@@ -441,35 +456,6 @@ public class MethodDifferentiator {
 
     }
 
-    /** Perform the code changes.
-     * @param instructions instructions of the method
-     * @param changes instructions that must be changed
-     * @exception DifferentiationException if some instruction cannot be handled
-     */
-    private void changeCode(final InsnList instructions, final Set<AbstractInsnNode> changes)
-        throws DifferentiationException {
-
-        // insert the parameter conversion code at method start
-        final InsnList list = new InsnList();
-        list.add(new VarInsnNode(Opcodes.ALOAD, 1));
-        list.add(new InsnNode(Opcodes.DUP));
-        list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, Descriptors.DP_NAME,
-                                    "getValue", Descriptors.VOID_RETURN_D_DESCRIPTOR));
-        list.add(new VarInsnNode(Opcodes.DSTORE, 1));
-        list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, Descriptors.DP_NAME,
-                                    "getFirstDerivative", Descriptors.VOID_RETURN_D_DESCRIPTOR));
-        list.add(new VarInsnNode(Opcodes.DSTORE, 3));
-
-        instructions.insertBefore(instructions.get(0), list);
-
-        // transform the existing instructions
-        for (final AbstractInsnNode insn : changes) {
-            instructions.insert(insn, getReplacement(insn));
-            instructions.remove(insn);
-        }
-
-    }
-
     /** Get the replacement list for an instruction.
      * @param insn instruction to replace
      * @return replacement instructions list
@@ -690,9 +676,9 @@ public class MethodDifferentiator {
     /** Replace an INVOKESTATIC instruction.
      * @param methodInsn invocation instruction
      * @param stack1Converted if true, the stack sub-head has been
-     * converted to differential pair
+     * converted to derivative structure
      * @param stack0Converted if true, the stack head has been
-     * converted to differential pair
+     * converted to derivative structure
      * @return replacement instructions list
      * @exception DifferentiationException if the instruction cannot be replaced
      */
@@ -748,7 +734,7 @@ public class MethodDifferentiator {
     /** Set a local variable as used by the modified code.
      * @param index index of the variable
      * @param size size of the variable (1 or 2 for standard variables,
-     * 4 for special expanded differential pairs)
+     * 4 for special expanded derivative structures)
      * @exception DifferentiationException if the number of the
      * temporary variable lies outside of the allowed range
      */

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer1.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer1.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer1.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DADD instructions.
  * <p>This transformer is used when only the first argument
- * of DADD is an expanded differential pair. It implements the
+ * of DADD is an expanded derivative structure. It implements the
  * classical differentiation rules for addition.</p>
  * @see DAddTransformer12
  * @see DAddTransformer2

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer12.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer12.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer12.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DADD instructions.
  * <p>This transformer is used when both arguments of DADD are
- * expanded differential pairs. It implements the classical
+ * expanded derivative structures. It implements the classical
  * differentiation rules for addition.</p>
  * @see DAddTransformer1
  * @see DAddTransformer2

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer2.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer2.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DAddTransformer2.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DADD instructions.
  * <p>This transformer is used when only the second argument
- * of DADD is an expanded differential pair. It implements the
+ * of DADD is an expanded derivative structure. It implements the
  * classical differentiation rules for addition.</p>
  * @see DAddTransformer1
  * @see DAddTransformer12

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer1.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer1.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer1.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DDIV instructions.
  * <p>This transformer is used when only the first argument
- * of DDIV is an expanded differential pair. It implements the
+ * of DDIV is an expanded derivative structure. It implements the
  * classical differentiation rules for division.</p>
  * @see DDivTransformer12
  * @see DDivTransformer2

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer12.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer12.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer12.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DDIV instructions.
  * <p>This transformer is used when both arguments of DDIV are
- * expanded differential pairs. It implements the classical
+ * expanded derivative structures. It implements the classical
  * differentiation rules for division.</p>
  * @see DDivTransformer1
  * @see DDivTransformer2

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer2.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer2.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DDivTransformer2.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DDIV instructions.
  * <p>This transformer is used when only the second argument
- * of DDIV is an expanded differential pair. It implements the
+ * of DDIV is an expanded derivative structure. It implements the
  * classical differentiation rules for division.</p>
  * @see DDivTransformer1
  * @see DDivTransformer12

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer1.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer1.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer1.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DMUL instructions.
  * <p>This transformer is used when only the first argument
- * of DMUL is an expanded differential pair. It implements the
+ * of DMUL is an expanded derivative structure. It implements the
  * classical differentiation rules for multiplication.</p>
  * @see DMulTransformer12
  * @see DMulTransformer2

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer12.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer12.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer12.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DMUL instructions.
  * <p>This transformer is used when both arguments of DMUL are
- * expanded differential pairs. It implements the classical
+ * expanded derivative structures. It implements the classical
  * differentiation rules for multiplication.</p>
  * @see DMulTransformer1
  * @see DMulTransformer2

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer2.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer2.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DMulTransformer2.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DMUL instructions.
  * <p>This transformer is used when only the second argument
- * of DMUL is an expanded differential pair. It implements the
+ * of DMUL is an expanded derivative structure. It implements the
  * classical differentiation rules for multiplication.</p>
  * @see DMulTransformer1
  * @see DMulTransformer12

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer1.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer1.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer1.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DREM instructions.
  * <p>This transformer is used when only the first argument
- * of DREM is an expanded differential pair. It is based on
+ * of DREM is an expanded derivative structure. It is based on
  * the identity: <code>a%b = a - q * b</code> where q is an
  * integer.</p>
  * @see DRemTransformer12

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer12.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer12.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer12.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DREM instructions.
  * <p>This transformer is used when only the second argument
- * of DREM is an expanded differential pair. It is based on
+ * of DREM is an expanded derivative structure. It is based on
  * the identity: <code>a%b = a - q * b</code> where q is an
  * integer.</p>
  * @see DRemTransformer1

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer2.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer2.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DRemTransformer2.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DREM instructions.
  * <p>This transformer is used when only the second argument
- * of DREM is an expanded differential pair. It is based on
+ * of DREM is an expanded derivative structure. It is based on
  * the identity: <code>a%b = a - q * b</code> where q is an
  * integer.</p>
  * @see DRemTransformer1

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer1.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer1.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer1.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DSUB instructions.
  * <p>This transformer is used when only the first argument
- * of DSUB is an expanded differential pair. It implements the
+ * of DSUB is an expanded derivative structure. It implements the
  * classical differentiation rules for subtraction.</p>
  * @see DSubTransformer12
  * @see DSubTransformer2

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer12.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer12.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer12.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DSUB instructions.
  * <p>This transformer is used when both arguments of DSUB are
- * expanded differential pairs. It implements the classical
+ * expanded derivative structures. It implements the classical
  * differentiation rules for subtraction.</p>
  * @see DSubTransformer1
  * @see DSubTransformer2

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer2.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer2.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/arithmetic/DSubTransformer2.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DSUB instructions.
  * <p>This transformer is used when only the second argument
- * of DSUB is an expanded differential pair. It implements the
+ * of DSUB is an expanded derivative structure. It implements the
  * classical differentiation rules for subtraction.</p>
  * @see DSubTransformer1
  * @see DSubTransformer12

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DLoadTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DLoadTransformer.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DLoadTransformer.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DLoadTransformer.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 /** Differentiation transformer for DLOAD instructions.
  * <p>Each DLOAD instruction for double variable <i>k</i>
  * is replaced by two DLOAD instructions for double variables
- * <i>k</i> and <i>k+2</i> representing an expanded differential pair.
+ * <i>k</i> and <i>k+2</i> representing an expanded derivative structure.
  */
 public class DLoadTransformer implements InstructionsTransformer {
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DReturnTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DReturnTransformer.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DReturnTransformer.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DReturnTransformer.java Fri Sep 28 16:38:56 2012
@@ -16,11 +16,12 @@
  */
 package org.apache.commons.nabla.forward.instructions;
 
-import org.apache.commons.nabla.Descriptors;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
 import org.apache.commons.nabla.DifferentiationException;
 import org.apache.commons.nabla.forward.analysis.InstructionsTransformer;
 import org.apache.commons.nabla.forward.analysis.MethodDifferentiator;
 import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
 import org.objectweb.asm.tree.AbstractInsnNode;
 import org.objectweb.asm.tree.InsnList;
 import org.objectweb.asm.tree.InsnNode;
@@ -30,8 +31,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DRETURN instructions.
  * <p>DRETURN instructions are replaced by instructions
- * that build a {@link org.apache.commons.nabla.core.DifferentialPair
- * DifferentialPair} instance from the expanded differential pair
+ * that build a {@link DerivativeStructure} instance from the expanded derivative structure
  * on operand stack head and an ARETURN instruction returning this
  * instance.</p>
  */
@@ -47,20 +47,22 @@ public class DReturnTransformer implemen
                                    final MethodDifferentiator methodDifferentiator)
         throws DifferentiationException {
 
+        final Type dsType = Type.getType(DerivativeStructure.class);
+
         // reuse local variables slots 1, 2, 3 and 4 for temporary storage
         // (this may reduce the number of needed local variables)
         methodDifferentiator.useLocal(1, 4);
 
         final InsnList list = new InsnList();
         // operand stack initial state: a0, a1
-        list.add(new VarInsnNode(Opcodes.DSTORE, 3));                 // => a0
-        list.add(new VarInsnNode(Opcodes.DSTORE, 1));                 // =>
-        list.add(new TypeInsnNode(Opcodes.NEW, Descriptors.DP_NAME)); // => o,
-        list.add(new InsnNode(Opcodes.DUP));                          // => o, o
-        list.add(new VarInsnNode(Opcodes.DLOAD, 1));                  // => o, o, a0
-        list.add(new VarInsnNode(Opcodes.DLOAD, 3));                  // => o, o, a0, a1
+        list.add(new VarInsnNode(Opcodes.DSTORE, 3));                      // => a0
+        list.add(new VarInsnNode(Opcodes.DSTORE, 1));                      // =>
+        list.add(new TypeInsnNode(Opcodes.NEW, dsType.getInternalName())); // => o,
+        list.add(new InsnNode(Opcodes.DUP));                               // => o, o
+        list.add(new VarInsnNode(Opcodes.DLOAD, 1));                       // => o, o, a0
+        list.add(new VarInsnNode(Opcodes.DLOAD, 3));                       // => o, o, a0, a1
         list.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,
-                                    Descriptors.DP_NAME,
+                                    dsType.getInternalName(),
                                     "<init>", "(DD)V"));              // => dp
         list.add(new InsnNode(Opcodes.ARETURN));                      // =>
         return list;

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DStoreTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DStoreTransformer.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DStoreTransformer.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/DStoreTransformer.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 /** Differentiation transformer for DSTORE instructions.
  * <p>Each DSTORE instruction for double variable <i>k</i>
  * is replaced by two DSTORE instructions for double variables
- * <i>k+2</i> and <i>k</i> representing an expanded differential pair.
+ * <i>k+2</i> and <i>k</i> representing an expanded derivative structure.
  */
 public class DStoreTransformer implements InstructionsTransformer {
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2Transformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2Transformer.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2Transformer.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2Transformer.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DUP2 instructions.
  * <p>DUP2 instructions are replaced by instructions
- * that duplicate the two parts of a differential pair on stack.</p>
+ * that duplicate the two parts of a derivative structure on stack.</p>
  */
 public class Dup2Transformer implements InstructionsTransformer {
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X1Transformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X1Transformer.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X1Transformer.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X1Transformer.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DUP2_X1 instructions.
  * <p>DUP2_X1 instructions are replaced by instructions
- * that duplicate the two parts of a differential pair on stack.</p>
+ * that duplicate the two parts of a derivative structure on stack.</p>
  */
 public class Dup2X1Transformer implements InstructionsTransformer {
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer1.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer1.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer1.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DUP2_X2 instructions.
  * <p>DUP2_X2 instructions are replaced by instructions
- * that duplicate the two parts of a differential pair on stack.</p>
+ * that duplicate the two parts of a derivative structure on stack.</p>
  */
 public class Dup2X2Transformer1 implements InstructionsTransformer {
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer12.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer12.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer12.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DUP2_X2 instructions.
  * <p>DUP2_X2 instructions are replaced by instructions
- * that duplicate the two parts of a differential pair on stack.</p>
+ * that duplicate the two parts of a derivative structure on stack.</p>
  */
 public class Dup2X2Transformer12 implements InstructionsTransformer {
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer2.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer2.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/Dup2X2Transformer2.java Fri Sep 28 16:38:56 2012
@@ -27,7 +27,7 @@ import org.objectweb.asm.tree.VarInsnNod
 
 /** Differentiation transformer for DUP2_X2 instructions.
  * <p>DUP2_X2 instructions are replaced by instructions
- * that duplicate the two parts of a differential pair on stack.</p>
+ * that duplicate the two parts of a derivative structure on stack.</p>
  */
 public class Dup2X2Transformer2 implements InstructionsTransformer {
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/NarrowingTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/NarrowingTransformer.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/NarrowingTransformer.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/NarrowingTransformer.java Fri Sep 28 16:38:56 2012
@@ -26,7 +26,7 @@ import org.objectweb.asm.tree.InsnNode;
 
 /** Differentiation transformer for narrowing a differential part on the stack
  * to a double.
- * <p>Some instructions (D2I, D2L, D2F, POP2) may handle differential pair
+ * <p>Some instructions (D2I, D2L, D2F, POP2) may handle derivative structure
  * on the stack by simply popping the differential part out before being
  * applied.</p>
  */

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/WideningTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/WideningTransformer.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/WideningTransformer.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/forward/instructions/WideningTransformer.java Fri Sep 28 16:38:56 2012
@@ -25,9 +25,9 @@ import org.objectweb.asm.tree.InsnList;
 import org.objectweb.asm.tree.InsnNode;
 
 /** Differentiation transformer for promoting a double on the stack
- * to a differential pair.
+ * to a derivative structure.
  * <p>Some instructions pushing a double on the stack simply need to
- * be completed by pushing a 0 afterwards to form a differential pair
+ * be completed by pushing a 0 afterwards to form a derivative structure
  * representing a constant value. These instructions are replaced by
  * a copy of themselves followed by a DCONST_0 instruction.</p>
  */

Added: commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/localization/NablaMessages_fr.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/localization/NablaMessages_fr.properties?rev=1391531&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/localization/NablaMessages_fr.properties (added)
+++ commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/localization/NablaMessages_fr.properties Fri Sep 28 16:38:56 2012
@@ -0,0 +1,30 @@
+
+# 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.
+
+CANNOT_READ_CLASS = la classe {0} ne peut pas \u00eatre lue ({1})
+CANNOT_INSTANTIATE_ABSTRACT_CLASS = la classe abstraite {0} ne peut pas \u00eatre instanci\u00e9e ({1})
+ILLEGAL_ACCESS_TO_CONSTRUCTOR = acc\u00e8s ill\u00e9gal au constructeur de la classe {0} ({1})
+CANNOT_BUILD_CLASS_FROM_OTHER_CLASS = la classe {0} ne peut pas \u00eatre construite \u00e0 partir d''une instance de la classe {1} ({2})
+CANNOT_INSTANTIATE_CLASS_FROM_OTHER_INSTANCE = \u00e9chec de l''instanciation de la classe {0} \u00e0 partir d''une instance de la classe {1} ({2})
+INCORRECT_GENERATED_CODE = code incorrect pour la classe {0} g\u00e9n\u00e9r\u00e9e \u00e0 partir d''une instance de la classe {1} ({2})"),
+INTERFACE_NOT_FOUND_WHILE_DIFFERENTIATING = interface {0} non trouv\u00e9e lors de la diff\u00e9rentiation de la classe {1}
+CLASS_DOES_NOT_IMPLEMENT_INTERFACE = la classe {0} ne met pas en \u0153uvre l''interface {1}
+UNABLE_TO_ANALYZE_METHOD = impossible d''analyser la m\u00e9thode {0}.{1} ({2})
+NUMBER_OF_TEMPORARY_VARIABLES_OUT_OF_RANGE = num\u00e9ro de la variable temporaire ({0}) hors du domaine [{1}, {2}]
+INDEX_OF_LOCAL_VARIABLE_OUT_OF_RANGE = index ({1}) de la variable locale de taille {0} hors du domaine [{2}, {3}]
+UNEXPECTED_INSTRUCTION = instruction ayant l''opcode {0} inattendue
+UNABLE_TO_HANDLE_INSTRUCTION = incapable de g\u00e9rer une instruction ayant l''opcode {0}
+CANNOT_GET_VOID_FIELD = impossible de r\u00e9cup\u00e9rer la valeur du champ de type vide {0}

Propchange: commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/localization/NablaMessages_fr.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/nabla/trunk/src/main/resources/assets/org/apache/nabla/localization/NablaMessages_fr.properties
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractMathTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractMathTest.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractMathTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractMathTest.java Fri Sep 28 16:38:56 2012
@@ -16,27 +16,31 @@
  */
 package org.apache.commons.nabla;
 
-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.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
+import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
 import org.apache.commons.nabla.forward.ForwardModeAlgorithmicDifferentiator;
 import org.junit.Assert;
 
 
 public abstract class AbstractMathTest {
 
+    public interface ReferenceFunction extends UnivariateFunction {
+        double firstDerivative(double t);
+    }
+
     protected void checkReference(ReferenceFunction reference,
                                   double t0, double t1, int n,
                                   double threshold) {
         try {
             ForwardModeAlgorithmicDifferentiator differentiator = new ForwardModeAlgorithmicDifferentiator();
             differentiator.addMathImplementation(MathExtensions.class);
-            UnivariateDerivative derivative = differentiator.differentiate(reference);
+            UnivariateDifferentiableFunction 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);
-                Assert.assertEquals(reference.fPrime(t), derivative.f(dpT).getFirstDerivative(), threshold);
-                Assert.assertEquals(reference.f(t), derivative.f(dpT).getValue(), threshold);
+                DerivativeStructure dpT = new DerivativeStructure(1, 1, 0, t);
+                Assert.assertEquals(reference.firstDerivative(t), derivative.value(dpT).getPartialDerivative(1), threshold);
+                Assert.assertEquals(reference.value(t), derivative.value(dpT).getValue(), threshold);
             }
         } catch (DifferentiationException de) {
             Assert.fail(de.getMessage());

Added: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMessagesTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMessagesTest.java?rev=1391531&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMessagesTest.java (added)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/NablaMessagesTest.java Fri Sep 28 16:38:56 2012
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+/**
+ * This file is an adapted version of OrekitMessagesTest test class
+ * for the <a href="https://www.orekit.org/forge/projects/orekit">orekit</a> library.
+ * The original file is distributed under the terms of the Apache 2 license and is:
+ * Copyright 2010 CS Communication & Systèmes
+ */
+package org.apache.commons.nabla;
+
+
+import java.text.MessageFormat;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class NablaMessagesTest {
+
+    @Test
+    public void testMessageNumber() {
+        Assert.assertEquals(14, NablaMessages.values().length);
+    }
+
+    @Test
+    public void testAllKeysPresentInPropertiesFiles() {
+        final String path = NablaMessages.class.getName().replaceAll("\\.", "/");
+        for (final String language : new String[] { "fr" } ) {
+            ResourceBundle bundle =
+                ResourceBundle.getBundle("assets/" + path, new Locale(language));
+            for (NablaMessages message : NablaMessages.values()) {
+                final String messageKey = message.toString();
+                boolean keyPresent = false;
+                for (final Enumeration<String> keys = bundle.getKeys(); keys.hasMoreElements();) {
+                    keyPresent |= messageKey.equals(keys.nextElement());
+                }
+                Assert.assertTrue("missing key \"" + message.name() + "\" for language " + language,
+                                  keyPresent);
+            }
+            Assert.assertEquals(language, bundle.getLocale().getLanguage());
+        }
+
+    }
+
+    @Test
+    public void testAllPropertiesCorrespondToKeys() {
+        final String path = NablaMessages.class.getName().replaceAll("\\.", "/");
+        for (final String language : new String[] { "fr" } ) {
+            ResourceBundle bundle =
+                ResourceBundle.getBundle("assets/" + path, new Locale(language));
+            for (final Enumeration<String> keys = bundle.getKeys(); keys.hasMoreElements();) {
+                final String propertyKey = keys.nextElement();
+                try {
+                    Assert.assertNotNull(NablaMessages.valueOf(propertyKey));
+                } catch (IllegalArgumentException iae) {
+                    Assert.fail("unknown key \"" + propertyKey + "\" in language " + language);
+                }
+            }
+            Assert.assertEquals(language, bundle.getLocale().getLanguage());
+        }
+
+    }
+
+    @Test
+    public void testNoMissingFrenchTranslation() {
+        for (NablaMessages message : NablaMessages.values()) {
+            String translated = message.getLocalizedString(Locale.FRENCH);
+            Assert.assertFalse(message.name(), translated.toLowerCase().contains("missing translation"));
+        }
+    }
+
+    @Test
+    public void testNoOpEnglishTranslation() {
+        for (NablaMessages message : NablaMessages.values()) {
+            String translated = message.getLocalizedString(Locale.ENGLISH);
+            Assert.assertEquals(message.getSourceString(), translated);
+        }
+    }
+
+    @Test
+    public void testVariablePartsConsistency() {
+        for (final String language : new String[] { "fr" } ) {
+            Locale locale = new Locale(language);
+            for (NablaMessages message : NablaMessages.values()) {
+                MessageFormat source     = new MessageFormat(message.getSourceString());
+                MessageFormat translated = new MessageFormat(message.getLocalizedString(locale));
+                Assert.assertEquals(message.name() + " (" + language + ")",
+                                    source.getFormatsByArgumentIndex().length,
+                                    translated.getFormatsByArgumentIndex().length);
+            }
+        }
+    }
+
+}

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

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

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/ForwardAlgorithmicDifferentiatorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/ForwardAlgorithmicDifferentiatorTest.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/ForwardAlgorithmicDifferentiatorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/ForwardAlgorithmicDifferentiatorTest.java Fri Sep 28 16:38:56 2012
@@ -16,12 +16,10 @@
  */
 package org.apache.commons.nabla.forward;
 
+import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
+import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction;
 import org.apache.commons.nabla.AbstractMathTest;
-import org.apache.commons.nabla.ReferenceFunction;
-import org.apache.commons.nabla.core.DifferentialPair;
-import org.apache.commons.nabla.core.UnivariateDerivative;
-import org.apache.commons.nabla.core.UnivariateDifferentiable;
-import org.apache.commons.nabla.forward.ForwardModeAlgorithmicDifferentiator;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -30,92 +28,92 @@ public class ForwardAlgorithmicDifferent
     @Test
     public void testSingleCall() {
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return Math.cos(t); }
-            public double fPrime(double t) { return -Math.sin(t); }
+            public double value(double t) { return Math.cos(t); }
+            public double firstDerivative(double t) { return -Math.sin(t); }
         }, 0, 2 * Math.PI, 20, 0.0);
     }
 
     @Test
     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)); }
+            public double value(double t) { return Math.exp(Math.sin(t)); }
+            public double firstDerivative(double t) { return Math.cos(t) * Math.exp(Math.sin(t)); }
         }, 0.1, 10, 20, 0);
     }
 
     @Test
     public void testParameterIndependent() {
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return 1; }
-            public double fPrime(double t) { return 0; }
+            public double value(double t) { return 1; }
+            public double firstDerivative(double t) { return 0; }
         }, 0.1, 5, 20, 2.0e-12);
     }
 
     @Test
     public void testSimpleExpression() {
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return 1.0 / t; }
-            public double fPrime(double t) { return -1 / (t * t); }
+            public double value(double t) { return 1.0 / t; }
+            public double firstDerivative(double t) { return -1 / (t * t); }
         }, 0.1, 5, 20, 2.0e-12);
     }
 
     @Test
     public void testMul() {
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return t * t; }
-            public double fPrime(double t) { return 2 * t; }
+            public double value(double t) { return t * t; }
+            public double firstDerivative(double t) { return 2 * t; }
         }, 0.1, 5, 20, 2.0e-12);
     }
 
     @Test
     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; }
+            public double value(double t) { return (((4 * t + 2) * t + 1) * t - 2) * t + 5; }
+            public double firstDerivative(double t) { return ((16 * t + 6) * t + 2) * t - 2; }
         }, 0.1, 5, 20, 2.0e-12);
     }
 
     @Test
     public void testNarrowing() {
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return t - (int) t; }
-            public double fPrime(double t) { return 1; }
+            public double value(double t) { return t - (int) t; }
+            public double firstDerivative(double t) { return 1; }
         }, 0.1, 5, 20, 0);
     }
 
     @Test
     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; }
+            public double value(double t) { double threeT = 3 * t; return threeT * threeT; }
+            public double firstDerivative(double t) { return 18 * t; }
         }, -5, 5, 20, 2.0e-14);
     }
 
     @Test
     public void testLoopLdc() {
         checkReference(new ReferenceFunction() {
-            public double f(double t) {
+            public double value(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; }
+            public double firstDerivative(double t) { return 6 * t * t; }
         }, -5, 5, 20, 4.0e-14);
     }
 
     @Test
     public void testLoopDcons() {
         checkReference(new ReferenceFunction() {
-            public double f(double t) {
+            public double value(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; }
+            public double firstDerivative(double t) { return 3 * t * t; }
         }, -5, 5, 20, 4.0e-14);
     }
 
@@ -123,17 +121,17 @@ public class ForwardAlgorithmicDifferent
     public void testPartialDerivatives() throws Exception {
         PartialFunction function = new PartialFunction(1);
 
-        final UnivariateDerivative derivative = new
+        final UnivariateDifferentiableFunction derivative = new
                 ForwardModeAlgorithmicDifferentiator().differentiate(function);
-        DifferentialPair t = DifferentialPair.newVariable(1);
-        Assert.assertEquals(3, derivative.f(t).getFirstDerivative(), 0);
-        Assert.assertEquals(2, derivative.f(t).getValue(), 0);
+        DerivativeStructure t = new DerivativeStructure(1, 1, 0, 1.0);
+        Assert.assertEquals(3, derivative.value(t).getPartialDerivative(1), 0);
+        Assert.assertEquals(2, derivative.value(t).getValue(), 0);
         function.setX(2);
-        Assert.assertEquals(4, derivative.f(t).getFirstDerivative(), 0);
-        Assert.assertEquals(3, derivative.f(t).getValue(), 0);
+        Assert.assertEquals(4, derivative.value(t).getPartialDerivative(1), 0);
+        Assert.assertEquals(3, derivative.value(t).getValue(), 0);
     }
 
-    public class PartialFunction implements UnivariateDifferentiable {
+    public class PartialFunction implements UnivariateFunction {
         private double x;
         public PartialFunction(double x) {
             this.x = x;
@@ -144,7 +142,7 @@ public class ForwardAlgorithmicDifferent
         public double getX() {
             return x;
         }
-        public double f(double y) {
+        public double value(double y) {
             return x * y + y * y;
         }
     }

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DAddGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DAddGeneratorTest.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DAddGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DAddGeneratorTest.java Fri Sep 28 16:38:56 2012
@@ -17,7 +17,6 @@
 package org.apache.commons.nabla.forward.arithmetic;
 
 import org.apache.commons.nabla.AbstractMathTest;
-import org.apache.commons.nabla.ReferenceFunction;
 import org.junit.Test;
 
 public class DAddGeneratorTest extends AbstractMathTest {
@@ -25,24 +24,24 @@ public class DAddGeneratorTest extends A
     @Test
     public void testReference1(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return t + 5; }
-            public double fPrime(double t) { return 1; }
+            public double value(double t) { return t + 5; }
+            public double firstDerivative(double t) { return 1; }
         }, -0.99, 0.99, 30, 0.0);
     }
 
     @Test
     public void testReference2(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return 5 + t; }
-            public double fPrime(double t) { return 1; }
+            public double value(double t) { return 5 + t; }
+            public double firstDerivative(double t) { return 1; }
         }, -0.99, 0.99, 30, 0.0);
     }
 
     @Test
     public void testReference12(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return t + t; }
-            public double fPrime(double t) { return 2; }
+            public double value(double t) { return t + t; }
+            public double firstDerivative(double t) { return 2; }
         }, -0.99, 0.99, 30, 0.0);
     }
 

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DDivGeneratorTest.java Fri Sep 28 16:38:56 2012
@@ -17,7 +17,6 @@
 package org.apache.commons.nabla.forward.arithmetic;
 
 import org.apache.commons.nabla.AbstractMathTest;
-import org.apache.commons.nabla.ReferenceFunction;
 import org.junit.Test;
 
 public class DDivGeneratorTest extends AbstractMathTest {
@@ -25,24 +24,24 @@ public class DDivGeneratorTest extends A
     @Test
     public void testReference1(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return t / 5; }
-            public double fPrime(double t) { return 1.0 / 5.0; }
+            public double value(double t) { return t / 5; }
+            public double firstDerivative(double t) { return 1.0 / 5.0; }
         }, 0.1, 10, 30, 0.0);
     }
 
     @Test
     public void testReference2(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return 5 / t; }
-            public double fPrime(double t) { return -5 / (t * t); }
+            public double value(double t) { return 5 / t; }
+            public double firstDerivative(double t) { return -5 / (t * t); }
         }, 0.5, 10, 30, 1e-15);
     }
 
     @Test
     public void testReference12(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return t / t; }
-            public double fPrime(double t) { return 0; }
+            public double value(double t) { return t / t; }
+            public double firstDerivative(double t) { return 0; }
         }, 0.1, 10, 30, 0.0);
     }
 

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DMulGeneratorTest.java Fri Sep 28 16:38:56 2012
@@ -17,7 +17,6 @@
 package org.apache.commons.nabla.forward.arithmetic;
 
 import org.apache.commons.nabla.AbstractMathTest;
-import org.apache.commons.nabla.ReferenceFunction;
 import org.junit.Test;
 
 public class DMulGeneratorTest extends AbstractMathTest {
@@ -25,24 +24,24 @@ public class DMulGeneratorTest extends A
     @Test
     public void testReference1(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return t * 5; }
-            public double fPrime(double t) { return 5; }
+            public double value(double t) { return t * 5; }
+            public double firstDerivative(double t) { return 5; }
         }, -0.99, 0.99, 30, 0.0);
     }
 
     @Test
     public void testReference2(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return 5 * t; }
-            public double fPrime(double t) { return 5; }
+            public double value(double t) { return 5 * t; }
+            public double firstDerivative(double t) { return 5; }
         }, -0.99, 0.99, 30, 0.0);
     }
 
     @Test
     public void testReference12(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return t * t; }
-            public double fPrime(double t) { return 2 * t; }
+            public double value(double t) { return t * t; }
+            public double firstDerivative(double t) { return 2 * t; }
         }, -0.99, 0.99, 30, 0.0);
     }
 

Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DNegGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DNegGeneratorTest.java?rev=1391531&r1=1391530&r2=1391531&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DNegGeneratorTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/forward/arithmetic/DNegGeneratorTest.java Fri Sep 28 16:38:56 2012
@@ -17,7 +17,6 @@
 package org.apache.commons.nabla.forward.arithmetic;
 
 import org.apache.commons.nabla.AbstractMathTest;
-import org.apache.commons.nabla.ReferenceFunction;
 import org.junit.Test;
 
 public class DNegGeneratorTest extends AbstractMathTest {
@@ -25,8 +24,8 @@ public class DNegGeneratorTest extends A
     @Test
     public void testReference(){
         checkReference(new ReferenceFunction() {
-            public double f(double t) { return -t; }
-            public double fPrime(double t) { return -1; }
+            public double value(double t) { return -t; }
+            public double firstDerivative(double t) { return -1; }
         }, -0.99, 0.99, 30, 0.0);
     }