Lines Matching defs:nd

65 #define ND_IS_CONSUMER(nd) \
66 (((NDArrayObject *)nd)->head == &((NDArrayObject *)nd)->staticbuf)
178 ndbuf_push(NDArrayObject *nd, ndbuf_t *elt)
180 elt->next = nd->head;
181 if (nd->head) nd->head->prev = elt;
182 nd->head = elt;
187 ndbuf_delete(NDArrayObject *nd, ndbuf_t *elt)
192 nd->head = elt->next;
201 ndbuf_pop(NDArrayObject *nd)
203 ndbuf_delete(nd, nd->head);
210 NDArrayObject *nd;
212 nd = PyObject_New(NDArrayObject, &NDArray_Type);
213 if (nd == NULL)
216 nd->flags = 0;
217 nd->head = NULL;
218 return (PyObject *)nd;
243 ndarray_init_staticbuf(PyObject *exporter, NDArrayObject *nd, int flags)
245 Py_buffer *base = &nd->staticbuf.base;
250 nd->head = &nd->staticbuf;
252 nd->head->next = NULL;
253 nd->head->prev = NULL;
254 nd->head->len = -1;
255 nd->head->offset = -1;
256 nd->head->data = NULL;
258 nd->head->flags = base->readonly ? 0 : ND_WRITABLE;
259 nd->head->exports = 0;
658 ndarray_as_list(NDArrayObject *nd)
662 Py_buffer *base = &nd->head->base;
671 base = &nd->head->base;
680 assert(ND_C_CONTIGUOUS(nd->head->flags));
689 assert(ND_C_CONTIGUOUS(nd->head->flags));
690 strides = strides_from_shape(nd->head, 0);
1264 ndarray_push_base(NDArrayObject *nd, PyObject *items,
1274 ndbuf_push(nd, ndbuf);
1282 NDArrayObject *nd = (NDArrayObject *)self;
1312 if (ndarray_init_staticbuf(v, nd, getbuf) < 0)
1315 init_flags(nd->head);
1316 nd->head->flags |= flags;
1336 nd->flags |= ND_VAREXPORT;
1341 return ndarray_push_base(nd, v, shape, strides, offset, format, flags);
1348 NDArrayObject *nd = (NDArrayObject *)self;
1368 if (ND_IS_CONSUMER(nd)) {
1373 if (!(nd->flags&ND_VAREXPORT) && nd->head->exports > 0) {
1376 nd->head->exports, nd->head->exports==1 ? "" : "s");
1380 if (ndarray_push_base(nd, items, shape, strides,
1390 NDArrayObject *nd = (NDArrayObject *)self;
1391 if (ND_IS_CONSUMER(nd)) {
1396 if (nd->head->exports > 0) {
1399 nd->head->exports, nd->head->exports==1 ? "" : "s");
1402 if (nd->head->next == NULL) {
1408 ndbuf_pop(nd);
1607 NDArrayObject *nd;
1610 nd = (NDArrayObject *)ndarray_new(&NDArray_Type, NULL, NULL);
1611 if (nd == NULL)
1614 if (ndarray_init_staticbuf((PyObject *)self, nd, PyBUF_FULL_RO) < 0) {
1615 Py_DECREF(nd);
1619 subview = &nd->staticbuf.base;
1629 init_flags(&nd->staticbuf);
1631 return (PyObject *)nd;
1782 NDArrayObject *nd;
1806 nd = (NDArrayObject *)ndarray_new(&NDArray_Type, NULL, NULL);
1807 if (nd == NULL)
1811 if (ndarray_init_staticbuf((PyObject *)self, nd, PyBUF_FULL_RO) < 0) {
1812 Py_DECREF(nd);
1817 ndbuf = nd->head;
1820 Py_DECREF(nd);
1851 return (PyObject *)nd;
1859 Py_DECREF(nd);
1867 NDArrayObject *nd;
1910 nd = (NDArrayObject *)ndarray_subscript(self, key);
1911 if (nd != NULL) {
1912 dest = &nd->head->base;
1914 Py_DECREF(nd);
2088 NDArrayObject *nd = (NDArrayObject *)self;
2089 int ret = PyBuffer_IsContiguous(&nd->head->base, 'C');
2091 if (ret != ND_C_CONTIGUOUS(nd->head->flags)) {
2102 NDArrayObject *nd = (NDArrayObject *)self;
2103 int ret = PyBuffer_IsContiguous(&nd->head->base, 'F');
2105 if (ret != ND_FORTRAN_CONTIGUOUS(nd->head->flags)) {
2116 NDArrayObject *nd = (NDArrayObject *)self;
2117 int ret = PyBuffer_IsContiguous(&nd->head->base, 'A');
2119 if (ret != ND_ANY_CONTIGUOUS(nd->head->flags)) {
2198 NDArrayObject *nd = (NDArrayObject *)self;
2199 Py_buffer *base = &nd->head->base;
2222 nd->head->flags &= ~(ND_C|ND_FORTRAN);
2234 const NDArrayObject *nd = (NDArrayObject *)self;
2235 const Py_buffer *view = &nd->head->base;
2244 if (!ND_IS_CONSUMER(nd))
2245 ndbuf = nd->head; /* self is ndarray/original exporter */
2607 const NDArrayObject *nd = (NDArrayObject *)self;
2608 const Py_buffer *view = &nd->head->base;