本文整理汇总了C++中dynd::nd::array::get_readwrite_originptr方法的典型用法代码示例。如果您正苦于以下问题:C++ array::get_readwrite_originptr方法的具体用法?C++ array::get_readwrite_originptr怎么用?C++ array::get_readwrite_originptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dynd::nd::array
的用法示例。
在下文中一共展示了array::get_readwrite_originptr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: array_setitem
void pydynd::array_setitem(const dynd::nd::array& n, PyObject *subscript, PyObject *value)
{
if (subscript == Py_Ellipsis) {
array_broadcast_assign_from_py(n, value);
#if PY_VERSION_HEX < 0x03000000
} else if (PyInt_Check(subscript)) {
long i = PyInt_AS_LONG(subscript);
const char *metadata = n.get_ndo_meta();
char *data = n.get_readwrite_originptr();
ndt::type d = n.get_type().at_single(i, &metadata, const_cast<const char **>(&data));
array_broadcast_assign_from_py(d, metadata, data, value);
#endif // PY_VERSION_HEX < 0x03000000
} else if (PyLong_Check(subscript)) {
intptr_t i = PyLong_AsSsize_t(subscript);
if (i == -1 && PyErr_Occurred()) {
throw runtime_error("error converting int value");
}
const char *metadata = n.get_ndo_meta();
char *data = n.get_readwrite_originptr();
ndt::type d = n.get_type().at_single(i, &metadata, const_cast<const char **>(&data));
array_broadcast_assign_from_py(d, metadata, data, value);
} else {
intptr_t size;
shortvector<irange> indices;
pyobject_as_irange_array(size, indices, subscript);
array_broadcast_assign_from_py(n.at_array(size, indices.get(), false), value);
}
}
示例2:
void
pydynd::array_broadcast_assign_from_py(const dynd::nd::array &a,
PyObject *value,
const dynd::eval::eval_context *ectx)
{
array_broadcast_assign_from_py(a.get_type(), a.get_arrmeta(),
a.get_readwrite_originptr(), value, ectx);
}