d9dc7cb009a6518c83b63da44dce791b60af879b
7 class Atan2Prim
: public xtended
12 Atan2Prim() : xtended("atantwo") {}
14 virtual unsigned int arity () { return 2; }
16 virtual bool needCache () { return true; }
18 virtual Type
infereSigType (const vector
<Type
>& args
)
20 assert (args
.size() == 2);
21 return floatCast(args
[0]|args
[1]);
24 virtual void sigVisit (Tree sig
, sigvisitor
* visitor
) {}
26 virtual int infereSigOrder (const vector
<int>& args
) {
27 return max(args
[0], args
[1]);
31 virtual Tree
computeSigOutput (const vector
<Tree
>& args
)
33 assert (args
.size() == 2);
35 if (isNum(args
[0],n
) && isNum(args
[1],m
)) {
36 return tree(atan2(double(n
), double(m
)));
38 return tree(symbol(), args
[0], args
[1]);
42 virtual string
generateCode (Klass
* klass
, const vector
<string
>& args
, const vector
<Type
>& types
)
44 assert (args
.size() == arity());
45 assert (types
.size() == arity());
47 return subst("atan2$2($0,$1)", args
[0], args
[1], isuffix());
50 virtual string
generateLateq (Lateq
* lateq
, const vector
<string
>& args
, const vector
<Type
>& types
)
52 assert (args
.size() == arity());
53 assert (types
.size() == arity());
55 return subst("\\arctan\\frac{$0}{$1}", args
[0], args
[1]);
61 xtended
* gAtan2Prim
= new Atan2Prim();