Skip to content

Commit

Permalink
- simple fix for array slices
Browse files Browse the repository at this point in the history
- typo fixes for array operations
  • Loading branch information
Marcus Walther authored and OpenModelica-Hudson committed Oct 22, 2015
1 parent 57d7bf3 commit 8907348
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Compiler/Template/CodegenCppCommon.tpl
Expand Up @@ -430,7 +430,7 @@ template daeExpCrefRhs2(Exp ecr, Context context, Text &preExp, Text &varDecls,
let slice = daeExpCrefIndexSpec(crefSubs(cr), context, &preExp,
&varDecls, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace,
stateDerVectorName, useFlatArrayNotation)
let &varDecls += 'ArraySlice<<%typeStr%>> <%slice%>_as(<%arrName%>, <%slice%>);<%\n%>'
let &preExp += 'ArraySlice<<%typeStr%>> <%slice%>_as(<%arrName%>, <%slice%>);<%\n%>'
'<%slice%>_as'
// old code making a copy of the slice using create_array_from_shape
//let arrayType = expTypeFlag(ty, 6)
Expand Down Expand Up @@ -2732,7 +2732,7 @@ case STMT_TUPLE_ASSIGN(exp=CALL(__)) then

let lhsCrefs = (expExpLst |> cr hasindex i1 fromindex 0 =>
let rhsStr = 'get<<%i1%>>(<%retStruct%>.data)'
writeLhsCref(cr, rhsStr, context, &afterExp, &varDecls, simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
writeLhsCref(cr, rhsStr, context, &preExp, &varDecls, simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
;separator="\n";empty)
<<
// algStmtTupleAssign: preExp printout <%marker%>
Expand Down
5 changes: 3 additions & 2 deletions SimulationRuntime/cpp/Core/Math/ArrayOperations.cpp
Expand Up @@ -213,6 +213,7 @@ void multiply_array(const BaseArray<T> &leftArray, const BaseArray<T> &rightArra
size_t leftNumDims = leftArray.getNumDims();
size_t rightNumDims = rightArray.getNumDims();
size_t matchDim = rightArray.getDim(1);
resultArray.setDims(leftArray.getDims());
if (leftArray.getDim(leftNumDims) != matchDim)
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,
"Wrong sizes in multiply_array");
Expand Down Expand Up @@ -311,7 +312,7 @@ void subtract_array(const BaseArray<T>& leftArray, const BaseArray<T>& rightArra

if(dimLeft != dimRight)
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,
"Right and left array must have the same size for element wise multiplication");
"Right and left array must have the same size for element wise substraction");

resultArray.setDims(leftArray.getDims());
const T* data1 = leftArray.getData();
Expand Down Expand Up @@ -343,7 +344,7 @@ void add_array(const BaseArray<T>& leftArray, const BaseArray<T>& rightArray, Ba

if(dimLeft != dimRight)
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,
"Right and left array must have the same size for element wise multiplication");
"Right and left array must have the same size for element wise addition");

resultArray.setDims(leftArray.getDims());
const T* data1 = leftArray.getData();
Expand Down

0 comments on commit 8907348

Please sign in to comment.