FAUST compiler
0.9.9.6b8
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
extended
fmodprim.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
FmodPrim
:
public
xtended
8
{
9
10
public
:
11
12
FmodPrim
() :
xtended
(
"fmod"
) {}
13
14
virtual
unsigned
int
arity
() {
return
2; }
15
16
virtual
bool
needCache
() {
return
true
; }
17
18
virtual
Type
infereSigType
(
const
vector<Type>& args)
19
{
20
assert (args.size() ==
arity
());
21
return
floatCast
(args[0]|args[1]);
22
}
23
24
virtual
void
sigVisit
(
Tree
sig,
sigvisitor
* visitor) {}
25
26
virtual
int
infereSigOrder
(
const
vector<int>& args) {
27
assert (args.size() ==
arity
());
28
return
max
(args[0], args[1]);
29
}
30
31
32
virtual
Tree
computeSigOutput
(
const
vector<Tree>& args) {
33
num
n,m;
34
assert (args.size() ==
arity
());
35
if
(
isNum
(args[0],n) &
isNum
(args[1],m)) {
36
return
tree
(fmod(
double
(n),
double
(m)));
37
}
else
{
38
return
tree
(
symbol
(), args[0], args[1]);
39
}
40
}
41
42
virtual
string
generateCode
(
Klass
* klass,
const
vector<string>& args,
const
vector<Type>& types)
43
{
44
assert (args.size() ==
arity
());
45
assert (types.size() ==
arity
());
46
47
return
subst
(
"fmod$2($0,$1)"
, args[0], args[1],
isuffix
());
48
}
49
50
virtual
string
generateLateq
(
Lateq
* lateq,
const
vector<string>& args,
const
vector<Type>& types)
51
{
52
assert (args.size() ==
arity
());
53
assert (types.size() ==
arity
());
54
55
return
subst
(
"$0\\pmod{$1}"
, args[0], args[1]);
56
}
57
58
};
59
60
61
xtended
*
gFmodPrim
=
new
FmodPrim
();
62
63
xtended.hh
num
Definition:
num.hh:58
isNum
bool isNum(Tree a)
Definition:
signals.hh:187
FmodPrim::arity
virtual unsigned int arity()
Definition:
fmodprim.cpp:14
P
Definition:
smartpointer.hh:34
CTree
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition:
tree.hh:109
Lateq
Definition:
lateq.hh:56
sigvisitor
Definition:
sigvisitor.hh:6
xtended
Definition:
xtended.hh:12
max
double max(double x, double y)
Definition:
interval.hh:60
FmodPrim::sigVisit
virtual void sigVisit(Tree sig, sigvisitor *visitor)
Definition:
fmodprim.cpp:24
FmodPrim::infereSigType
virtual Type infereSigType(const vector< Type > &args)
Definition:
fmodprim.cpp:18
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
FmodPrim::computeSigOutput
virtual Tree computeSigOutput(const vector< Tree > &args)
Definition:
fmodprim.cpp:32
floats.hh
FmodPrim::generateLateq
virtual string generateLateq(Lateq *lateq, const vector< string > &args, const vector< Type > &types)
Definition:
fmodprim.cpp:50
xtended::symbol
Sym symbol()
Definition:
xtended.hh:24
tree
Tree tree(const Node &n)
Definition:
tree.hh:186
FmodPrim::generateCode
virtual string generateCode(Klass *klass, const vector< string > &args, const vector< Type > &types)
Definition:
fmodprim.cpp:42
FmodPrim
Definition:
fmodprim.cpp:7
isuffix
const char * isuffix()
suffix for math functions
Definition:
floats.cpp:43
FmodPrim::FmodPrim
FmodPrim()
Definition:
fmodprim.cpp:12
FmodPrim::infereSigOrder
virtual int infereSigOrder(const vector< int > &args)
Definition:
fmodprim.cpp:26
FmodPrim::needCache
virtual bool needCache()
Definition:
fmodprim.cpp:16
gFmodPrim
xtended * gFmodPrim
Definition:
fmodprim.cpp:61
Generated on Fri Sep 5 2014 18:06:36 for FAUST compiler by
1.8.7