本文整理汇总了C++中dynd::nd::array::at_array方法的典型用法代码示例。如果您正苦于以下问题:C++ array::at_array方法的具体用法?C++ array::at_array怎么用?C++ array::at_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dynd::nd::array
的用法示例。
在下文中一共展示了array::at_array方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
dynd::nd::array pydynd::array_getitem(const dynd::nd::array& n, PyObject *subscript)
{
if (subscript == Py_Ellipsis) {
return n.at_array(0, NULL);
} else {
// Convert the pyobject into an array of iranges
intptr_t size;
shortvector<irange> indices;
pyobject_as_irange_array(size, indices, subscript);
// Do an indexing operation
return n.at_array(size, indices.get());
}
}
示例2: array_setitem
void pydynd::array_setitem(const dynd::nd::array &n, PyObject *subscript,
PyObject *value)
{
if (subscript == Py_Ellipsis) {
n.assign(value);
#if PY_VERSION_HEX < 0x03000000
}
else if (PyInt_Check(subscript)) {
long i = PyInt_AS_LONG(subscript);
n(i).assign(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");
}
n(i).assign(value);
}
else {
intptr_t size;
shortvector<irange> indices;
pyobject_as_irange_array(size, indices, subscript);
n.at_array(size, indices.get(), false).assign(value);
}
}
示例3: 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);
}
}