788ca293f918252d83d212a8c31cce676c5a7e65
7 class SinPrim
: public xtended
12 SinPrim() : xtended("sin") {}
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(sin(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("sin$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("\\sin\\left($0\\right)", args
[0]);
59 xtended
* gSinPrim
= new SinPrim();