7 class CosPrim
: public xtended
12 CosPrim() : xtended("cos") {}
14 virtual unsigned int arity () { return 1; }
16 virtual bool needCache () { return true; }
18 virtual Type
infereSigType (const vector
<Type
>& args
)
20 assert (args
.size() == 1);
21 return castInterval(floatCast(args
[0]), interval(-1,1));
24 virtual void sigVisit (Tree sig
, sigvisitor
* visitor
) {}
26 virtual int infereSigOrder (const vector
<int>& args
) {
31 virtual Tree
computeSigOutput (const vector
<Tree
>& args
) {
33 if (isNum(args
[0],n
)) {
34 return tree(cos(double(n
)));
36 return tree(symbol(), args
[0]);
40 virtual string
generateCode (Klass
* klass
, const vector
<string
>& args
, const vector
<Type
>& types
)
42 assert (args
.size() == arity());
43 assert (types
.size() == arity());
45 return subst("cos$1($0)", args
[0], isuffix());
48 virtual string
generateLateq (Lateq
* lateq
, const vector
<string
>& args
, const vector
<Type
>& types
)
50 assert (args
.size() == arity());
51 assert (types
.size() == arity());
53 return subst("\\cos\\left($0\\right)", args
[0]);
59 xtended
* gCosPrim
= new CosPrim();