File tree Expand file tree Collapse file tree 1 file changed +38
-2
lines changed Expand file tree Collapse file tree 1 file changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -378,17 +378,43 @@ namespace eigenpy
378378
379379 if (MatType::IsVectorAtCompileTime)
380380 {
381+ const Eigen::DenseIndex size_at_compile_time
382+ = MatType::IsRowMajor
383+ ? MatType::ColsAtCompileTime
384+ : MatType::RowsAtCompileTime;
385+
381386 switch (PyArray_NDIM (pyArray))
382387 {
383388 case 0 :
384389 return 0 ;
385390 case 1 :
386- return pyArray;
391+ {
392+ if (size_at_compile_time != Eigen::Dynamic)
393+ {
394+ // check that the sizes at compile time matche
395+ if (PyArray_DIMS (pyArray)[0 ] == size_at_compile_time)
396+ return pyArray;
397+ else
398+ return 0 ;
399+ }
400+ else // This is a dynamic MatType
401+ return pyArray;
402+ }
387403 case 2 :
388404 {
389405 // Special care of scalar matrix of dimension 1x1.
390406 if (PyArray_DIMS (pyArray)[0 ] == 1 && PyArray_DIMS (pyArray)[1 ] == 1 )
391- return pyArray;
407+ {
408+ if (size_at_compile_time != Eigen::Dynamic)
409+ {
410+ if (size_at_compile_time == 1 )
411+ return pyArray;
412+ else
413+ return 0 ;
414+ }
415+ else // This is a dynamic MatType
416+ return pyArray;
417+ }
392418
393419 if (PyArray_DIMS (pyArray)[0 ] > 1 && PyArray_DIMS (pyArray)[1 ] > 1 )
394420 {
@@ -409,6 +435,16 @@ namespace eigenpy
409435#endif
410436 return 0 ;
411437 }
438+
439+ if (size_at_compile_time != Eigen::Dynamic)
440+ { // This is a fixe size vector
441+ const Eigen::DenseIndex pyArray_size
442+ = PyArray_DIMS (pyArray)[0 ] > PyArray_DIMS (pyArray)[1 ]
443+ ? PyArray_DIMS (pyArray)[0 ]
444+ : PyArray_DIMS (pyArray)[1 ];
445+ if (size_at_compile_time != pyArray_size)
446+ return 0 ;
447+ }
412448 break ;
413449 }
414450 default :
You can’t perform that action at this time.
0 commit comments