MCPcopy Create free account
hub / github.com/pybind/pybind11 / eigen_array_cast

Function eigen_array_cast

include/pybind11/eigen/matrix.h:249–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247// otherwise it'll make a copy. writeable lets you turn off the writeable flag for the array.
248template <typename props>
249handle
250eigen_array_cast(typename props::Type const &src, handle base = handle(), bool writeable = true) {
251 constexpr ssize_t elem_size = sizeof(typename props::Scalar);
252 array a;
253 if (props::vector) {
254 a = array({src.size()}, {elem_size * src.innerStride()}, src.data(), base);
255 } else {
256 a = array({src.rows(), src.cols()},
257 {elem_size * src.rowStride(), elem_size * src.colStride()},
258 src.data(),
259 base);
260 }
261
262 if (!writeable) {
263 array_proxy(a.ptr())->flags &= ~detail::npy_api::NPY_ARRAY_WRITEABLE_;
264 }
265
266 return a.release();
267}
268
269// Takes an lvalue ref to some Eigen type and a (python) base object, creating a numpy array that
270// reference the Eigen object's data with `base` as the python-registered base class (if omitted,

Callers

nothing calls this directly

Calls 9

arrayClass · 0.85
array_proxyFunction · 0.85
ptrMethod · 0.80
releaseMethod · 0.80
handleFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45
rowsMethod · 0.45
colsMethod · 0.45

Tested by

no test coverage detected