Skip to content

Commit

Permalink
Add the trigonometric functions to EmbeddedC
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2851
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jan 9, 2019
1 parent 17e1186 commit 43bdde4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Compiler/Template/CodegenEmbeddedC.tpl
Expand Up @@ -483,6 +483,21 @@ template daeExpCallBuiltin(Exp exp)
case CALL(path=IDENT(name="abs"),expLst={exp1}) then 'fabs(<%daeExp(exp1)%>)'
case CALL(path=IDENT(name="min"),expLst={exp1,exp2},attr=CALL_ATTR(ty=T_REAL(__))) then 'fmin(<%daeExp(exp1)%>,<%daeExp(exp2)%>)'
case CALL(path=IDENT(name="max"),expLst={exp1,exp2},attr=CALL_ATTR(ty=T_REAL(__))) then 'fmax(<%daeExp(exp1)%>,<%daeExp(exp2)%>)'
case CALL(path=IDENT(name=name as "sin"),expLst={exp1})
case CALL(path=IDENT(name=name as "cos"),expLst={exp1})
case CALL(path=IDENT(name=name as "tan"),expLst={exp1})
case CALL(path=IDENT(name=name as "asin"),expLst={exp1})
case CALL(path=IDENT(name=name as "acos"),expLst={exp1})
case CALL(path=IDENT(name=name as "atan"),expLst={exp1})
case CALL(path=IDENT(name=name as "sinh"),expLst={exp1})
case CALL(path=IDENT(name=name as "cosh"),expLst={exp1})
case CALL(path=IDENT(name=name as "tanh"),expLst={exp1})
case CALL(path=IDENT(name=name as "exp"),expLst={exp1})
case CALL(path=IDENT(name=name as "log"),expLst={exp1})
case CALL(path=IDENT(name=name as "log10"),expLst={exp1})
then '<%name%>(<%daeExp(exp1)%>)'
case CALL(path=IDENT(name=name as "atan2"),expLst={exp1,exp2})
then '<%name%>(<%daeExp(exp1)%>,<%daeExp(exp2)%>)'
/* TODO: Generate used builtin functions before SimCode */
case CALL(path=IDENT(name="mod"),expLst=exp1::exp2::_) then 'om_mod(<%daeExp(exp1)%>,<%daeExp(exp2)%>)'
/* TODO: pre needs to be handled in a special way */
Expand Down

0 comments on commit 43bdde4

Please sign in to comment.