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 Atan2Transformer12 implements MathInvocationTransformer { |
30 | |
|
31 | |
|
32 | |
public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) |
33 | |
throws DifferentiationException { |
34 | |
|
35 | 2 | final int tmp1 = methodDifferentiator.getTmp(1); |
36 | 2 | final int tmp2 = methodDifferentiator.getTmp(2); |
37 | 2 | final int tmp3 = methodDifferentiator.getTmp(3); |
38 | 2 | final int tmp4 = methodDifferentiator.getTmp(4); |
39 | |
|
40 | |
|
41 | |
|
42 | 2 | final InsnList list = new InsnList(); |
43 | 2 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp4)); |
44 | 2 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); |
45 | 2 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); |
46 | 2 | list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); |
47 | 2 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); |
48 | 2 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp3)); |
49 | 2 | list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "atan2", DD_RETURN_D_DESCRIPTOR)); |
50 | 2 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp3)); |
51 | 2 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); |
52 | 2 | list.add(new InsnNode(Opcodes.DMUL)); |
53 | 2 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp4)); |
54 | 2 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); |
55 | 2 | list.add(new InsnNode(Opcodes.DMUL)); |
56 | 2 | list.add(new InsnNode(Opcodes.DSUB)); |
57 | 2 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp3)); |
58 | 2 | list.add(new InsnNode(Opcodes.DUP2)); |
59 | 2 | list.add(new InsnNode(Opcodes.DMUL)); |
60 | 2 | list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); |
61 | 2 | list.add(new InsnNode(Opcodes.DUP2)); |
62 | 2 | list.add(new InsnNode(Opcodes.DMUL)); |
63 | 2 | list.add(new InsnNode(Opcodes.DADD)); |
64 | 2 | list.add(new InsnNode(Opcodes.DDIV)); |
65 | 2 | return list; |
66 | |
|
67 | |
} |
68 | |
|
69 | |
} |