Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit a3b03f0

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Complete fix for 3dim RefArray, ticket:4093
This applies the fix of ea606a1 to five further occurences of the wrong index calculation.
1 parent 73f7fca commit a3b03f0

File tree

1 file changed

+5
-5
lines changed
  • SimulationRuntime/cpp/Include/Core/Math

1 file changed

+5
-5
lines changed

SimulationRuntime/cpp/Include/Core/Math/Array.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,9 @@ class RefArrayDim3 : public RefArray<T, size1*size2*size3>
580580
*/
581581
virtual const T& operator()(const vector<size_t>& idx) const
582582
{
583-
assert((size1*size2*size3) > (size3*(idx[0]-1 + size2*(idx[1]-1)) + idx[2]-1));
583+
assert((size1*size2*size3) > (size3*(size2*(idx[0]-1) + (idx[1]-1)) + idx[2]-1));
584584
return *(RefArray<T, size1*size2*size3>::
585-
_ref_array[size3*(idx[0]-1 + size2*(idx[1]-1)) + idx[2]-1]);
585+
_ref_array[size3*(size2*(idx[0]-1) + (idx[1]-1)) + idx[2]-1]);
586586
}
587587

588588
/**
@@ -591,9 +591,9 @@ class RefArrayDim3 : public RefArray<T, size1*size2*size3>
591591
*/
592592
virtual T& operator()(const vector<size_t>& idx)
593593
{
594-
assert((size1*size2*size3) > (size3*(idx[0]-1 + size2*(idx[1]-1)) + idx[2]-1));
594+
assert((size1*size2*size3) > (size3*(size2*(idx[0]-1) + (idx[1]-1)) + idx[2]-1));
595595
return *(RefArray<T, size1*size2*size3>::
596-
_ref_array[size3*(idx[0]-1 + size2*(idx[1]-1)) + idx[2]-1]);
596+
_ref_array[size3*(size2*(idx[0]-1) + (idx[1]-1)) + idx[2]-1]);
597597
}
598598

599599
/**
@@ -604,7 +604,7 @@ class RefArrayDim3 : public RefArray<T, size1*size2*size3>
604604
*/
605605
inline virtual T& operator()(size_t i, size_t j, size_t k)
606606
{
607-
assert((size1*size2*size3) > (size3*(i-1 + size2*(j-1)) + (k-1)));
607+
assert((size1*size2*size3) > (size3*(size2*(i-1) + (j-1)) + (k-1)));
608608
return *(RefArray<T, size1*size2*size3>::
609609
_ref_array[size3*(size2*(i-1) + (j-1)) + (k-1)]);
610610
}

0 commit comments

Comments
 (0)