You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got some Eigen::Matrixes that, depending on some runtime data, either represents a (row)-vector or a 2d matrix. I would like to expose them as either 1D or 2D numpy arrays depending on this runtime variable (whether or not this is a lovely API is a separate question, but it's aiming to be compatible with some existing code).
How would I approach this? I would ideally like to be able to return both no-copy views on internal Eigen::Matrix members (i.e. rv_policy::reference_internal), as well as return by-move matrices that I construct on-the-fly.
I started down a route of copying some of the code in
, but I seemed to end up needing to reimplement all of the ownership management stuff, and started to have to put rv_policy values inside my functions rather than just on the bindings. I wonder if there is a simpler way to approach this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've got some
Eigen::Matrix
es that, depending on some runtime data, either represents a (row)-vector or a 2d matrix. I would like to expose them as either 1D or 2D numpy arrays depending on this runtime variable (whether or not this is a lovely API is a separate question, but it's aiming to be compatible with some existing code).How would I approach this? I would ideally like to be able to return both no-copy views on internal
Eigen::Matrix
members (i.e.rv_policy::reference_internal
), as well as return by-move matrices that I construct on-the-fly.I started down a route of copying some of the code in
nanobind/include/nanobind/eigen/dense.h
Lines 159 to 212 in 0435e16
rv_policy
values inside my functions rather than just on the bindings. I wonder if there is a simpler way to approach this?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions