From c5e81d548230e12eecc5f9b4fdebe49bb010c1ba Mon Sep 17 00:00:00 2001
From: Justin Carpentier <justin.carpentier@inria.fr>
Date: Tue, 18 Aug 2020 16:39:21 +0200
Subject: [PATCH] core: swap dimensions if needed

---
 include/eigenpy/eigen-allocator.hpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/eigenpy/eigen-allocator.hpp b/include/eigenpy/eigen-allocator.hpp
index b23fa2fb..343f7681 100644
--- a/include/eigenpy/eigen-allocator.hpp
+++ b/include/eigenpy/eigen-allocator.hpp
@@ -105,11 +105,11 @@ namespace eigenpy
   } // namespace details
 
 #define EIGENPY_CAST_FROM_PYARRAY_TO_EIGEN_MATRIX(MatType,Scalar,NewScalar,pyArray,mat) \
-  details::cast_matrix_or_array<Scalar,NewScalar>::run(NumpyMap<MatType,Scalar>::map(pyArray),mat)
+  details::cast_matrix_or_array<Scalar,NewScalar>::run(NumpyMap<MatType,Scalar>::map(pyArray,details::check_swap(pyArray,mat)),mat)
 
 #define EIGENPY_CAST_FROM_EIGEN_MATRIX_TO_PYARRAY(MatType,Scalar,NewScalar,mat,pyArray) \
-  details::cast_matrix_or_array<Scalar,NewScalar>::run(mat,NumpyMap<MatType,NewScalar>::map(pyArray))
-  
+  details::cast_matrix_or_array<Scalar,NewScalar>::run(mat,NumpyMap<MatType,NewScalar>::map(pyArray,details::check_swap(pyArray,mat)))
+
   template<typename MatType>
   struct EigenAllocator
   {
@@ -127,7 +127,7 @@ namespace eigenpy
       const int Scalar_type_code = Register::getTypeCode<Scalar>();
       if(pyArray_type_code == Scalar_type_code)
       {
-        mat = NumpyMap<MatType,Scalar>::map(pyArray); // avoid useless cast
+        mat = NumpyMap<MatType,Scalar>::map(pyArray,details::check_swap(pyArray,mat)); // avoid useless cast
         return;
       }
       
@@ -175,7 +175,7 @@ namespace eigenpy
       
       if(pyArray_type_code == Scalar_type_code) // no cast needed
       {
-        MapType map_pyArray = NumpyMap<MatType,Scalar>::map(pyArray);
+        MapType map_pyArray = NumpyMap<MatType,Scalar>::map(pyArray,details::check_swap(pyArray,mat));
         map_pyArray = mat;
         return;
       }
@@ -257,7 +257,7 @@ namespace eigenpy
         RefType & mat = *reinterpret_cast<RefType*>(raw_ptr);
         if(pyArray_type_code == Scalar_type_code)
         {
-          mat = NumpyMap<MatType,Scalar>::map(pyArray); // avoid useless cast
+          mat = NumpyMap<MatType,Scalar>::map(pyArray,details::check_swap(pyArray,mat)); // avoid useless cast
           return;
         }
         
@@ -351,7 +351,7 @@ namespace eigenpy
         MatType & mat = *mat_ptr;
         if(pyArray_type_code == Scalar_type_code)
         {
-          mat = NumpyMap<MatType,Scalar>::map(pyArray); // avoid useless cast
+          mat = NumpyMap<MatType,Scalar>::map(pyArray,details::check_swap(pyArray,mat)); // avoid useless cast
           return;
         }
         
-- 
GitLab