Opened 13 years ago
Last modified 13 years ago
#1569 closed defect (fixed)
Bug of arrayDimension in daeExpArray
Reported by: | Dongliang Li | Owned by: | Dongliang Li |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Backend | Version: | trunk |
Keywords: | Cc: | Dongliang Li, |
Description
In the daeExpArray(shown following), when we use the method "listLength" to get the dimension of the array according to the information of "arrayDimensions" in ET_ARRAY, it (<%dimsLenStr%>) always just returns "1", but not the correct dimension. See example in the attachment, "AlgorithmFor6.mo" has an array dimension of "2", but the code generator returns "1".
template daeExpArray(Exp exp, Context context, Text &preExp /*BUFP*/,Text &varDecls /*BUFP*/,SimCode simCode) "Generates code for an array expression." ::= match exp case ARRAY(ty=ET_ARRAY(arrayDimensions=dims)) then let arrayTypeStr = expTypeArray(ty) let dimsLenStr = listLength(dims) let arrayVar = tempDecl(arrayTypeStr, &varDecls /*BUFD*/) let scalarPrefix = if scalar then "scalar_" else "" let scalarRef = if scalar then "&" else "" let params = (array |> e => '<%daeExp(e, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)%>' ;separator=", ") let &preExp += ' multi_array<<%arrayTypeStr%>,<%dimsLenStr%>> <%arrayVar%>(boost::extents[<%listLength(array)%>]); <%arrayTypeStr%> <%arrayVar%>_data[]={<%params%>}; <%arrayVar%>.assign(<%arrayVar%>_data,<%arrayVar%>_data+<%listLength(array)%>); <%arrayVar%>.reindex(1);<%\n%>' arrayVar end daeExpArray;
Attachments (1)
Note:
See TracTickets
for help on using tickets.