FAUST compiler  0.9.9.6b8
Public Member Functions | List of all members
SqrtPrim Class Reference
Inheritance diagram for SqrtPrim:
Inheritance graph
[legend]
Collaboration diagram for SqrtPrim:
Collaboration graph
[legend]

Public Member Functions

 SqrtPrim ()
 
virtual unsigned int arity ()
 
virtual bool needCache ()
 
virtual Type infereSigType (const vector< Type > &args)
 
virtual void sigVisit (Tree sig, sigvisitor *visitor)
 
virtual int infereSigOrder (const vector< int > &args)
 
virtual Tree computeSigOutput (const vector< Tree > &args)
 
virtual string generateCode (Klass *klass, const vector< string > &args, const vector< Type > &types)
 
virtual string generateLateq (Lateq *lateq, const vector< string > &args, const vector< Type > &types)
 
- Public Member Functions inherited from xtended
 xtended (const char *name)
 
virtual ~xtended ()
 
Sym symbol ()
 
const char * name ()
 
Tree box ()
 
virtual bool isSpecialInfix ()
 generaly false, but true for binary op # such that #(x) == _::x More...
 

Detailed Description

Definition at line 8 of file sqrtprim.cpp.

Constructor & Destructor Documentation

SqrtPrim::SqrtPrim ( )
inline

Definition at line 13 of file sqrtprim.cpp.

13 : xtended("sqrt") {}
xtended(const char *name)
Definition: xtended.hh:18

Member Function Documentation

virtual unsigned int SqrtPrim::arity ( )
inlinevirtual

Implements xtended.

Definition at line 15 of file sqrtprim.cpp.

Referenced by generateCode(), and generateLateq().

15 { return 1; }

Here is the caller graph for this function:

virtual Tree SqrtPrim::computeSigOutput ( const vector< Tree > &  args)
inlinevirtual

Implements xtended.

Definition at line 38 of file sqrtprim.cpp.

References isNum(), xtended::symbol(), and tree().

38  {
39  // verifier les simplifications
40  num n;
41  if (isNum(args[0],n)) {
42  return tree(sqrt(double(n)));
43  } else {
44  return tree(symbol(), args[0]);
45  }
46  }
Definition: num.hh:58
bool isNum(Tree a)
Definition: signals.hh:187
Sym symbol()
Definition: xtended.hh:24
Tree tree(const Node &n)
Definition: tree.hh:186

Here is the call graph for this function:

virtual string SqrtPrim::generateCode ( Klass klass,
const vector< string > &  args,
const vector< Type > &  types 
)
inlinevirtual

Implements xtended.

Definition at line 48 of file sqrtprim.cpp.

References arity(), isuffix(), and subst().

49  {
50  assert (args.size() == arity());
51  assert (types.size() == arity());
52 
53  return subst("sqrt$1($0)", args[0], isuffix());
54  }
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual unsigned int arity()
Definition: sqrtprim.cpp:15
const char * isuffix()
suffix for math functions
Definition: floats.cpp:43

Here is the call graph for this function:

virtual string SqrtPrim::generateLateq ( Lateq lateq,
const vector< string > &  args,
const vector< Type > &  types 
)
inlinevirtual

Implements xtended.

Definition at line 56 of file sqrtprim.cpp.

References arity(), and subst().

57  {
58  assert (args.size() == arity());
59  assert (types.size() == arity());
60 
61  return subst("\\sqrt{$0}", args[0]);
62  }
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual unsigned int arity()
Definition: sqrtprim.cpp:15

Here is the call graph for this function:

virtual int SqrtPrim::infereSigOrder ( const vector< int > &  args)
inlinevirtual

Implements xtended.

Definition at line 33 of file sqrtprim.cpp.

33  {
34  return args[0];
35  }
virtual Type SqrtPrim::infereSigType ( const vector< Type > &  args)
inlinevirtual

Implements xtended.

Definition at line 19 of file sqrtprim.cpp.

References castInterval(), floatCast(), interval::hi, interval::lo, and interval::valid.

20  {
21  assert (args.size() == 1);
22  Type t = args[0];
23  interval i = t->getInterval();
24  if (i.valid && i.lo >=0) {
25  return castInterval(floatCast(t), interval(sqrt(i.lo), sqrt(i.hi)));
26  } else {
27  return castInterval(floatCast(t), interval());
28  }
29  }
bool valid
true if it is a valid interval
Definition: interval.hh:38
double lo
minimal value
Definition: interval.hh:39
Type floatCast(Type t)
Definition: sigtype.hh:270
Type castInterval(Type t, const interval &i)
Definition: sigtype.hh:278
double hi
maximal value
Definition: interval.hh:40

Here is the call graph for this function:

virtual bool SqrtPrim::needCache ( )
inlinevirtual

Implements xtended.

Definition at line 17 of file sqrtprim.cpp.

17 { return true; }
virtual void SqrtPrim::sigVisit ( Tree  sig,
sigvisitor visitor 
)
inlinevirtual

Definition at line 31 of file sqrtprim.cpp.

31 {}

The documentation for this class was generated from the following file: