| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.apache.commons.nabla.automatic.functions; |
| 18 | |
|
| 19 | |
import org.apache.commons.nabla.automatic.analysis.MethodDifferentiator; |
| 20 | |
import org.apache.commons.nabla.core.DifferentiationException; |
| 21 | |
import org.objectweb.asm.Opcodes; |
| 22 | |
import org.objectweb.asm.tree.InsnList; |
| 23 | |
import org.objectweb.asm.tree.InsnNode; |
| 24 | |
import org.objectweb.asm.tree.MethodInsnNode; |
| 25 | |
import org.objectweb.asm.tree.VarInsnNode; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | 1 | public class Atan2Transformer2 implements MathInvocationTransformer { |
| 30 | |
|
| 31 | |
|
| 32 | |
public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) |
| 33 | |
throws DifferentiationException { |
| 34 | |
|
| 35 | 1 | final int tmp1 = methodDifferentiator.getTmp(1); |
| 36 | 1 | final int tmp2 = methodDifferentiator.getTmp(2); |
| 37 | 1 | final int tmp3 = methodDifferentiator.getTmp(3); |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | 1 | final InsnList list = new InsnList(); |
| 42 | 1 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); |
| 43 | 1 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); |
| 44 | 1 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); |
| 45 | 1 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); |
| 46 | 1 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); |
| 47 | 1 | list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "atan2", DD_RETURN_D_DESCRIPTOR)); |
| 48 | 1 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp3)); |
| 49 | 1 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); |
| 50 | 1 | list.add(new InsnNode(Opcodes.DMUL)); |
| 51 | 1 | list.add(new InsnNode(Opcodes.DNEG)); |
| 52 | 1 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); |
| 53 | 1 | list.add(new InsnNode(Opcodes.DUP2)); |
| 54 | 1 | list.add(new InsnNode(Opcodes.DMUL)); |
| 55 | 1 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); |
| 56 | 1 | list.add(new InsnNode(Opcodes.DUP2)); |
| 57 | 1 | list.add(new InsnNode(Opcodes.DMUL)); |
| 58 | 1 | list.add(new InsnNode(Opcodes.DADD)); |
| 59 | 1 | list.add(new InsnNode(Opcodes.DDIV)); |
| 60 | 1 | return list; |
| 61 | |
|
| 62 | |
} |
| 63 | |
|
| 64 | |
} |