Bug fixed in the Makefile.
[Faustine.git] / interpretor / faust-0.9.47mr3 / compiler / extended / atan2prim.cpp
1 #include "xtended.hh"
2 #include "Text.hh"
3 #include <math.h>
4
5 #include "floats.hh"
6
7 class Atan2Prim : public xtended
8 {
9
10 public:
11
12 Atan2Prim() : xtended("atantwo") {}
13
14 virtual unsigned int arity () { return 2; }
15
16 virtual bool needCache () { return true; }
17
18 virtual Type infereSigType (const vector<Type>& args)
19 {
20 assert (args.size() == 2);
21 return floatCast(args[0]|args[1]);
22 }
23
24 virtual void sigVisit (Tree sig, sigvisitor* visitor) {}
25
26 virtual int infereSigOrder (const vector<int>& args) {
27 return max(args[0], args[1]);
28 }
29
30
31 virtual Tree computeSigOutput (const vector<Tree>& args)
32 {
33 assert (args.size() == 2);
34 num n,m;
35 if (isNum(args[0],n) && isNum(args[1],m)) {
36 return tree(atan2(double(n), double(m)));
37 } else {
38 return tree(symbol(), args[0], args[1]);
39 }
40 }
41
42 virtual string generateCode (Klass* klass, const vector<string>& args, const vector<Type>& types)
43 {
44 assert (args.size() == arity());
45 assert (types.size() == arity());
46
47 return subst("atan2$2($0,$1)", args[0], args[1], isuffix());
48 }
49
50 virtual string generateLateq (Lateq* lateq, const vector<string>& args, const vector<Type>& types)
51 {
52 assert (args.size() == arity());
53 assert (types.size() == arity());
54
55 return subst("\\arctan\\frac{$0}{$1}", args[0], args[1]);
56 }
57
58 };
59
60
61 xtended* gAtan2Prim = new Atan2Prim();
62
63