From 0fce853cb8cf01e6632f33e4a5558b4d2dd63092 Mon Sep 17 00:00:00 2001
From: Justin Carpentier <justin.carpentier@inria.fr>
Date: Thu, 12 Mar 2020 15:16:08 +0100
Subject: [PATCH] core: remove eigenpy:Ref

No more useful
---
 CMakeLists.txt                        |  1 -
 include/eigenpy/eigen-allocator.hpp   | 18 ------
 include/eigenpy/eigen-from-python.hpp | 12 ----
 include/eigenpy/eigen-to-python.hpp   | 10 ---
 include/eigenpy/eigenpy.hpp           | 11 ----
 include/eigenpy/ref.hpp               | 91 ---------------------------
 unittest/CMakeLists.txt               |  1 -
 unittest/eigenpy_ref.cpp              | 54 ----------------
 8 files changed, 198 deletions(-)
 delete mode 100644 include/eigenpy/ref.hpp
 delete mode 100644 unittest/eigenpy_ref.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 230fba31..622d7555 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -121,7 +121,6 @@ SET(${PROJECT_NAME}_HEADERS
   include/eigenpy/angle-axis.hpp
   include/eigenpy/quaternion.hpp
   include/eigenpy/stride.hpp
-  include/eigenpy/ref.hpp
   include/eigenpy/version.hpp
 )
 
diff --git a/include/eigenpy/eigen-allocator.hpp b/include/eigenpy/eigen-allocator.hpp
index d04fd7a7..340ac66e 100644
--- a/include/eigenpy/eigen-allocator.hpp
+++ b/include/eigenpy/eigen-allocator.hpp
@@ -388,24 +388,6 @@ namespace eigenpy
       EigenAllocator<MatType>::copy(ref,pyArray);
     }
   };
-
-  template<typename MatType>
-  struct EigenAllocator< eigenpy::Ref<MatType> >
-  {
-    typedef eigenpy::Ref<MatType> Type;
-    typedef typename MatType::Scalar Scalar;
-    
-    static void allocate(PyArrayObject * pyArray, void * storage)
-    {
-      typename NumpyMap<MatType,Scalar>::EigenMap numpyMap = NumpyMap<MatType,Scalar>::map(pyArray);
-      new (storage) Type(numpyMap);
-    }
-    
-    static void copy(Type const & mat, PyArrayObject * pyArray)
-    {
-      EigenAllocator<MatType>::copy(mat,pyArray);
-    }
-  };
 #endif
 }
 
diff --git a/include/eigenpy/eigen-from-python.hpp b/include/eigenpy/eigen-from-python.hpp
index 325326d6..f17ca6ed 100644
--- a/include/eigenpy/eigen-from-python.hpp
+++ b/include/eigenpy/eigen-from-python.hpp
@@ -512,18 +512,6 @@ namespace eigenpy
        &eigen_from_py_construct<ConstRefType>,bp::type_id<ConstRefType>());
     }
   };
-
-  // Template specialization for Eigen::Ref
-  template<typename MatType>
-  struct EigenFromPyConverter< eigenpy::Ref<MatType> >
-  {
-    static void registration()
-    {
-      bp::converter::registry::push_back
-      (reinterpret_cast<void *(*)(_object *)>(&EigenFromPy<MatType>::convertible),
-       &EigenFromPy<MatType>::construct,bp::type_id<MatType>());
-    }
-  };
 #endif
 
 }
diff --git a/include/eigenpy/eigen-to-python.hpp b/include/eigenpy/eigen-to-python.hpp
index cc990519..c2548216 100644
--- a/include/eigenpy/eigen-to-python.hpp
+++ b/include/eigenpy/eigen-to-python.hpp
@@ -90,16 +90,6 @@ namespace eigenpy
       bp::to_python_converter<MatType,EigenToPy<MatType> >();
     }
   };
-
-#if EIGEN_VERSION_AT_LEAST(3,2,0)
-  template<typename MatType>
-  struct EigenToPyConverter< eigenpy::Ref<MatType> >
-  {
-    static void registration()
-    {
-    }
-  };
-#endif
 }
 
 #endif // __eigenpy_eigen_to_python_hpp__
