commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r648239 [2/4] - in /commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic: ./ analysis/ arithmetic/ functions/ instructions/ trimming/
Date Tue, 15 Apr 2008 13:20:54 GMT
Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer1.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer1.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer1.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * classical differentiation rules for addition.</p>
+ * @see DAddTransformer12
+ * @see DAddTransformer2
+ */
+public class DAddTransformer1 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DAddTransformer1();
+    }
+
+    /** Hidden constructor.
+     */
+    private DAddTransformer1() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b
+        list.add(new InsnNode(Opcodes.DUP2_X2));        // => a0, b, a1, b
+        list.add(new InsnNode(Opcodes.POP2));           // => a0, b, a1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, b
+        list.add(new InsnNode(Opcodes.DADD));           // => a0+b
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a0+b, a1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer12.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer12.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer12.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DADD instructions.
+ * <p>This transformer is used when both arguments of DADD are
+ * expanded differential pairs. It implements the classical
+ * differentiation rules for addition.</p>
+ * @see DAddTransformer1
+ * @see DAddTransformer2
+ */
+public class DAddTransformer12 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DAddTransformer12();
+    }
+
+    /** Hidden constructor.
+     */
+    private DAddTransformer12() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, a1, b0
+        list.add(new InsnNode(Opcodes.DUP2_X2));        // => a0, b0, a1, b0
+        list.add(new InsnNode(Opcodes.POP2));           // => a0, b0, a1
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a0, b0, a1, b1
+        list.add(new InsnNode(Opcodes.DADD));           // => a0, b0, a1+b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, b0
+        list.add(new InsnNode(Opcodes.DADD));           // => a0+b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a0+b0, a1+b1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer12.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer2.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer2.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer2.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * classical differentiation rules for addition.</p>
+ * @see DAddTransformer1
+ * @see DAddTransformer12
+ */
+public class DAddTransformer2 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DAddTransformer2();
+    }
+
+    /** Hidden constructor.
+     */
+    private DAddTransformer2() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a, b0
+        list.add(new InsnNode(Opcodes.DADD));           // => a+b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a+b0, b1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DAddTransformer2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer1.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer1.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer1.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * classical differentiation rules for division.</p>
+ * @see DDivTransformer12
+ * @see DDivTransformer2
+ */
+public class DDivTransformer1 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DDivTransformer1();
+    }
+
+    /** Hidden constructor.
+     */
+    private DDivTransformer1() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b
+        list.add(new InsnNode(Opcodes.DUP2_X2));        // => a0, b, a1, b
+        list.add(new InsnNode(Opcodes.DDIV));           // => a0, b, a1/b
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, b
+        list.add(new InsnNode(Opcodes.DDIV));           // => a0/b
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a0/b, a1/b
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer12.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer12.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer12.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DDIV instructions.
+ * <p>This transformer is used when both arguments of DDIV are
+ * expanded differential pairs. It implements the classical
+ * differentiation rules for division.</p>
+ * @see DDivTransformer1
+ * @see DDivTransformer2
+ */
+public class DDivTransformer12 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DDivTransformer12();
+    }
+
+    /** Hidden constructor.
+     */
+    private DDivTransformer12() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp1 = methodDifferentiator.getTmp(1);
+        final int tmp2 = methodDifferentiator.getTmp(2);
+        final int tmp3 = methodDifferentiator.getTmp(3);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0, a1, b0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a0, a1, b0, b0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => a0, a1, b0
+        list.add(new InsnNode(Opcodes.DMUL));            // => a0, a1*b0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => a0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a0, a0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => a0, a0, b1
+        list.add(new InsnNode(Opcodes.DMUL));            // => a0, a0*b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => a0, b0
+        list.add(new InsnNode(Opcodes.DDIV));            // => a0/b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => a0/b0, a1*b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => a0/b0, a1*b0, a0*b1
+        list.add(new InsnNode(Opcodes.DSUB));            // => a0/b0, a1*b0-a0*b1
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => a0/b0, a1*b0-a0*b1, b0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a0/b0, a1*b0-a0*b1, b0, b0
+        list.add(new InsnNode(Opcodes.DMUL));            // => a0/b0, a1*b0-a0*b1, b0^2
+        list.add(new InsnNode(Opcodes.DDIV));            // => a0/b0, (a1*b0-a0*b1)/b0^2
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer12.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer2.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer2.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer2.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * classical differentiation rules for division.</p>
+ * @see DDivTransformer1
+ * @see DDivTransformer12
+ */
+public class DDivTransformer2 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DDivTransformer2();
+    }
+
+    /** Hidden constructor.
+     */
+    private DDivTransformer2() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp1 = methodDifferentiator.getTmp(1);
+        final int tmp2 = methodDifferentiator.getTmp(2);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a, b0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a, b0, b0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => a, b0
+        list.add(new InsnNode(Opcodes.DDIV));            // => a/b0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a/b0, a/b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => a/b0, a/b0, b1
+        list.add(new InsnNode(Opcodes.DMUL));            // => a/b0, a*b1/b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => a/b0, a*b1/b0, b0
+        list.add(new InsnNode(Opcodes.DDIV));            // => a/b0, a*b1/b0^2
+        list.add(new InsnNode(Opcodes.DNEG));            // => a/b0, -a*b1/b0^2
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DDivTransformer2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer1.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer1.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer1.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * classical differentiation rules for multiplication.</p>
+ * @see DMulTransformer12
+ * @see DMulTransformer2
+ */
+public class DMulTransformer1 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DMulTransformer1();
+    }
+
+    /** Hidden constructor.
+     */
+    private DMulTransformer1() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b
+        list.add(new InsnNode(Opcodes.DUP2_X2));        // => a0, b, a1, b
+        list.add(new InsnNode(Opcodes.DMUL));           // => a0, b, a1*b
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, b
+        list.add(new InsnNode(Opcodes.DMUL));           // => a0*b
+        list.add(new VarInsnNode(Opcodes.DLOAD, tmp));  // => a0*b, a1*b
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer12.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer12.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer12.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DMUL instructions.
+ * <p>This transformer is used when both arguments of DMUL are
+ * expanded differential pairs. It implements the classical
+ * differentiation rules for multiplication.</p>
+ * @see DMulTransformer1
+ * @see DMulTransformer2
+ */
+public class DMulTransformer12 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DMulTransformer12();
+    }
+
+    /** Hidden constructor.
+     */
+    private DMulTransformer12() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp1 = methodDifferentiator.getTmp(1);
+        final int tmp2 = methodDifferentiator.getTmp(2);
+        final int tmp3 = methodDifferentiator.getTmp(3);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0, a1, b0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a0, a1, b0, b0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => a0, a1, b0
+        list.add(new InsnNode(Opcodes.DMUL));            // => a0, a1*b0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => a0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a0, a0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => a0, a0, b1
+        list.add(new InsnNode(Opcodes.DMUL));            // => a0, a0*b1
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => a0, a0*b1, a1*b0
+        list.add(new InsnNode(Opcodes.DADD));            // => a0, a0*b1+a1*b0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => a0, b0
+        list.add(new InsnNode(Opcodes.DMUL));            // => a0*b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => a0*b0, a0*b1+a1*b0
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer12.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer2.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer2.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer2.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * classical differentiation rules for multiplication.</p>
+ * @see DMulTransformer1
+ * @see DMulTransformer12
+ */
+public class DMulTransformer2 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DMulTransformer2();
+    }
+
+    /** Hidden constructor.
+     */
+    private DMulTransformer2() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a, b0
+        list.add(new InsnNode(Opcodes.DUP2_X2));        // => b0, a, b0
+        list.add(new InsnNode(Opcodes.POP2));           // => b0, a
+        list.add(new InsnNode(Opcodes.DUP2));           // => b0, a, a
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => b0, a, a, b1
+        list.add(new InsnNode(Opcodes.DMUL));           // => b0, a, a*b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => b0, a
+        list.add(new InsnNode(Opcodes.DMUL));           // => a*b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a*b0, a*b1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DMulTransformer2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DNegTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DNegTransformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DNegTransformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DNegTransformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DNEG instructions.
+ */
+public class DNegTransformer implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DNegTransformer();
+    }
+
+    /** Hidden constructor.
+     */
+    private DNegTransformer() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp));
+        list.add(new InsnNode(Opcodes.DNEG));
+        list.add(new VarInsnNode(Opcodes.DLOAD, tmp));
+        list.add(new InsnNode(Opcodes.DNEG));
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DNegTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer1.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer1.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer1.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * the identity: <code>a%b = a - q * b</code> where q is an
+ * integer.</p>
+ * @see DRemTransformer12
+ * @see DRemTransformer2
+ */
+public class DRemTransformer1 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DRemTransformer1();
+    }
+
+    /** Hidden constructor.
+     */
+    private DRemTransformer1() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b
+        list.add(new InsnNode(Opcodes.DUP2_X2));        // => a0, b, a1, b
+        list.add(new InsnNode(Opcodes.POP2));           // => a0, b, a1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, b
+        list.add(new InsnNode(Opcodes.DREM));           // => a0%b
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a0%b, a1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer12.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer12.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer12.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * the identity: <code>a%b = a - q * b</code> where q is an
+ * integer.</p>
+ * @see DRemTransformer1
+ * @see DRemTransformer12
+ */
+public class DRemTransformer12 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DRemTransformer12();
+    }
+
+    /** Hidden constructor.
+     */
+    private DRemTransformer12() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp1 = methodDifferentiator.getTmp(1);
+        final int tmp2 = methodDifferentiator.getTmp(2);
+        final int tmp3 = methodDifferentiator.getTmp(3);
+        final int tmp4 = methodDifferentiator.getTmp(4);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0, a1, b0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => a0, a1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => a0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp4)); // =>
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp4)); // => a0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => a0, b0
+        list.add(new InsnNode(Opcodes.DREM));            // => a0%b0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a0%b0, a0%b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp4)); // => a0%b0, a0%b0, a0
+        list.add(new InsnNode(Opcodes.DSUB));            // => a0%b0, a0%b0-a0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => a0%b0, a0%b0-a0, b0
+        list.add(new InsnNode(Opcodes.DDIV));            // => a0%b0, -q
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => a0%b0, -q, b1
+        list.add(new InsnNode(Opcodes.DMUL));            // => a0%b0, -q*b1
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => a0%b0, -q*b1, a1
+        list.add(new InsnNode(Opcodes.DADD));            // => a0%b0, a1-q*b1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer12.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer2.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer2.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer2.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * the identity: <code>a%b = a - q * b</code> where q is an
+ * integer.</p>
+ * @see DRemTransformer1
+ * @see DRemTransformer12
+ */
+public class DRemTransformer2 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DRemTransformer2();
+    }
+
+    /** Hidden constructor.
+     */
+    private DRemTransformer2() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp1 = methodDifferentiator.getTmp(1);
+        final int tmp2 = methodDifferentiator.getTmp(2);
+        final int tmp3 = methodDifferentiator.getTmp(3);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a, b0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => a
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // =>
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => a
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => a, b0
+        list.add(new InsnNode(Opcodes.DREM));            // => a%b0
+        list.add(new InsnNode(Opcodes.DUP2));            // => a%b0, a%b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => a%b0, a%b0, a
+        list.add(new InsnNode(Opcodes.DSUB));            // => a%b0, a%b0-a
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => a%b0, a%b0-a, b0
+        list.add(new InsnNode(Opcodes.DDIV));            // => a%b0, -q
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => a%b0, -q, b1
+        list.add(new InsnNode(Opcodes.DMUL));            // => a%b0, -q*b1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DRemTransformer2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer1.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer1.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer1.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * classical differentiation rules for subtraction.</p>
+ * @see DSubTransformer12
+ * @see DSubTransformer2
+ */
+public class DSubTransformer1 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DSubTransformer1();
+    }
+
+    /** Hidden constructor.
+     */
+    private DSubTransformer1() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b
+        list.add(new InsnNode(Opcodes.DUP2_X2));        // => a0, b, a1, b
+        list.add(new InsnNode(Opcodes.POP2));           // => a0, b, a1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, b
+        list.add(new InsnNode(Opcodes.DSUB));           // => a0-b
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a0-b, a1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer12.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer12.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer12.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for DSUB instructions.
+ * <p>This transformer is used when both arguments of DSUB are
+ * expanded differential pairs. It implements the classical
+ * differentiation rules for subtraction.</p>
+ * @see DSubTransformer1
+ * @see DSubTransformer2
+ */
+public class DSubTransformer12 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DSubTransformer12();
+    }
+
+    /** Hidden constructor.
+     */
+    private DSubTransformer12() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a0, a1, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, a1, b0
+        list.add(new InsnNode(Opcodes.DUP2_X2));        // => a0, b0, a1, b0
+        list.add(new InsnNode(Opcodes.POP2));           // => a0, b0, a1
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a0, b0, a1, b1
+        list.add(new InsnNode(Opcodes.DSUB));           // => a0, b0, a1-b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, b0
+        list.add(new InsnNode(Opcodes.DSUB));           // => a0-b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a0-b0, a1-b1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer12.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer2.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer2.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer2.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.arithmetic;
+
+import org.apache.commons.nabla.automatic.analysis.InstructionsTransformer;
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** 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
+ * classical differentiation rules for subtraction.</p>
+ * @see DSubTransformer1
+ * @see DSubTransformer12
+ */
+public class DSubTransformer2 implements InstructionsTransformer {
+
+    /** Holder for the singleton instance.*/
+    private static class LazyHolder  {
+        /** The singleton instance. */
+        private static final InstructionsTransformer INSTANCE = new DSubTransformer2();
+    }
+
+    /** Hidden constructor.
+     */
+    private DSubTransformer2() {
+    }
+
+    /** Get the singleton instance.
+     * <p>We use here the Initialization on Demand Holder idiom.</p>
+     * @return the singleton instance
+     */
+    public static InstructionsTransformer getInstance() {
+        return LazyHolder.INSTANCE;
+    }
+
+    /** {@inheritDoc} */
+    public InsnList getReplacement(final AbstractInsnNode insn,
+                                   final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp = methodDifferentiator.getTmp(1);
+        final InsnList list = new InsnList();
+
+        // operand stack initial state: a, b0, b1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a, b0
+        list.add(new InsnNode(Opcodes.DSUB));           // => a-b0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp)); // => a-b0, b1
+        list.add(new InsnNode(Opcodes.DNEG));           // => a-b0, -b1
+
+        return list;
+
+    }
+
+}

