From d833b7bdeef8c4b98c2eed3a951ee0330ca39c72 Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Tue, 21 Feb 2023 17:10:50 +0100 Subject: [PATCH] core: remove TensorBase --- include/eigenpy/eigen-allocator.hpp | 7 ++----- include/eigenpy/numpy-allocator.hpp | 15 ++++----------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/include/eigenpy/eigen-allocator.hpp b/include/eigenpy/eigen-allocator.hpp index b4397d9..cdcec2c 100644 --- a/include/eigenpy/eigen-allocator.hpp +++ b/include/eigenpy/eigen-allocator.hpp @@ -342,11 +342,8 @@ struct eigen_allocator_impl_tensor { tensor) /// \brief Copy Python array into the input matrix mat. - template <typename TensorDerived, int AccessLevel> - static void copy( - const Eigen::TensorBase<TensorDerived, AccessLevel> &tensor_) { - TensorDerived &tensor = const_cast<TensorDerived &>( - static_cast<const TensorDerived &>(tensor_)); + template <typename TensorDerived> + static void copy(PyArrayObject *pyArray, TensorDerived &tensor) { const int pyArray_type_code = EIGENPY_GET_PY_ARRAY_TYPE(pyArray); const int Scalar_type_code = Register::getTypeCode<Scalar>(); diff --git a/include/eigenpy/numpy-allocator.hpp b/include/eigenpy/numpy-allocator.hpp index 026f65b..6165394 100644 --- a/include/eigenpy/numpy-allocator.hpp +++ b/include/eigenpy/numpy-allocator.hpp @@ -78,8 +78,8 @@ struct numpy_allocator_impl<const TensorType, template <typename TensorType> struct numpy_allocator_impl_tensor { template <typename TensorDerived> - static PyArrayObject *allocate(const Eigen::TensorBase<TensorDerived> &tensor, - npy_intp nd, npy_intp *shape) { + static PyArrayObject *allocate(const TensorDerived &tensor, npy_intp nd, + npy_intp *shape) { const int code = Register::getTypeCode<typename TensorDerived::Scalar>(); PyArrayObject *pyArray = (PyArrayObject *)call_PyArray_SimpleNew( static_cast<int>(nd), shape, code); @@ -250,10 +250,7 @@ struct numpy_allocator_impl_tensor<Eigen::TensorRef<TensorType> > { return pyArray; } else { - return NumpyAllocator<TensorType>::allocate( - static_cast<Eigen::TensorBase<Eigen::TensorRef<TensorType> > &>( - tensor), - nd, shape); + return NumpyAllocator<TensorType>::allocate(tensor, nd, shape); } } }; @@ -281,11 +278,7 @@ struct numpy_allocator_impl_tensor<const Eigen::TensorRef<const TensorType> > { return pyArray; } else { - return NumpyAllocator<TensorType>::allocate( - static_cast< - const Eigen::TensorBase<Eigen::TensorRef<const TensorType> > &>( - tensor), - nd, shape); + return NumpyAllocator<TensorType>::allocate(tensor, nd, shape); } } }; -- GitLab