diff --git a/include/eigenpy/eigenpy.hpp b/include/eigenpy/eigenpy.hpp
index 75c2c73e..304b01b0 100644
--- a/include/eigenpy/eigenpy.hpp
+++ b/include/eigenpy/eigenpy.hpp
@@ -10,20 +10,9 @@
 #include "eigenpy/deprecated.hpp"
 #include "eigenpy/config.hpp"
 
-#if EIGEN_VERSION_AT_LEAST(3,2,0)
-#include "eigenpy/ref.hpp"
-
-#define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \
-  ::eigenpy::enableEigenPySpecific<TYPE>(); \
-  ::eigenpy::enableEigenPySpecific< eigenpy::Ref<TYPE> >();
-
-#else // if EIGEN_VERSION_AT_LEAST(3,2,0)
-
 #define ENABLE_SPECIFIC_MATRIX_TYPE(TYPE) \
   ::eigenpy::enableEigenPySpecific<TYPE>();
 
-#endif // if EIGEN_VERSION_AT_LEAST(3,2,0)
-
 #define EIGENPY_MAKE_TYPEDEFS(Type, Options, TypeSuffix, Size, SizeSuffix)   \
   /** \ingroup matrixtypedefs */                                    \
   typedef Eigen::Matrix<Type, Size, Size, Options> Matrix##SizeSuffix##TypeSuffix;  \
