Skip to content

Commit

Permalink
fix for #3458, proper type in DAE.MUL_MATRIX_PRODUCT
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo committed Sep 13, 2015
1 parent 94be67b commit d78c1bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Compiler/BackEnd/IndexReduction.mo
Expand Up @@ -1574,7 +1574,7 @@ protected
list<BackendDAE.Var> setVars,aVars,varJ,otherVars,stateCandidates;
list<DAE.ComponentRef> crstates,crset;
DAE.ComponentRef crA,set,crJ;
DAE.Type tp;
DAE.Type tp, tyExpCrStates;
Integer rang,nStates,nStateCandidates,nUnassignedEquations,setIndex,level;

DAE.Exp expcrA,mulAstates,mulAdstates,expset,expderset,expsetstart;
Expand Down Expand Up @@ -1605,10 +1605,11 @@ algorithm
expcrdset := List.map(expcrset,makeder);
expcrA := Expression.crefExp(crA);
expcrA := DAE.CAST(tp,expcrA);
op := if b then DAE.MUL_MATRIX_PRODUCT(DAE.T_REAL_DEFAULT) else DAE.MUL_SCALAR_PRODUCT(DAE.T_REAL_DEFAULT);
mulAstates := DAE.BINARY(expcrA,op,DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(nStateCandidates)},DAE.emptyTypeSource),true,expcrstates));
tyExpCrStates := DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(nStateCandidates)},DAE.emptyTypeSource);
op := if b then DAE.MUL_MATRIX_PRODUCT(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(rang)}, DAE.emptyTypeSource)) else DAE.MUL_SCALAR_PRODUCT(DAE.T_REAL_DEFAULT);
mulAstates := DAE.BINARY(expcrA,op,DAE.ARRAY(tyExpCrStates,true,expcrstates));
(mulAstates,_) := Expression.extendArrExp(mulAstates,false);
mulAdstates := DAE.BINARY(expcrA,op,DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(nStateCandidates)},DAE.emptyTypeSource),true,expcrdstates));
mulAdstates := DAE.BINARY(expcrA,op,DAE.ARRAY(tyExpCrStates,true,expcrdstates));
(mulAdstates,_) := Expression.extendArrExp(mulAdstates,false);
expset := if b then DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(rang)},DAE.emptyTypeSource),true,expcrset) else listHead(expcrset);
expderset := if b then DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(rang)},DAE.emptyTypeSource),true,expcrdset) else listHead(expcrdset);
Expand All @@ -1620,7 +1621,7 @@ algorithm
deqn := if b then BackendDAE.ARRAY_EQUATION({rang},expderset,mulAdstates,DAE.emptyElementSource,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC)
else BackendDAE.EQUATION(expderset,mulAdstates,DAE.emptyElementSource,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC);
// start values for the set
expsetstart := DAE.BINARY(expcrA,op,DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(nStateCandidates)},DAE.emptyTypeSource),true,expcrstatesstart));
expsetstart := DAE.BINARY(expcrA,op,DAE.ARRAY(tyExpCrStates,true,expcrstatesstart));
(expsetstart,_) := Expression.extendArrExp(expsetstart,false);
(setVars,_) := List.map2Fold(setVars,setStartExp,expsetstart,rang,1);
// add set states
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCppCommon.tpl
Expand Up @@ -2399,7 +2399,7 @@ template daeExpBinary(Operator it, Exp exp1, Exp exp2, Context context, Text &pr
case EQUAL(__) then "daeExpBinary:ERR EQUAL not supported"
case NEQUAL(__) then "daeExpBinary:ERR NEQUAL not supported"
case USERDEFINED(__) then "daeExpBinary:ERR POW_ARR not supported"
case _ then 'daeExpBinary:ERR'
case _ then 'daeExpBinary:ERR <%printExpStr(exp1)%> <%binopSymbol(it)%> <%printExpStr(exp2)%>'
end daeExpBinary;


Expand Down
4 changes: 4 additions & 0 deletions Compiler/Template/SimCodeTV.mo
Expand Up @@ -3100,6 +3100,10 @@ package ExpressionDump
input DAE.Exp e;
output String s;
end printCrefsFromExpStr;
function binopSymbol
input DAE.Operator inOperator;
output String outString;
end binopSymbol;
end ExpressionDump;

package Config
Expand Down

0 comments on commit d78c1bf

Please sign in to comment.