X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/c7f552fd8888da2f0d8cfb228fe0f28d3df3a12c..b4b6f2ea75b9f0f3ca918f5b84016610bf7a4d4f:/interpretor/preprocessor/faust-0.9.47mr3/compiler/extended/log10prim.cpp diff --git a/interpretor/preprocessor/faust-0.9.47mr3/compiler/extended/log10prim.cpp b/interpretor/preprocessor/faust-0.9.47mr3/compiler/extended/log10prim.cpp new file mode 100644 index 0000000..f93cc93 --- /dev/null +++ b/interpretor/preprocessor/faust-0.9.47mr3/compiler/extended/log10prim.cpp @@ -0,0 +1,69 @@ +#include "xtended.hh" +#include "Text.hh" +#include + +#include "floats.hh" + + +class Log10Prim : public xtended +{ + + public: + + Log10Prim() : xtended("log10f") {} + + virtual unsigned int arity () { return 1; } + + virtual bool needCache () { return true; } + + virtual Type infereSigType (const vector& args) + { + assert (args.size() == arity()); + interval i = args[0]->getInterval(); + if (i.valid && (i.lo > 0)) { + return castInterval(floatCast(args[0]), interval(log10(i.lo), log10(i.hi))); + } else { + return floatCast(args[0]); + } + } + + virtual void sigVisit (Tree sig, sigvisitor* visitor) {} + + virtual int infereSigOrder (const vector& args) { + assert (args.size() == arity()); + return args[0]; + } + + + virtual Tree computeSigOutput (const vector& args) { + num n; + assert (args.size() == arity()); + if (isNum(args[0],n)) { + return tree(log10(double(n))); + } else { + return tree(symbol(), args[0]); + } + } + + virtual string generateCode (Klass* klass, const vector& args, const vector& types) + { + assert (args.size() == arity()); + assert (types.size() == arity()); + + return subst("log10$1($0)", args[0], isuffix()); + } + + virtual string generateLateq (Lateq* lateq, const vector& args, const vector& types) + { + assert (args.size() == arity()); + assert (types.size() == arity()); + + return subst("\\log_{10}\\left( $0 \\right)", args[0]); + } + +}; + + +xtended* gLog10Prim = new Log10Prim(); + +