mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-04 04:05:19 +08:00
Added missing accessors to fixed sized tensors
This commit is contained in:
parent
17fe7f354e
commit
d6c9596fd8
@ -128,7 +128,6 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
|
|||||||
return m_storage.data()[0];
|
return m_storage.data()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_VARIADIC_TEMPLATES
|
#ifdef EIGEN_HAS_VARIADIC_TEMPLATES
|
||||||
template<typename... IndexTypes>
|
template<typename... IndexTypes>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& operator()(Index firstIndex, IndexTypes... otherIndices) const
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& operator()(Index firstIndex, IndexTypes... otherIndices) const
|
||||||
@ -137,8 +136,54 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
|
|||||||
EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
return this->operator()(array<Index, NumIndices>{{firstIndex, otherIndices...}});
|
return this->operator()(array<Index, NumIndices>{{firstIndex, otherIndices...}});
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE const Scalar& operator()(Index i0, Index i1) const
|
||||||
|
{
|
||||||
|
if (Options&RowMajor) {
|
||||||
|
const Index index = i1 + i0 * m_storage.dimensions()[1];
|
||||||
|
return m_storage.data()[index];
|
||||||
|
} else {
|
||||||
|
const Index index = i0 + i1 * m_storage.dimensions()[0];
|
||||||
|
return m_storage.data()[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE const Scalar& operator()(Index i0, Index i1, Index i2) const
|
||||||
|
{
|
||||||
|
if (Options&RowMajor) {
|
||||||
|
const Index index = i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0);
|
||||||
|
return m_storage.data()[index];
|
||||||
|
} else {
|
||||||
|
const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * i2);
|
||||||
|
return m_storage.data()[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE const Scalar& operator()(Index i0, Index i1, Index i2, Index i3) const
|
||||||
|
{
|
||||||
|
if (Options&RowMajor) {
|
||||||
|
const Index index = i3 + m_storage.dimensions()[3] * (i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0));
|
||||||
|
return m_storage.data()[index];
|
||||||
|
} else {
|
||||||
|
const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * (i2 + m_storage.dimensions()[2] * i3));
|
||||||
|
return m_storage.data()[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE const Scalar& operator()(Index i0, Index i1, Index i2, Index i3, Index i4) const
|
||||||
|
{
|
||||||
|
if (Options&RowMajor) {
|
||||||
|
const Index index = i4 + m_storage.dimensions()[4] * (i3 + m_storage.dimensions()[3] * (i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0)));
|
||||||
|
return m_storage.data()[index];
|
||||||
|
} else {
|
||||||
|
const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * (i2 + m_storage.dimensions()[2] * (i3 + m_storage.dimensions()[3] * i4)));
|
||||||
|
return m_storage.data()[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STRONG_INLINE const Scalar& operator()(const array<Index, NumIndices>& indices) const
|
EIGEN_STRONG_INLINE const Scalar& operator()(const array<Index, NumIndices>& indices) const
|
||||||
{
|
{
|
||||||
@ -176,6 +221,51 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
|
|||||||
EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(sizeof...(otherIndices) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
return operator()(array<Index, NumIndices>{{firstIndex, otherIndices...}});
|
return operator()(array<Index, NumIndices>{{firstIndex, otherIndices...}});
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Scalar& operator()(Index i0, Index i1)
|
||||||
|
{
|
||||||
|
if (Options&RowMajor) {
|
||||||
|
const Index index = i1 + i0 * m_storage.dimensions()[1];
|
||||||
|
return m_storage.data()[index];
|
||||||
|
} else {
|
||||||
|
const Index index = i0 + i1 * m_storage.dimensions()[0];
|
||||||
|
return m_storage.data()[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Scalar& operator()(Index i0, Index i1, Index i2)
|
||||||
|
{
|
||||||
|
if (Options&RowMajor) {
|
||||||
|
const Index index = i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0);
|
||||||
|
return m_storage.data()[index];
|
||||||
|
} else {
|
||||||
|
const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * i2);
|
||||||
|
return m_storage.data()[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Scalar& operator()(Index i0, Index i1, Index i2, Index i3)
|
||||||
|
{
|
||||||
|
if (Options&RowMajor) {
|
||||||
|
const Index index = i3 + m_storage.dimensions()[3] * (i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0));
|
||||||
|
return m_storage.data()[index];
|
||||||
|
} else {
|
||||||
|
const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * (i2 + m_storage.dimensions()[2] * i3));
|
||||||
|
return m_storage.data()[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Scalar& operator()(Index i0, Index i1, Index i2, Index i3, Index i4)
|
||||||
|
{
|
||||||
|
if (Options&RowMajor) {
|
||||||
|
const Index index = i4 + m_storage.dimensions()[4] * (i3 + m_storage.dimensions()[3] * (i2 + m_storage.dimensions()[2] * (i1 + m_storage.dimensions()[1] * i0)));
|
||||||
|
return m_storage.data()[index];
|
||||||
|
} else {
|
||||||
|
const Index index = i0 + m_storage.dimensions()[0] * (i1 + m_storage.dimensions()[1] * (i2 + m_storage.dimensions()[2] * (i3 + m_storage.dimensions()[3] * i4)));
|
||||||
|
return m_storage.data()[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
|
Loading…
x
Reference in New Issue
Block a user