Verified Commit 13e21e8f authored by Justin Carpentier's avatar Justin Carpentier
Browse files

math/tensor: sue array for the dimensions

parent 68afcbfd
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
struct array struct array
{ {
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE T& operator[] (size_t index) { return values[index]; } EIGEN_STRONG_INLINE T& operator[] (size_t index)
{ return values[index]; }
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE const T& operator[] (size_t index) const { return values[index]; } EIGEN_STRONG_INLINE const T& operator[] (size_t index) const
{ return values[index]; }
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE T& front() { return values[0]; } EIGEN_STRONG_INLINE T& front() { return values[0]; }
...@@ -83,10 +85,16 @@ namespace pinocchio ...@@ -83,10 +85,16 @@ namespace pinocchio
NumIndices = NumIndices_ NumIndices = NumIndices_
}; };
typedef IndexType Index; typedef IndexType Index;
typedef Eigen::array<Index,NumIndices_> Dimensions;
inline Tensor& base() { return *this; } inline Tensor& base() { return *this; }
inline const Tensor& base() const { return *this; } inline const Tensor& base() const { return *this; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
Dimensions& dimensions() { return m_dimensions; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const Dimensions& dimensions() const { return m_dimensions; }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const
{ {
return NumIndices; return NumIndices;
...@@ -239,7 +247,7 @@ namespace pinocchio ...@@ -239,7 +247,7 @@ namespace pinocchio
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1,Options> StorageType; typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1,Options> StorageType;
StorageType m_storage; StorageType m_storage;
Index m_dimensions[NumIndices]; Dimensions m_dimensions;
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment