commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r650634 - in /commons/sandbox/nabla/trunk/src: main/java/org/apache/commons/nabla/automatic/ main/java/org/apache/commons/nabla/automatic/analysis/ main/java/org/apache/commons/nabla/automatic/instructions/ test/java/org/apache/commons/nabl...
Date Tue, 22 Apr 2008 20:10:14 GMT
Author: luc
Date: Tue Apr 22 13:10:05 2008
New Revision: 650634

URL: http://svn.apache.org/viewvc?rev=650634&view=rev
Log:
moved AutomaticDifferentiator up in the hierarchy package
it is the entry point and it was completely hidden

Added:
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/AutomaticDifferentiator.java
      - copied, changed from r650019, commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiator.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AutomaticDifferentiatorTest.java
      - copied, changed from r650019, commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java
Removed:
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiator.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java
Modified:
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/ClassDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DReturnTransformer.java
    commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java

Copied: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/AutomaticDifferentiator.java
(from r650019, commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiator.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/AutomaticDifferentiator.java?p2=commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/AutomaticDifferentiator.java&p1=commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiator.java&r1=650019&r2=650634&rev=650634&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiator.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/AutomaticDifferentiator.java
Tue Apr 22 13:10:05 2008
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.automatic.analysis;
+package org.apache.commons.nabla.automatic;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -25,7 +25,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.commons.nabla.core.DifferentialPair;
+import org.apache.commons.nabla.automatic.analysis.ClassDifferentiator;
 import org.apache.commons.nabla.core.DifferentiationException;
 import org.apache.commons.nabla.core.UnivariateDerivative;
 import org.apache.commons.nabla.core.UnivariateDifferentiable;
@@ -51,15 +51,6 @@
  * @see org.apache.commons.nabla.Fetchdifferentiator
  */
 public class AutomaticDifferentiator implements UnivariateDifferentiator {
-
-    /** Name for the DifferentialPair class. */
-    public static final String DP_NAME = DifferentialPair.class.getName().replace('.', '/');
-
-    /** Descriptor for the DifferentialPair class. */
-    public static final String DP_DESCRIPTOR = "L" + DP_NAME + ";";
-
-    /** Descriptor for the derivative class f method. */
-    public static final String DP_RETURN_DP_DESCRIPTOR = "(" + DP_DESCRIPTOR + ")" + DP_DESCRIPTOR;
 
     /** UnivariateDifferentiable/UnivariateDerivative map. */
     private final HashMap<Class<? extends UnivariateDifferentiable>,

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/ClassDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/ClassDifferentiator.java?rev=650634&r1=650633&r2=650634&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/ClassDifferentiator.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/ClassDifferentiator.java
Tue Apr 22 13:10:05 2008
@@ -46,7 +46,7 @@
  * The visited class bytecode is not changed at all.
  * </p>
  */
-class ClassDifferentiator implements ClassVisitor {
+public class ClassDifferentiator implements ClassVisitor {
 
     /** Name for the primitive instance field. */
     private static final String PRIMITIVE_FIELD = "primitive";
@@ -155,7 +155,7 @@
             // get a generator for the method we are going to create
             final MethodVisitor visitor =
                 generator.visitMethod(access | Opcodes.ACC_SYNTHETIC, name,
-                                      AutomaticDifferentiator.DP_RETURN_DP_DESCRIPTOR, null,
null);
+                                      MethodDifferentiator.DP_RETURN_DP_DESCRIPTOR, null,
null);
 
             // make sure our own differentiator will be used to transform the code
             return new MethodDifferentiator(access, name, desc, signature, exceptions,

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java?rev=650634&r1=650633&r2=650634&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java
Tue Apr 22 13:10:05 2008
@@ -86,6 +86,7 @@
 import org.apache.commons.nabla.automatic.trimming.DLoadPop2Trimmer;
 import org.apache.commons.nabla.automatic.trimming.SwappedDloadTrimmer;
 import org.apache.commons.nabla.automatic.trimming.SwappedDstoreTrimmer;
+import org.apache.commons.nabla.core.DifferentialPair;
 import org.apache.commons.nabla.core.DifferentiationException;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
@@ -109,6 +110,15 @@
  */
 public class MethodDifferentiator extends MethodNode {
 
+    /** Name for the DifferentialPair class. */
+    public static final String DP_NAME = DifferentialPair.class.getName().replace('.', '/');
+
+    /** Descriptor for the DifferentialPair class. */
+    public static final String DP_DESCRIPTOR = "L" + DP_NAME + ";";
+
+    /** Descriptor for the derivative class f method. */
+    public static final String DP_RETURN_DP_DESCRIPTOR = "(" + DP_DESCRIPTOR + ")" + DP_DESCRIPTOR;
+
     /** Descriptor for <code>double f()</code> methods. */
     private static final String VOID_RETURN_D_DESCRIPTOR = "()D";
 
@@ -241,10 +251,7 @@
                 // the method does not depend on the parameter at all!
                 // we replace all code by a simple "return DifferentialPair.ZERO;"
                 instructions.clear();
-                instructions.add(new FieldInsnNode(Opcodes.GETSTATIC,
-                                                   AutomaticDifferentiator.DP_NAME,
-                                                   "ZERO",
-                                                   AutomaticDifferentiator.DP_DESCRIPTOR));
+                instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, DP_NAME, "ZERO", DP_DESCRIPTOR));
                 instructions.add(new InsnNode(Opcodes.ARETURN));
 
             } else {
@@ -263,7 +270,7 @@
             }
 
             // change the descriptor to its true final value
-            desc = AutomaticDifferentiator.DP_RETURN_DP_DESCRIPTOR;
+            desc = DP_RETURN_DP_DESCRIPTOR;
 
             // generate the method
             accept(generator);
@@ -460,15 +467,11 @@
         final InsnList list = new InsnList();
         list.add(new VarInsnNode(Opcodes.ALOAD, 1));
         list.add(new InsnNode(Opcodes.DUP));
-        list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
-                                    AutomaticDifferentiator.DP_NAME,
-                                    "getValue",
-                                    VOID_RETURN_D_DESCRIPTOR));
+        list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, DP_NAME,
+                                    "getValue", VOID_RETURN_D_DESCRIPTOR));
         list.add(new VarInsnNode(Opcodes.DSTORE, 1));
