Skip to content

Commit

Permalink
Fixed bug 95. Testcase in simulation3.mos and avg.mo.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2703 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Feb 12, 2007
1 parent caec13e commit 67b5bc2
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Compiler/Builtin.mo
Expand Up @@ -2557,6 +2557,9 @@ algorithm
env = Env.extendFrameT(env, "sin", real2real) "Not in the report" ;
env = Env.extendFrameT(env, "cos", real2real);
env = Env.extendFrameT(env, "tan", real2real);
env = Env.extendFrameT(env, "tanh", real2real);
env = Env.extendFrameT(env, "sinh", real2real);
env = Env.extendFrameT(env, "cosh", real2real);
env = Env.extendFrameT(env, "arcsin", real2real);
env = Env.extendFrameT(env, "arccos", real2real);
env = Env.extendFrameT(env, "arctan", real2real);
Expand Down
107 changes: 106 additions & 1 deletion Compiler/Ceval.mo
Expand Up @@ -220,11 +220,14 @@ algorithm
case "div" then cevalBuiltinDiv;
case "sin" then cevalBuiltinSin;
case "cos" then cevalBuiltinCos;
case "tan" then cevalBuiltinTan;
case "sinh" then cevalBuiltinSinh;
case "cosh" then cevalBuiltinCosh;
case "tanh" then cevalBuiltinTanh;
case "log" then cevalBuiltinLog;
case "arcsin" then cevalBuiltinAsin;
case "arccos" then cevalBuiltinAcos;
case "arctan" then cevalBuiltinAtan;
case "tan" then cevalBuiltinTan;
case "integer" then cevalBuiltinInteger;
case "mod" then cevalBuiltinMod;
case "max" then cevalBuiltinMax;
Expand Down Expand Up @@ -4272,6 +4275,40 @@ algorithm
end matchcontinue;
end cevalBuiltinSin;

protected function cevalBuiltinSinh "function cevalBuiltinSin
author: PA
Evaluates the builtin sinh function.
"
input Env.Cache inCache;
input Env.Env inEnv;
input list<Exp.Exp> inExpExpLst;
input Boolean inBoolean;
input Option<Interactive.InteractiveSymbolTable> inInteractiveInteractiveSymbolTableOption;
input Msg inMsg;
output Env.Cache outCache;
output Values.Value outValue;
output Option<Interactive.InteractiveSymbolTable> outInteractiveInteractiveSymbolTableOption;
algorithm
(outCache,outValue,outInteractiveInteractiveSymbolTableOption):=
matchcontinue (inCache,inEnv,inExpExpLst,inBoolean,inInteractiveInteractiveSymbolTableOption,inMsg)
local
Real rv,rv_1;
list<Env.Frame> env;
Exp.Exp exp;
Boolean impl;
Option<Interactive.InteractiveSymbolTable> st;
Msg msg;
Env.Cache cache;
case (cache,env,{exp},impl,st,msg)
equation
(cache,Values.REAL(rv),_) = ceval(cache,env, exp, impl, st, NONE, msg);
rv_1 = System.sinh(rv);
then
(cache,Values.REAL(rv_1),st);
end matchcontinue;
end cevalBuiltinSinh;

protected function cevalBuiltinCos "function cevalBuiltinCos
author: LP
Expand Down Expand Up @@ -4306,6 +4343,40 @@ algorithm
end matchcontinue;
end cevalBuiltinCos;

protected function cevalBuiltinCosh "function cevalBuiltinCos
author: PA
Evaluates the builtin cosh function.
"
input Env.Cache inCache;
input Env.Env inEnv;
input list<Exp.Exp> inExpExpLst;
input Boolean inBoolean;
input Option<Interactive.InteractiveSymbolTable> inInteractiveInteractiveSymbolTableOption;
input Msg inMsg;
output Env.Cache outCache;
output Values.Value outValue;
output Option<Interactive.InteractiveSymbolTable> outInteractiveInteractiveSymbolTableOption;
algorithm
(outCache,outValue,outInteractiveInteractiveSymbolTableOption):=
matchcontinue (inCache,inEnv,inExpExpLst,inBoolean,inInteractiveInteractiveSymbolTableOption,inMsg)
local
Real rv,rv_1;
list<Env.Frame> env;
Exp.Exp exp;
Boolean impl;
Option<Interactive.InteractiveSymbolTable> st;
Msg msg;
Env.Cache cache;
case (cache,env,{exp},impl,st,msg)
equation
(cache,Values.REAL(rv),_) = ceval(cache,env, exp, impl, st, NONE, msg);
rv_1 = System.cosh(rv);
then
(cache,Values.REAL(rv_1),st);
end matchcontinue;
end cevalBuiltinCosh;

protected function cevalBuiltinLog "function cevalBuiltinLog
author: LP
Expand Down Expand Up @@ -4376,6 +4447,40 @@ algorithm
end matchcontinue;
end cevalBuiltinTan;

protected function cevalBuiltinTanh "function cevalBuiltinTan
author: PA
Evaluates the builtin tanh function.
"
input Env.Cache inCache;
input Env.Env inEnv;
input list<Exp.Exp> inExpExpLst;
input Boolean inBoolean;
input Option<Interactive.InteractiveSymbolTable> inInteractiveInteractiveSymbolTableOption;
input Msg inMsg;
output Env.Cache outCache;
output Values.Value outValue;
output Option<Interactive.InteractiveSymbolTable> outInteractiveInteractiveSymbolTableOption;
algorithm
(outCache,outValue,outInteractiveInteractiveSymbolTableOption):=
matchcontinue (inCache,inEnv,inExpExpLst,inBoolean,inInteractiveInteractiveSymbolTableOption,inMsg)
local
Real rv,sv,cv,rv_1;
list<Env.Frame> env;
Exp.Exp exp;
Boolean impl;
Option<Interactive.InteractiveSymbolTable> st;
Msg msg;
Env.Cache cache;
case (cache,env,{exp},impl,st,msg) /* tanh is not implemented in MetaModelica Compiler (MMC) for some strange reason. */
equation
(cache,Values.REAL(rv),_) = ceval(cache,env, exp, impl, st, NONE, msg);
rv_1 = System.tanh(rv);
then
(cache,Values.REAL(rv_1),st);
end matchcontinue;
end cevalBuiltinTanh;

protected function cevalBuiltinAsin "function cevalBuiltinAsin
author: PA
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Codegen.mo
Expand Up @@ -2492,7 +2492,7 @@ algorithm
array_type_str = expTypeStr(t, true);
(cfn3,evar,tnr3) = generateExpression(e, tnr2, context);
for_begin = Util.stringAppendList(
{"for (",tvar," = 0; ",tvar," < size_of_dimension_",
{"for (",tvar," = 1; ",tvar," <= size_of_dimension_",
array_type_str,"(",evar,", 1); ","++",tvar,") {"});
def_beg1 = Util.stringAppendList({"{\n ",ident_type_str," ",i,";\n"});
mem_begin = Util.stringAppendList({svar," = get_memory_state();"});
Expand Down

0 comments on commit 67b5bc2

Please sign in to comment.