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

Merge pull request #168 from jcarpent/devel

Minor renaming
parents c870f4c9 287351ea
...@@ -110,7 +110,7 @@ SET(${PROJECT_NAME}_HEADERS ...@@ -110,7 +110,7 @@ SET(${PROJECT_NAME}_HEADERS
include/eigenpy/eigen-allocator.hpp include/eigenpy/eigen-allocator.hpp
include/eigenpy/eigen-to-python.hpp include/eigenpy/eigen-to-python.hpp
include/eigenpy/eigen-from-python.hpp include/eigenpy/eigen-from-python.hpp
include/eigenpy/map.hpp include/eigenpy/numpy-map.hpp
include/eigenpy/geometry.hpp include/eigenpy/geometry.hpp
include/eigenpy/geometry-conversion.hpp include/eigenpy/geometry-conversion.hpp
include/eigenpy/memory.hpp include/eigenpy/memory.hpp
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "eigenpy/eigen-from-python.hpp" #include "eigenpy/eigen-from-python.hpp"
#include "eigenpy/registration.hpp" #include "eigenpy/registration.hpp"
#include "eigenpy/map.hpp"
#include "eigenpy/exception.hpp" #include "eigenpy/exception.hpp"
namespace boost { namespace python { namespace detail { namespace boost { namespace python { namespace detail {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define __eigenpy_eigen_allocator_hpp__ #define __eigenpy_eigen_allocator_hpp__
#include "eigenpy/fwd.hpp" #include "eigenpy/fwd.hpp"
#include "eigenpy/map.hpp" #include "eigenpy/numpy-map.hpp"
#include "eigenpy/scalar-conversion.hpp" #include "eigenpy/scalar-conversion.hpp"
#include "eigenpy/utils/is-aligned.hpp" #include "eigenpy/utils/is-aligned.hpp"
...@@ -96,10 +96,10 @@ namespace eigenpy ...@@ -96,10 +96,10 @@ namespace eigenpy
} // namespace details } // namespace details
#define EIGENPY_CAST_FROM_PYARRAY_TO_EIGEN_MATRIX(MatType,Scalar,NewScalar,pyArray,mat) \ #define EIGENPY_CAST_FROM_PYARRAY_TO_EIGEN_MATRIX(MatType,Scalar,NewScalar,pyArray,mat) \
details::cast_matrix_or_array<Scalar,NewScalar>::run(MapNumpy<MatType,Scalar>::map(pyArray),mat) details::cast_matrix_or_array<Scalar,NewScalar>::run(NumpyMap<MatType,Scalar>::map(pyArray),mat)
#define EIGENPY_CAST_FROM_EIGEN_MATRIX_TO_PYARRAY(MatType,Scalar,NewScalar,mat,pyArray) \ #define EIGENPY_CAST_FROM_EIGEN_MATRIX_TO_PYARRAY(MatType,Scalar,NewScalar,mat,pyArray) \
details::cast_matrix_or_array<Scalar,NewScalar>::run(mat,MapNumpy<MatType,NewScalar>::map(pyArray)) details::cast_matrix_or_array<Scalar,NewScalar>::run(mat,NumpyMap<MatType,NewScalar>::map(pyArray))
template<typename MatType> template<typename MatType>
struct EigenAllocator struct EigenAllocator
...@@ -117,7 +117,7 @@ namespace eigenpy ...@@ -117,7 +117,7 @@ namespace eigenpy
const int pyArray_Type = EIGENPY_GET_PY_ARRAY_TYPE(pyArray); const int pyArray_Type = EIGENPY_GET_PY_ARRAY_TYPE(pyArray);
if(pyArray_Type == NumpyEquivalentType<Scalar>::type_code) if(pyArray_Type == NumpyEquivalentType<Scalar>::type_code)
{ {
mat = MapNumpy<MatType,Scalar>::map(pyArray); // avoid useless cast mat = NumpyMap<MatType,Scalar>::map(pyArray); // avoid useless cast
return; return;
} }
...@@ -160,11 +160,11 @@ namespace eigenpy ...@@ -160,11 +160,11 @@ namespace eigenpy
const MatrixDerived & mat = const_cast<const MatrixDerived &>(mat_.derived()); const MatrixDerived & mat = const_cast<const MatrixDerived &>(mat_.derived());
const int pyArray_Type = EIGENPY_GET_PY_ARRAY_TYPE(pyArray); const int pyArray_Type = EIGENPY_GET_PY_ARRAY_TYPE(pyArray);
typedef typename MapNumpy<MatType,Scalar>::EigenMap MapType; typedef typename NumpyMap<MatType,Scalar>::EigenMap MapType;
if(pyArray_Type == NumpyEquivalentType<Scalar>::type_code) // no cast needed if(pyArray_Type == NumpyEquivalentType<Scalar>::type_code) // no cast needed
{ {
MapType map_pyArray = MapNumpy<MatType,Scalar>::map(pyArray); MapType map_pyArray = NumpyMap<MatType,Scalar>::map(pyArray);
if(mat.rows() == map_pyArray.rows()) if(mat.rows() == map_pyArray.rows())
map_pyArray = mat; map_pyArray = mat;
else else
...@@ -248,7 +248,7 @@ namespace eigenpy ...@@ -248,7 +248,7 @@ namespace eigenpy
RefType & mat = *reinterpret_cast<RefType*>(raw_ptr); RefType & mat = *reinterpret_cast<RefType*>(raw_ptr);
if(pyArray_Type == NumpyEquivalentType<Scalar>::type_code) if(pyArray_Type == NumpyEquivalentType<Scalar>::type_code)
{ {
mat = MapNumpy<MatType,Scalar>::map(pyArray); // avoid useless cast mat = NumpyMap<MatType,Scalar>::map(pyArray); // avoid useless cast
return; return;
} }
...@@ -285,7 +285,7 @@ namespace eigenpy ...@@ -285,7 +285,7 @@ namespace eigenpy
else else
{ {
assert(pyArray_Type == NumpyEquivalentType<Scalar>::type_code); assert(pyArray_Type == NumpyEquivalentType<Scalar>::type_code);
typename MapNumpy<MatType,Scalar,Options,NumpyMapStride>::EigenMap numpyMap = MapNumpy<MatType,Scalar,Options,NumpyMapStride>::map(pyArray); typename NumpyMap<MatType,Scalar,Options,NumpyMapStride>::EigenMap numpyMap = NumpyMap<MatType,Scalar,Options,NumpyMapStride>::map(pyArray);
RefType mat_ref(numpyMap); RefType mat_ref(numpyMap);
new (raw_ptr) StorageType(mat_ref,pyArray); new (raw_ptr) StorageType(mat_ref,pyArray);
} }
...@@ -340,7 +340,7 @@ namespace eigenpy ...@@ -340,7 +340,7 @@ namespace eigenpy
MatType & mat = *mat_ptr; MatType & mat = *mat_ptr;
if(pyArray_Type == NumpyEquivalentType<Scalar>::type_code) if(pyArray_Type == NumpyEquivalentType<Scalar>::type_code)
{ {
mat = MapNumpy<MatType,Scalar>::map(pyArray); // avoid useless cast mat = NumpyMap<MatType,Scalar>::map(pyArray); // avoid useless cast
return; return;
} }
...@@ -377,7 +377,7 @@ namespace eigenpy ...@@ -377,7 +377,7 @@ namespace eigenpy
else else
{ {
assert(pyArray_Type == NumpyEquivalentType<Scalar>::type_code); assert(pyArray_Type == NumpyEquivalentType<Scalar>::type_code);
typename MapNumpy<MatType,Scalar,Options,NumpyMapStride>::EigenMap numpyMap = MapNumpy<MatType,Scalar,Options,NumpyMapStride>::map(pyArray); typename NumpyMap<MatType,Scalar,Options,NumpyMapStride>::EigenMap numpyMap = NumpyMap<MatType,Scalar,Options,NumpyMapStride>::map(pyArray);
RefType mat_ref(numpyMap); RefType mat_ref(numpyMap);
new (raw_ptr) StorageType(mat_ref,pyArray); new (raw_ptr) StorageType(mat_ref,pyArray);
} }
...@@ -397,7 +397,7 @@ namespace eigenpy ...@@ -397,7 +397,7 @@ namespace eigenpy
static void allocate(PyArrayObject * pyArray, void * storage) static void allocate(PyArrayObject * pyArray, void * storage)
{ {
typename MapNumpy<MatType,Scalar>::EigenMap numpyMap = MapNumpy<MatType,Scalar>::map(pyArray); typename NumpyMap<MatType,Scalar>::EigenMap numpyMap = NumpyMap<MatType,Scalar>::map(pyArray);
new (storage) Type(numpyMap); new (storage) Type(numpyMap);
} }
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* Copyright 2018-2020, INRIA * Copyright 2018-2020, INRIA
*/ */
#ifndef __eigenpy_map_hpp__ #ifndef __eigenpy_numpy_map_hpp__
#define __eigenpy_map_hpp__ #define __eigenpy_numpy_map_hpp__
#include "eigenpy/fwd.hpp" #include "eigenpy/fwd.hpp"
#include "eigenpy/exception.hpp" #include "eigenpy/exception.hpp"
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
namespace eigenpy namespace eigenpy
{ {
template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride, bool IsVector = MatType::IsVectorAtCompileTime> template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride, bool IsVector = MatType::IsVectorAtCompileTime>
struct MapNumpyTraits {}; struct NumpyMapTraits {};
/* Wrap a numpy::array with an Eigen::Map. No memory copy. */ /* Wrap a numpy::array with an Eigen::Map. No memory copy. */
template<typename MatType, typename InputScalar, int AlignmentValue = EIGENPY_NO_ALIGNMENT_VALUE, typename Stride = typename StrideType<MatType>::type> template<typename MatType, typename InputScalar, int AlignmentValue = EIGENPY_NO_ALIGNMENT_VALUE, typename Stride = typename StrideType<MatType>::type>
struct MapNumpy struct NumpyMap
{ {
typedef MapNumpyTraits<MatType, InputScalar, AlignmentValue, Stride> Impl; typedef NumpyMapTraits<MatType, InputScalar, AlignmentValue, Stride> Impl;
typedef typename Impl::EigenMap EigenMap; typedef typename Impl::EigenMap EigenMap;
static EigenMap map(PyArrayObject* pyArray); static EigenMap map(PyArrayObject* pyArray);
...@@ -34,7 +34,7 @@ namespace eigenpy ...@@ -34,7 +34,7 @@ namespace eigenpy
namespace eigenpy namespace eigenpy
{ {
template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride> template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride>
struct MapNumpyTraits<MatType,InputScalar,AlignmentValue,Stride,false> struct NumpyMapTraits<MatType,InputScalar,AlignmentValue,Stride,false>
{ {
typedef Eigen::Matrix<InputScalar,MatType::RowsAtCompileTime,MatType::ColsAtCompileTime,MatType::Options> EquivalentInputMatrixType; typedef Eigen::Matrix<InputScalar,MatType::RowsAtCompileTime,MatType::ColsAtCompileTime,MatType::Options> EquivalentInputMatrixType;
typedef Eigen::Map<EquivalentInputMatrixType,AlignmentValue,Stride> EigenMap; typedef Eigen::Map<EquivalentInputMatrixType,AlignmentValue,Stride> EigenMap;
...@@ -108,7 +108,7 @@ namespace eigenpy ...@@ -108,7 +108,7 @@ namespace eigenpy
}; };
template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride> template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride>
struct MapNumpyTraits<MatType,InputScalar,AlignmentValue,Stride,true> struct NumpyMapTraits<MatType,InputScalar,AlignmentValue,Stride,true>
{ {
typedef Eigen::Matrix<InputScalar,MatType::RowsAtCompileTime,MatType::ColsAtCompileTime,MatType::Options> EquivalentInputMatrixType; typedef Eigen::Matrix<InputScalar,MatType::RowsAtCompileTime,MatType::ColsAtCompileTime,MatType::Options> EquivalentInputMatrixType;
typedef Eigen::Map<EquivalentInputMatrixType,AlignmentValue,Stride> EigenMap; typedef Eigen::Map<EquivalentInputMatrixType,AlignmentValue,Stride> EigenMap;
...@@ -140,12 +140,12 @@ namespace eigenpy ...@@ -140,12 +140,12 @@ namespace eigenpy
}; };
template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride> template<typename MatType, typename InputScalar, int AlignmentValue, typename Stride>
typename MapNumpy<MatType,InputScalar,AlignmentValue,Stride>::EigenMap typename NumpyMap<MatType,InputScalar,AlignmentValue,Stride>::EigenMap
MapNumpy<MatType,InputScalar,AlignmentValue,Stride>::map(PyArrayObject * pyArray) NumpyMap<MatType,InputScalar,AlignmentValue,Stride>::map(PyArrayObject * pyArray)
{ {
return Impl::mapImpl(pyArray); return Impl::mapImpl(pyArray);
} }
} // namespace eigenpy } // namespace eigenpy
#endif // define __eigenpy_map_hpp__ #endif // define __eigenpy_numpy_map_hpp__
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