Propchange: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/arithmetic/DSubTransformer2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AcosTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AcosTransformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AcosTransformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AcosTransformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+
+
+/** Differentiation transformer for the acos function invocation instructions.
+ */
+public class AcosTransformer implements MathInvocationTransformer {
+
+    /** {@inheritDoc} */
+    public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
+
+        // generate differential code
+        // ... u0, u1  --> ...  acos(u0), -u1 / sqrt(1 - u0 * u0)
+        final InsnList list = new InsnList();
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.DUP2));
+        list.add(new InsnNode(Opcodes.DMUL));
+        list.add(new InsnNode(Opcodes.DCONST_1));
+        list.add(new InsnNode(Opcodes.DSUB));
+        list.add(new InsnNode(Opcodes.DNEG));
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "sqrt", D_RETURN_D_DESCRIPTOR));
+        list.add(new InsnNode(Opcodes.DDIV));
+        list.add(new InsnNode(Opcodes.DNEG));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "acos", D_RETURN_D_DESCRIPTOR));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        return list;
+
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AcoshTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AcoshTransformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AcoshTransformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AcoshTransformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+
+/** Differentiation transformer for the acosh function invocation instructions.
+ * <p>As of java 6, the JVM does not supply an inverse hyperbolic
+ * cosine function (see <a
+ * href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4919337">bug
+ * 4919337</a>), so this generator will not be triggered for java 6 and below.</p>
+ */
+public class AcoshTransformer implements MathInvocationTransformer {
+
+    /** {@inheritDoc} */
+    public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
+
+        // generate differential code
+        // ... u0, u1  --> ...  acosh(u0), u1 / sqrt(u0 * u0 - 1)
+        final InsnList list = new InsnList();
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.DUP2));
+        list.add(new InsnNode(Opcodes.DMUL));
+        list.add(new InsnNode(Opcodes.DCONST_1));
+        list.add(new InsnNode(Opcodes.DSUB));
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "sqrt", D_RETURN_D_DESCRIPTOR));
+        list.add(new InsnNode(Opcodes.DDIV));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "acosh", D_RETURN_D_DESCRIPTOR));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        return list;
+
+    }
+}

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

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AsinTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AsinTransformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AsinTransformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AsinTransformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+
+/** Differentiation transformer for the asin function invocation instructions.
+ */
+public class AsinTransformer implements MathInvocationTransformer {
+
+    /** {@inheritDoc} */
+    public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
+
+        // generate differential code
+        // ... u0, u1  --> ...  asin(u0), u1 / sqrt(1 - u0 * u0)
+        final InsnList list = new InsnList();
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.DUP2));
+        list.add(new InsnNode(Opcodes.DMUL));
+        list.add(new InsnNode(Opcodes.DCONST_1));
+        list.add(new InsnNode(Opcodes.DSUB));
+        list.add(new InsnNode(Opcodes.DNEG));
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "sqrt", D_RETURN_D_DESCRIPTOR));
+        list.add(new InsnNode(Opcodes.DDIV));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "asin", D_RETURN_D_DESCRIPTOR));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        return list;
+
+    }
+}

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

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AsinhTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AsinhTransformer.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AsinhTransformer.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/AsinhTransformer.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+
+/** Differentiation transformer for the asinh function invocation instructions.
+ * <p>As of java 6, the JVM does not supply an inverse hyperbolic
+ * sine function (see <a
+ * href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4919337">bug
+ * 4919337</a>), so this generator will not be triggered for java 6 and below.</p>
+ */
+public class AsinhTransformer implements MathInvocationTransformer {
+
+    /** {@inheritDoc} */
+    public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
+
+        // generate differential code
+        // ... u0, u1  --> ...  asinh(u0), u1 / sqrt(u0 * u0 + 1)
+        final InsnList list = new InsnList();
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.DUP2));
+        list.add(new InsnNode(Opcodes.DMUL));
+        list.add(new InsnNode(Opcodes.DCONST_1));
+        list.add(new InsnNode(Opcodes.DADD));
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "sqrt", D_RETURN_D_DESCRIPTOR));
+        list.add(new InsnNode(Opcodes.DDIV));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "asinh", D_RETURN_D_DESCRIPTOR));
+        list.add(new InsnNode(Opcodes.DUP2_X2));
+        list.add(new InsnNode(Opcodes.POP2));
+        return list;
+
+    }
+}

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

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/Atan2Transformer1.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/Atan2Transformer1.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/Atan2Transformer1.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/Atan2Transformer1.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for the atan2 function invocation instructions.
+ */
+public class Atan2Transformer1 implements MathInvocationTransformer {
+
+    /** {@inheritDoc} */
+    public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp1 = methodDifferentiator.getTmp(1);
+        final int tmp2 = methodDifferentiator.getTmp(2);
+        final int tmp3 = methodDifferentiator.getTmp(3);
+
+        // generate differential code
+        // ... y0, y1, x  --> ...  atan2(y0, x), x*y1/(x^2+y0^2)
+        final InsnList list = new InsnList();
+        list.add(new InsnNode(Opcodes.DUP2_X2));         // => y0, x, y1, x
+        list.add(new InsnNode(Opcodes.DMUL));            // => y0, x, x*y1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => y0, x
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => y0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // =>
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => y0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => y0, x
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "atan2", DD_RETURN_D_DESCRIPTOR)); // => atan2(y0,x)
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => atan2(y0,x), x*y1
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => atan2(y0,x), x*y1, x
+        list.add(new InsnNode(Opcodes.DUP2));            // => atan2(y0,x), x*y1, x, x
+        list.add(new InsnNode(Opcodes.DMUL));            // => atan2(y0,x), x*y1, x^2
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => atan2(y0,x), x*y1, x^2, y0
+        list.add(new InsnNode(Opcodes.DUP2));            // => atan2(y0,x), x*y1, x^2, y0, y0
+        list.add(new InsnNode(Opcodes.DMUL));            // => atan2(y0,x), x*y1, x^2, y0^2
+        list.add(new InsnNode(Opcodes.DADD));            // => atan2(y0,x), x*y1, x^2+y0^2
+        list.add(new InsnNode(Opcodes.DDIV));            // => atan2(y0,x), x*y1/(x^2+y0^2)
+        return list;
+
+    }
+
+}

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