-        list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
-                                    AutomaticDifferentiator.DP_NAME,
-                                    "getFirstDerivative",
-                                    VOID_RETURN_D_DESCRIPTOR));
+        list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, DP_NAME,
+                                    "getFirstDerivative", VOID_RETURN_D_DESCRIPTOR));
         list.add(new VarInsnNode(Opcodes.DSTORE, 3));
 
         instructions.insertBefore(instructions.get(0), list);

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DReturnTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DReturnTransformer.java?rev=650634&r1=650633&r2=650634&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DReturnTransformer.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/instructions/DReturnTransformer.java
Tue Apr 22 13:10:05 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.nabla.automatic.instructions;
 
-import org.apache.commons.nabla.automatic.analysis.AutomaticDifferentiator;
 import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
 import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
 import org.apache.commons.nabla.core.DifferentiationException;
@@ -67,17 +66,17 @@
 
         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 VarInsnNode(Opcodes.DSTORE, 3));             // => a0
+        list.add(new VarInsnNode(Opcodes.DSTORE, 1));             // =>
         list.add(new TypeInsnNode(Opcodes.NEW,
-                                  AutomaticDifferentiator.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
+                                  MethodDifferentiator.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 MethodInsnNode(Opcodes.INVOKESPECIAL,
-                                    AutomaticDifferentiator.DP_NAME,
-                                    "<init>", "(DD)V"));        // => dp
-        list.add(new InsnNode(Opcodes.ARETURN));                // =>
+                                    MethodDifferentiator.DP_NAME,
+                                    "<init>", "(DD)V"));          // => dp
+        list.add(new InsnNode(Opcodes.ARETURN));                  // =>
         return list;
 
     }

Modified: 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=650634&r1=650633&r2=650634&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java
(original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java
Tue Apr 22 13:10:05 2008
@@ -17,7 +17,6 @@
 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;

Copied: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AutomaticDifferentiatorTest.java
(from r650019, 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/AutomaticDifferentiatorTest.java?p2=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AutomaticDifferentiatorTest.java&p1=commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java&r1=650019&r2=650634&rev=650634&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/analysis/AutomaticDifferentiatorTest.java
(original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AutomaticDifferentiatorTest.java
Tue Apr 22 13:10:05 2008
@@ -14,10 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.nabla.automatic.analysis;
+package org.apache.commons.nabla.automatic;
 
 import org.apache.commons.nabla.ReferenceFunction;
-import org.apache.commons.nabla.automatic.AbstractMathTest;
 
 public class AutomaticDifferentiatorTest extends AbstractMathTest {
 



Mime
View raw message