Skip to content

Commit

Permalink
Implement const element access in DynArrayDim3 (#7647)
Browse files Browse the repository at this point in the history
See e.g. PowerSystems.Examples.AC3ph.Precalculation.EqCircFromTransDat
  • Loading branch information
rfranke committed Jul 3, 2021
1 parent de5d495 commit 8440874
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions OMCompiler/SimulationRuntime/cpp/Include/Core/Math/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,42 +100,47 @@ template<typename T> class BaseArray
virtual void getDataCopy(T data[], size_t n) const = 0;
virtual const T* const* getDataRefs() const
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,"Wrong virtual Array getDataRefs call");
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array getDataRefs call");
}

virtual T& operator()(size_t i)
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,"Wrong virtual Array operator call");
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array operator call");
};

virtual const T& operator()(size_t i) const
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,"Wrong virtual Array operator call");
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array operator call");
};

virtual T& operator()(size_t i, size_t j)
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,"Wrong virtual Array operator call");
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array operator call");
};

virtual const T& operator()(size_t i, size_t j) const
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,"Wrong virtual Array operator call");
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array operator call");
};

virtual T& operator()(size_t i, size_t j, size_t k)
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,"Wrong virtual Array operator call");
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array operator call");
};

virtual const T& operator()(size_t i, size_t j, size_t k) const
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array operator call");
};

virtual T& operator()(size_t i, size_t j, size_t k, size_t l)
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,"Wrong virtual Array operator call");
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array operator call");
};

virtual T& operator()(size_t i, size_t j, size_t k, size_t l, size_t m)
{
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,"Wrong virtual Array operator call");
throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION, "Wrong virtual Array operator call");
};

bool isStatic() const
Expand Down Expand Up @@ -1963,5 +1968,12 @@ class DynArrayDim3 : public DynArray<T, 3>
const std::vector<size_t>& shape = this->_dims;
return this->_array_data[i-1 + shape[0]*(j-1 + shape[1]*(k-1))];
}

inline virtual const T& operator()(size_t i, size_t j, size_t k) const
{
//return _multi_array[i-1][j-1][k-1];
const std::vector<size_t>& shape = this->_dims;
return this->_array_data[i-1 + shape[0]*(j-1 + shape[1]*(k-1))];
}
};
/** @} */ // end of math

0 comments on commit 8440874

Please sign in to comment.