Added: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/Atan2Transformer12.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/Atan2Transformer12.java?rev=648239&view=auto
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/Atan2Transformer12.java (added)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/functions/Atan2Transformer12.java Tue Apr 15 06:20:36 2008
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.nabla.automatic.functions;
+
+import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator;
+import org.apache.commons.nabla.core.DifferentiationException;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.InsnList;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.MethodInsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/** Differentiation transformer for the atan2 function invocation instructions.
+ */
+public class Atan2Transformer12 implements MathInvocationTransformer {
+
+    /** {@inheritDoc} */
+    public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator)
+        throws DifferentiationException {
+
+        final int tmp1 = methodDifferentiator.getTmp(1);
+        final int tmp2 = methodDifferentiator.getTmp(2);
+        final int tmp3 = methodDifferentiator.getTmp(3);
+        final int tmp4 = methodDifferentiator.getTmp(4);
+
+        // generate differential code
+        // ... y0, y1, x0, x1  --> ...  atan2(y0, x0), (x0*y1x0*y1-x1*y00)/(x0^2+y0^2)
+        final InsnList list = new InsnList();
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp4)); // => y0, y1, x0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => y0, y1
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => y0
+        list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // =>
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => y0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => y0, x0
+        list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "atan2", DD_RETURN_D_DESCRIPTOR)); // => atan2(y0,x0)
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => atan2(y0,x0), x0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp2)); // => atan2(y0,x0), x0, y1
+        list.add(new InsnNode(Opcodes.DMUL));            // => atan2(y0,x0), x0*y1
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp4)); // => atan2(y0,x0), x0*y1, x1
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => atan2(y0,x0), x0*y1, x1, y0
+        list.add(new InsnNode(Opcodes.DMUL));            // => atan2(y0,x0), x0*y1, x1*y0
+        list.add(new InsnNode(Opcodes.DSUB));            // => atan2(y0,x0), x0*y1-x1*y0
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp3)); // => atan2(y0,x0), x0*y1-x1*y0, x0
+        list.add(new InsnNode(Opcodes.DUP2));            // => atan2(y0,x0), x0*y1-x1*y0, x0, x0
+        list.add(new InsnNode(Opcodes.DMUL));            // => atan2(y0,x0), x0*y1-x1*y0, x0^2
+        list.add(new VarInsnNode(Opcodes.DLOAD,  tmp1)); // => atan2(y0,x0), x0*y1-x1*y0, x0^2, y0
+        list.add(new InsnNode(Opcodes.DUP2));            // => atan2(y0,x0), x0*y1-x1*y0, x0^2, y0, y0
+        list.add(new InsnNode(Opcodes.DMUL));            // => atan2(y0,x0), x0*y1-x1*y0, x0^2, y0^2
+        list.add(new InsnNode(Opcodes.DADD));            // => atan2(y0,x0), x0*y1-x1*y0, x0^2+y0^2
+        list.add(new InsnNode(Opcodes.DDIV));            // => atan2(y0,x0), (x0*y1-x1*y0)/(x0^2+y0^2)
+        return list;
+
+    }
+
+}

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



Mime
View raw message