FAUST compiler
0.9.9.6b8
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
extended
logprim.cpp
Go to the documentation of this file.
1
#include "
xtended.hh
"
2
#include "
Text.hh
"
3
#include <math.h>
4
5
#include "
floats.hh
"
6
7
class
LogPrim
:
public
xtended
8
{
9
10
public
:
11
12
LogPrim
() :
xtended
(
"log"
) {}
13
14
virtual
unsigned
int
arity
() {
return
1; }
15
16
virtual
bool
needCache
() {
return
true
; }
17
18
virtual
Type
infereSigType
(
const
vector<Type>& args)
19
{
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)));
24
}
else
{
25
return
floatCast
(args[0]);
26
}
27
}
28
29
virtual
void
sigVisit
(
Tree
sig,
sigvisitor
* visitor) {}
30
31
virtual
int
infereSigOrder
(
const
vector<int>& args) {
32
assert (args.size() ==
arity
());
33
return
args[0];
34
}
35
36
37
virtual
Tree
computeSigOutput
(
const
vector<Tree>& args) {
38
num
n;
39
assert (args.size() ==
arity
());
40
if
(
isNum
(args[0],n)) {
41
return
tree
(log(
double
(n)));
42
}
else
{
43
return
tree
(
symbol
(), args[0]);
44
}
45
}
46
47
virtual
string
generateCode
(
Klass
* klass,
const
vector<string>& args,
const
vector<Type>& types)
48
{
49
assert (args.size() ==
arity
());
50
assert (types.size() ==
arity
());
51
52
return
subst
(
"log$1($0)"
, args[0],
isuffix
());
53
}
54
55
virtual
string
generateLateq
(
Lateq
* lateq,
const
vector<string>& args,
const
vector<Type>& types)
56
{
57
assert (args.size() ==
arity
());
58
assert (types.size() ==
arity
());
59
60
return
subst
(
"\\ln\\left( $0 \\right)"
, args[0]);
61
}
62
63
};
64
65
66
xtended
*
gLogPrim
=
new
LogPrim
();
67
68
LogPrim::sigVisit
virtual void sigVisit(Tree sig, sigvisitor *visitor)
Definition:
logprim.cpp:29
xtended.hh
LogPrim::generateLateq
virtual string generateLateq(Lateq *lateq, const vector< string > &args, const vector< Type > &types)
Definition:
logprim.cpp:55
LogPrim::arity
virtual unsigned int arity()
Definition:
logprim.cpp:14
num
Definition:
num.hh:58
isNum
bool isNum(Tree a)
Definition:
signals.hh:187
P
Definition:
smartpointer.hh:34
LogPrim::needCache
virtual bool needCache()
Definition:
logprim.cpp:16
CTree
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition:
tree.hh:109
LogPrim::LogPrim
LogPrim()
Definition:
logprim.cpp:12
Lateq
Definition:
lateq.hh:56
sigvisitor
Definition:
sigvisitor.hh:6
xtended
Definition:
xtended.hh:12
interval
Definition:
interval.hh:36
LogPrim::computeSigOutput
virtual Tree computeSigOutput(const vector< Tree > &args)
Definition:
logprim.cpp:37
floatCast
Type floatCast(Type t)
Definition:
sigtype.hh:270
subst
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition:
Text.cpp:47
Text.hh
Klass
Definition:
klass.hh:55
floats.hh
LogPrim::infereSigType
virtual Type infereSigType(const vector< Type > &args)
Definition:
logprim.cpp:18
xtended::symbol
Sym symbol()
Definition:
xtended.hh:24
LogPrim::infereSigOrder
virtual int infereSigOrder(const vector< int > &args)
Definition:
logprim.cpp:31
LogPrim
Definition:
logprim.cpp:7
tree
Tree tree(const Node &n)
Definition:
tree.hh:186
castInterval
Type castInterval(Type t, const interval &i)
Definition:
sigtype.hh:278
isuffix
const char * isuffix()
suffix for math functions
Definition:
floats.cpp:43
LogPrim::generateCode
virtual string generateCode(Klass *klass, const vector< string > &args, const vector< Type > &types)
Definition:
logprim.cpp:47
gLogPrim
xtended * gLogPrim
Definition:
logprim.cpp:66
Generated on Fri Sep 5 2014 18:06:36 for FAUST compiler by
1.8.7