Unverified Commit 0d2d2987 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #171 from jcarpent/devel

Remove eigenpy::Ref
parents 17e7f023 02234822
......@@ -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
)
......
Subproject commit 65e7f52151c93dd3bf4e0017a44c170d0547d060
Subproject commit 93ec987ecdc016039c8731e203943e5a83eb96d5
......@@ -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
}
......
......@@ -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
}
......
......@@ -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__
......@@ -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; \
......
/*
* 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__
......@@ -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")
......
/*
* 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>);
}
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