File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,37 @@ struct implicit<Eigen::MatrixBase<MatType>,MatType>
4949 }
5050};
5151
52+ template <class MatType >
53+ struct implicit <MatType,Eigen::MatrixBase<MatType> >
54+ {
55+ typedef MatType Source;
56+ typedef Eigen::MatrixBase<MatType> Target;
57+
58+ static void * convertible (PyObject* obj)
59+ {
60+ // Find a converter which can produce a Source instance from
61+ // obj. The user has told us that Source can be converted to
62+ // Target, and instantiating construct() below, ensures that
63+ // at compile-time.
64+ return implicit_rvalue_convertible_from_python (obj, registered<Source>::converters)
65+ ? obj : 0 ;
66+ }
67+
68+ static void construct (PyObject* obj, rvalue_from_python_stage1_data* data)
69+ {
70+ void * storage = ((rvalue_from_python_storage<Source>*)data)->storage .bytes ;
71+
72+ arg_from_python<Source> get_source (obj);
73+ bool convertible = get_source.convertible ();
74+ BOOST_VERIFY (convertible);
75+
76+ new (storage) Source (get_source ());
77+
78+ // record successful construction
79+ data->convertible = storage;
80+ }
81+ };
82+
5283}}} // namespace boost::python::converter
5384
5485#define GET_PY_ARRAY_TYPE (array ) PyArray_ObjectType(reinterpret_cast <PyObject *>(array), 0 )
Original file line number Diff line number Diff line change 3232if verbose : print ("===> From Py to Eigen::MatrixXd" )
3333Mref = np .reshape (np .matrix (range (64 ),np .double ),[8 ,8 ])
3434
35+ # Test base function
36+ Mref_from_base = eigenpy .base (Mref )
37+ assert ( np .array_equal (Mref ,Mref_from_base ) );
38+
3539if verbose : print ("===> Matrix 8x8" )
3640M = Mref
3741assert ( np .array_equal (M ,eigenpy .reflex (M ,verbose )) );
You can’t perform that action at this time.
0 commit comments