5#include <boost/python.hpp>
6#include <boost/python/class.hpp>
7#include <boost/python/return_value_policy.hpp>
9#include <fmt/ostream.h>
21template <
typename MatrixType,
typename Class>
struct eigen_member {
23 typedef Eigen::Ref<const MatrixType> ConstMatRef;
25 eigen_member(MatrixType Class::*which) : m_which(which) {}
27 Eigen::Ref<MatrixType> operator()(Class &c)
const {
return c.*m_which; }
29 void operator()(Class &c,
30 typename bp::detail::value_arg<ConstMatRef>::type d)
const {
35 MatrixType Class::*m_which;
44template <
class C,
class MatrixType>
46 typedef Eigen::Ref<MatrixType> RefType;
47 return bp::make_function(
48 internal::eigen_member<MatrixType, C>(v),
49 bp::return_value_policy<bp::return_by_value,
50 bp::with_custodian_and_ward_postcall<0UL, 1UL>>(),
51 boost::mpl::vector2<RefType, C &>());
54template <
class C,
class MatrixType,
class Policies>
56 Policies const &policies) {
57 typedef Eigen::Ref<const MatrixType> ConstRefType;
58 return bp::make_function(
59 internal::eigen_member<MatrixType, C>(v), policies,
60 boost::mpl::vector3<void, C &, const ConstRefType>());
63template <
class C,
class MatrixType>
bp::object make_setter_eigen_matrix(MatrixType C::*v, Policies const &policies)
bp::object make_getter_eigen_matrix(MatrixType C::*v)
Create a getter for Eigen::Matrix type objects which returns an Eigen::Ref.