Commit 17d0283e by Jason Rhinelander Committed by Wenzel Jakob

Eigen<->numpy referencing support

This commit largely rewrites the Eigen dense matrix support to avoid
copying in many cases: Eigen arguments can now reference numpy data, and
numpy objects can now reference Eigen data (given compatible types).

Eigen::Ref<...> arguments now also make use of the new `convert`
argument use (added in PR #634) to avoid conversion, allowing
`py::arg().noconvert()` to be used when binding a function to prohibit
copying when invoking the function.  Respecting `convert` also means
Eigen overloads that avoid copying will be preferred during overload
resolution to ones that require copying.

This commit also rewrites the Eigen documentation and test suite to
explain and test the new capabilities.
parent 546f6fce
...@@ -6,6 +6,8 @@ with the basics of binding functions and classes, as explained in :doc:`/basics` ...@@ -6,6 +6,8 @@ with the basics of binding functions and classes, as explained in :doc:`/basics`
and :doc:`/classes`. The following guide is applicable to both free and member and :doc:`/classes`. The following guide is applicable to both free and member
functions, i.e. *methods* in Python. functions, i.e. *methods* in Python.
.. _return_value_policies:
Return value policies Return value policies
===================== =====================
...@@ -320,6 +322,8 @@ like so: ...@@ -320,6 +322,8 @@ like so:
py::class_<MyClass>("MyClass") py::class_<MyClass>("MyClass")
.def("myFunction", py::arg("arg") = (SomeType *) nullptr); .def("myFunction", py::arg("arg") = (SomeType *) nullptr);
.. _nonconverting_arguments:
Non-converting arguments Non-converting arguments
======================== ========================
......
Markdown is supported
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