Skip to content

Commit

Permalink
Revert "Fix ArraySlice for dim reduction if size(dim) is 1"
Browse files Browse the repository at this point in the history
This reverts commit d4f4681.
  • Loading branch information
rfranke authored and OpenModelica-Hudson committed Mar 28, 2016
1 parent 630d4b6 commit bb4bdc2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions SimulationRuntime/cpp/Include/Core/Math/ArraySlice.h
Expand Up @@ -126,14 +126,17 @@ class ArraySliceConst: public BaseArray<T> {
if (start > maxIndex || stop > maxIndex || step == 0)
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,
"Wrong slice exceeding array size");
size = std::max(0, (stop - start) / step + 1);
// avoid trivial fill of _idxs if slice accesses all indices
if (start > 1 || step != 1 || stop < maxIndex || size == 1)
for (size_t i = 0; i < size; i++)
if (start == 1 && step == 1 && stop == maxIndex)
// all indices; avoid trivial fill of _idxs
size = _baseArray.getDim(dim);
else {
size = std::max(0, (stop - start) / step + 1);
for (int i = 0; i < size; i++)
dit->push_back(start + i * step);
}
}
if (size == 1)
// preset constant _baseIdx in case of reduction
// prefill constant _baseIdx in case of reduction
_baseIdx[dim - 1] = sit->iset != NULL? (*_isets[dim - 1])(1): (*dit)[0];
else
// store dimension of array slice
Expand Down

0 comments on commit bb4bdc2

Please sign in to comment.