7 class LogPrim
: public xtended
12 LogPrim() : xtended("log") {}
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() == arity());
21 interval i
= args
[0]->getInterval();
22 if (i
.valid
& i
.lo
>0) {
23 return castInterval(floatCast(args
[0]), interval(log(i
.lo
), log(i
.hi
)));
25 return floatCast(args
[0]);
29 virtual void sigVisit (Tree sig
, sigvisitor
* visitor
) {}
31 virtual int infereSigOrder (const vector
<int>& args
) {
32 assert (args
.size() == arity());
37 virtual Tree
computeSigOutput (const vector
<Tree
>& args
) {
39 assert (args
.size() == arity());
40 if (isNum(args
[0],n
)) {
41 return tree(log(double(n
)));
43 return tree(symbol(), args
[0]);
47 virtual string
generateCode (Klass
* klass
, const vector
<string
>& args
, const vector
<Type
>& types
)
49 assert (args
.size() == arity());
50 assert (types
.size() == arity());
52 return subst("log$1($0)", args
[0], isuffix());
55 virtual string
generateLateq (Lateq
* lateq
, const vector
<string
>& args
, const vector
<Type
>& types
)
57 assert (args
.size() == arity());
58 assert (types
.size() == arity());
60 return subst("\\ln\\left( $0 \\right)", args
[0]);
66 xtended
* gLogPrim
= new LogPrim();