diff --git a/include/eigenpy/ref.hpp b/include/eigenpy/ref.hpp
deleted file mode 100644
index c2eb21d5..00000000
--- a/include/eigenpy/ref.hpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2014-2019, CNRS
- * Copyright 2018-2019, INRIA
- */
-
-#ifndef __eigenpy_ref_hpp__
-#define __eigenpy_ref_hpp__
-
-#include "eigenpy/fwd.hpp"
-#include "eigenpy/stride.hpp"
-
-// For old Eigen versions, EIGEN_DEVICE_FUNC is not defined.
-// We must define it just in the scope of this file.
-#if !EIGEN_VERSION_AT_LEAST(3,2,90)
-#define EIGEN_DEVICE_FUNC
-#endif
-
-namespace eigenpy
-{
-
-  template<typename PlainObjectTypeT>
-  struct Ref
-  : Eigen::Ref<PlainObjectTypeT,EIGENPY_NO_ALIGNMENT_VALUE,typename StrideType<PlainObjectTypeT>::type>
-  {
-  public:
-    typedef Eigen::Ref<PlainObjectTypeT,EIGENPY_NO_ALIGNMENT_VALUE,typename eigenpy::template StrideType<PlainObjectTypeT>::type> Base;
-
-  private:
-    typedef Eigen::internal::traits<Base> Traits;
-    template<typename Derived>
-    EIGEN_DEVICE_FUNC inline Ref(const Eigen::PlainObjectBase<Derived>& expr,
-                                 typename Eigen::internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0);
-    
-  public:
-    
-    typedef typename Eigen::internal::traits<Base>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \
-    typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \
-    typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */
-    typedef typename Eigen::internal::ref_selector<Base>::type Nested;
-    typedef typename Eigen::internal::traits<Base>::StorageKind StorageKind;
-#if EIGEN_VERSION_AT_LEAST(3,2,90)
-    typedef typename Eigen::internal::traits<Base>::StorageIndex StorageIndex;
-#else
-    typedef typename Eigen::internal::traits<Base>::Index StorageIndex;
-#endif
-    enum { RowsAtCompileTime = Eigen::internal::traits<Base>::RowsAtCompileTime,
-      ColsAtCompileTime = Eigen::internal::traits<Base>::ColsAtCompileTime,
-      Flags = Eigen::internal::traits<Base>::Flags,
-      SizeAtCompileTime = Base::SizeAtCompileTime,
-      MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime,
-      IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
-    using Base::derived;
-    using Base::const_cast_derived;
-    typedef typename Base::PacketScalar PacketScalar;
-    
-    template<typename Derived>
-    EIGEN_DEVICE_FUNC inline Ref(Eigen::PlainObjectBase<Derived>& expr,
-                                 typename Eigen::internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)
-    : Base(expr.derived())
-    {}
-    
-    template<typename Derived>
-    EIGEN_DEVICE_FUNC inline Ref(const Eigen::DenseBase<Derived>& expr,
-                                 typename Eigen::internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)
-    : Base(expr.derived())
-    {}
-    
-#if EIGEN_COMP_MSVC_STRICT && (EIGEN_COMP_MSVC < 1900 ||  defined(__CUDACC_VER__)) // for older MSVC versions, as well as 1900 && CUDA 8, using the base operator is sufficient (cf Bugs 1000, 1324)
-    using Base::operator =;
-#elif EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
-    using Base::operator =; \
-    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Ref& operator=(const Ref& other) { Base::operator=(other); return *this; } \
-    template <typename OtherDerived> \
-    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Ref& operator=(const Eigen::DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; }
-#else
-    using Base::operator =; \
-    EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Ref& operator=(const Ref& other) \
-    { \
-      Base::operator=(other); \
-      return *this; \
-    }
-#endif
-    
-  }; // struct Ref<PlainObjectType>
-}
-
-#if !EIGEN_VERSION_AT_LEAST(3,2,90)
-#undef EIGEN_DEVICE_FUNC
-#endif
-
-#endif // ifndef __eigenpy_ref_hpp__
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
index 1cb974d7..d6518c39 100644
--- a/unittest/CMakeLists.txt
+++ b/unittest/CMakeLists.txt
@@ -35,7 +35,6 @@ ADD_LIB_UNIT_TEST(complex "eigen3")
 ADD_LIB_UNIT_TEST(return_by_ref "eigen3")
 IF(NOT ${EIGEN3_VERSION} VERSION_LESS "3.2.0")
   ADD_LIB_UNIT_TEST(eigen_ref "eigen3")
-  ADD_LIB_UNIT_TEST(eigenpy_ref "eigen3")
 ENDIF()
 
 ADD_PYTHON_UNIT_TEST("py-matrix" "unittest/python/test_matrix.py" "unittest")
diff --git a/unittest/eigenpy_ref.cpp b/unittest/eigenpy_ref.cpp
deleted file mode 100644
index 165e0d96..00000000
--- a/unittest/eigenpy_ref.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014-2019, CNRS
- * Copyright 2018-2020, INRIA
- */
-
-#include "eigenpy/eigenpy.hpp"
-#include <iostream>
-
-using namespace Eigen;
-using namespace eigenpy;
-
-template<typename MatType>
-void printMatrix(const eigenpy::Ref<MatType> & mat)
-{
-  if(MatType::IsVectorAtCompileTime)
-    std::cout << "isVector" << std::endl;
-  std::cout << "size: cols " << mat.cols() << " rows " << mat.rows() << std::endl;
-  std::cout << mat << std::endl;
-}
-
-template<typename MatType>
-void printVector(const eigenpy::Ref<MatType> & mat)
-{
-  EIGEN_STATIC_ASSERT_VECTOR_ONLY(MatType);
-  printMatrix(mat);
-}
-
-template<typename MatType,int Options, typename StrideType>
-void setOnes(Eigen::Ref<MatType,Options,StrideType> mat)
-{
-  mat.setOnes();
-}
-
-template<typename MatType>
-void setOnes_wrap(eigenpy::Ref<MatType> mat)
-{
-  setOnes(mat);
-}
-
-BOOST_PYTHON_MODULE(eigenpy_ref)
-{
-  namespace bp = boost::python;
-  eigenpy::enableEigenPy();
-  
-  bp::def("printMatrix", printMatrix<Vector3d>);
-  bp::def("printMatrix", printMatrix<VectorXd>);
-  bp::def("printMatrix", printMatrix<MatrixXd>);
-  
-  bp::def("printVector", printVector<VectorXd>);
-
-  bp::def("setOnes", setOnes_wrap<Vector3d>);
-  bp::def("setOnes", setOnes_wrap<VectorXd>);
-  bp::def("setOnes", setOnes_wrap<MatrixXd>);
-}
-- 
GitLab