mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Added support for fixed sized tensors of rank 0
This commit is contained in:
@@ -90,6 +90,14 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
|
|||||||
return m_storage.data()[index];
|
return m_storage.data()[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE const Scalar& coeff() const
|
||||||
|
{
|
||||||
|
EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
|
return m_storage.data()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_VARIADIC_TEMPLATES
|
#ifdef EIGEN_HAS_VARIADIC_TEMPLATES
|
||||||
template<typename... IndexTypes>
|
template<typename... IndexTypes>
|
||||||
inline Scalar& coeffRef(Index firstIndex, IndexTypes... otherIndices)
|
inline Scalar& coeffRef(Index firstIndex, IndexTypes... otherIndices)
|
||||||
@@ -114,6 +122,14 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
|
|||||||
return m_storage.data()[index];
|
return m_storage.data()[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Scalar& coeffRef()
|
||||||
|
{
|
||||||
|
EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
|
return m_storage.data()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_VARIADIC_TEMPLATES
|
#ifdef EIGEN_HAS_VARIADIC_TEMPLATES
|
||||||
template<typename... IndexTypes>
|
template<typename... IndexTypes>
|
||||||
inline const Scalar& operator()(Index firstIndex, IndexTypes... otherIndices) const
|
inline const Scalar& operator()(Index firstIndex, IndexTypes... otherIndices) const
|
||||||
@@ -138,6 +154,13 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
|
|||||||
return coeff(index);
|
return coeff(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE const Scalar& operator()() const
|
||||||
|
{
|
||||||
|
EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
|
return coeff();
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STRONG_INLINE const Scalar& operator[](Index index) const
|
EIGEN_STRONG_INLINE const Scalar& operator[](Index index) const
|
||||||
{
|
{
|
||||||
@@ -170,6 +193,13 @@ class TensorFixedSize : public TensorBase<TensorFixedSize<Scalar_, Dimensions_,
|
|||||||
return coeffRef(index);
|
return coeffRef(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Scalar& operator()()
|
||||||
|
{
|
||||||
|
EIGEN_STATIC_ASSERT(NumIndices == 0, YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
|
return coeffRef();
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STRONG_INLINE Scalar& operator[](Index index)
|
EIGEN_STRONG_INLINE Scalar& operator[](Index index)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user