Skip to content

Commit

Permalink
- fix in cpp template for divide, multiply array and asub operation
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12791 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Sep 5, 2012
1 parent b928b99 commit 542d327
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Compiler/Template/CodegenCpp.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4428,7 +4428,7 @@ template daeExpAsub(Exp inExp, Context context, Text &preExp /*BUFP*/,
case ASUB(exp=e, sub=indexes) then
let exp = daeExp(e, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
// let typeShort = expTypeFromExpShort(e)
let expIndexes = (indexes |> index => '<%daeExpASubIndex(index, context, &preExp, &varDecls,simCode)%>' ;separator="][")
let expIndexes = (indexes |> index => '<%daeExpASubIndex(index, context, &preExp, &varDecls,simCode)%>' ;separator="+1][")
//'<%typeShort%>_get<%match listLength(indexes) case 1 then "" case i then '_<%i%>D'%>(&<%exp%>, <%expIndexes%>)'
'(<%exp%>)[<%expIndexes%>+1]'
case exp then
Expand Down Expand Up @@ -4745,7 +4745,7 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/,
case T_ARRAY(ty=T_ENUMERATION(__)) then 'int'
else 'double'
let tvar = tempDecl('multi_array<<%type%>,<%listLength(dims)%>>', &varDecls /*BUFD*/)
let &preExp += '<%tvar%> = cross_array<<%type%>>(<%var1%>,<%var2%>);<%\n%>'
let &preExp += 'assign_array(<%tvar%>,cross_array<<%type%>>(<%var1%>,<%var2%>));<%\n%>'
'<%tvar%>'

case CALL(path=IDENT(name="identity"), expLst={A}) then
Expand Down Expand Up @@ -5014,7 +5014,7 @@ template daeExpBinary(Operator it, Exp exp1, Exp exp2, Context context, Text &pr
else 'double'
let var = tempDecl('multi_array<<%type%>,<%listLength(dims)%>>', &varDecls /*BUFD*/)
//let var = tempDecl1(type,e1,&varDecls /*BUFD*/)
let &preExp += '<%var%>=divide_array<<%type%>,<%listLength(dims)%>>(<%e1%>, <%e2%>);<%\n%>'
let &preExp += 'assign_array(<%var%>,divide_array<<%type%>,<%listLength(dims)%>>(<%e1%>, <%e2%>));<%\n%>'
'<%var%>'

case UMINUS(__) then "daeExpBinary:ERR UMINUS not supported"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ template < typename T >
boost::multi_array< T, 1 > cross_array( boost::multi_array_ref< T, 1 > a , boost::multi_array_ref< T, 1 > b )
{
typename boost::multi_array<T, 1> res(boost::extents[3]);
res.reindex(1);
res[1] = (a[2] * b[3]) - (a[3] * b[2]);
res[2] = (a[3] * b[1]) - (a[1] * b[3]);
res[3] = (a[1] * b[2]) - (a[2] * b[1]);
Expand Down

0 comments on commit 542d327

Please sign in to comment.