Lines Matching defs:shape

155     base->shape = NULL;
170 PyMem_XFree(base->shape);
228 PyMem_XFree(base->shape);
473 copy_rec(const Py_ssize_t *shape, Py_ssize_t ndim, Py_ssize_t itemsize,
485 memmove(dptr, sptr, shape[0] * itemsize);
490 for (i=0, p=mem; i<shape[0]; p+=itemsize, sptr+=sstrides[0], i++) {
494 for (i=0, p=mem; i<shape[0]; p+=itemsize, dptr+=dstrides[0], i++) {
502 for (i = 0; i < shape[0]; dptr+=dstrides[0], sptr+=sstrides[0], i++) {
506 copy_rec(shape+1, ndim-1, itemsize,
524 if (dest->shape[i] != src->shape[i])
526 if (dest->shape[i] == 0)
534 ndim and shape. Copying is atomic, the function never fails with
553 mem = PyMem_Malloc(dest->shape[dest->ndim-1] * dest->itemsize);
560 copy_rec(dest->shape, dest->ndim, dest->itemsize,
611 const Py_ssize_t *shape, const Py_ssize_t *strides,
618 assert(shape != NULL);
635 lst = PyList_New(shape[0]);
639 for (i = 0; i < shape[0]; ptr+=strides[0], i++) {
643 shape+1, strides+1, suboffsets ? suboffsets+1 : NULL,
663 Py_ssize_t *shape = base->shape;
679 if (shape == NULL) {
683 shape = simple_shape;
684 shape[0] = base->len;
719 shape, strides, base->suboffsets,
774 | base.shape | NULL | NULL | OK |
865 is_shape ? "shape" : "strides");
876 "elements of shape must be integers >= 0");
901 s[i] = s[i-1] * base->shape[i-1];
906 s[i] = s[i+1] * base->shape[i+1];
922 and all indices combined with negative strides are shape[n]-1, which is
926 and all indices combined with positive strides are shape[n]-1.
930 const Py_ssize_t *shape, const Py_ssize_t *strides,
949 if (shape[n] == 0)
955 imin += (shape[n]-1) * strides[n];
957 imax += (shape[n]-1) * strides[n];
967 "invalid combination of buffer, shape and strides");
980 shape = {2, 2, 3};
988 shape = {2, 2, 3};
1008 shape = {2, 2, 3};
1016 shape = {2, 2, 3};
1042 /* Allocate new data with additional space for shape[0] pointers. */
1043 addsize = base->shape[0] * (sizeof (char *));
1066 if (base->shape[n] == 0)
1069 Py_ssize_t x = (base->shape[n]-1) * base->strides[n];
1079 for (n = 0; n < base->shape[0]; n++)
1099 if (base->shape[0] > 0)
1100 base->buf = (char *)base->buf + (base->shape[0]-1) * sizeof(char *);
1115 base->len *= base->shape[i];
1120 init_structure(ndbuf_t *ndbuf, PyObject *shape, PyObject *strides,
1136 /* shape */
1137 base->shape = seq_as_ssize_array(shape, ndim, 1);
1138 if (base->shape == NULL)
1151 base->shape, base->strides, ndim) < 0)
1177 init_ndbuf(PyObject *items, PyObject *shape, PyObject *strides,
1185 /* ndim = len(shape) */
1186 CHECK_LIST_OR_TUPLE(shape)
1187 ndim = PySequence_Fast_GET_SIZE(shape);
1194 /* len(strides) = len(shape) */
1206 "len(shape) != len(strides)");
1250 if (init_structure(ndbuf, shape, strides, ndim) < 0)
1265 PyObject *shape, PyObject *strides,
1270 ndbuf = init_ndbuf(items, shape, strides, offset, format, flags);
1284 "obj", "shape", "strides", "offset", "format", "flags", "getbuf", NULL
1287 PyObject *shape = NULL; /* size of each dimension */
1297 &v, &shape, &strides, &offset, &format, &flags, &getbuf))
1301 if (PyObject_CheckBuffer(v) && shape == NULL) {
1328 if (shape == NULL) {
1330 "shape is a required argument when constructing from "
1341 return ndarray_push_base(nd, v, shape, strides, offset, format, flags);
1350 "items", "shape", "strides", "offset", "format", "flags", NULL
1353 PyObject *shape = NULL; /* size of each dimension */
1360 &items, &shape, &strides, &offset, &format, &flags))
1380 if (ndarray_push_base(nd, items, shape, strides,
1437 ((REQ_SHAPE(flags) && base->shape == NULL) ||
1443 "re-exporter does not provide format, shape or strides");
1462 view->itemsize is the _previous_ itemsize. If shape is present,
1463 the equality product(shape) * itemsize = len still holds at this
1508 /* product(shape) * itemsize = len and calcsize(format) = itemsize
1511 view->shape = NULL;
1517 (view->format != NULL && view->shape != NULL &&
1520 (view->format == NULL && view->shape == NULL &&
1560 if (base->shape)
1561 nitems = base->shape[0];
1622 subview->len /= subview->shape[0];
1625 subview->shape++;
1656 Adjust shape:
1658 Obviously shape[n] = slicelength[n]
1697 Adjust shape and strides:
1719 slicelength = PySlice_AdjustIndices(base->shape[dim], &start, &stop, step);
1734 base->shape[dim] = slicelength;
1743 Py_ssize_t *shape = NULL, *strides = NULL, *suboffsets = NULL;
1746 shape = PyMem_Malloc(base->ndim * (sizeof *shape));
1748 if (shape == NULL || strides == NULL)
1759 shape[i] = base->shape[i];
1765 base->shape = shape;
1773 PyMem_XFree(shape);
1816 /* copy shape, strides and suboffsets */
2068 return ssize_array_as_tuple(base->shape, base->ndim);
2140 { "shape", (getter)ndarray_get_shape, NULL, NULL, NULL},
2167 assert(src->shape != NULL);
2238 static Py_ssize_t shape[ND_MAX_NDIM];
2286 if (view->shape) {
2287 memcpy(shape, view->shape, view->ndim * sizeof(Py_ssize_t));
2288 info.shape = shape;
2338 if (indices[i] < 0 || indices[i] >= view.shape[i]) {
2482 arraycmp(const Py_ssize_t *a1, const Py_ssize_t *a2, const Py_ssize_t *shape,
2489 if (shape && shape[i] <= 1) {
2538 !!v1.shape != !!v2.shape ||
2544 if ((v1.shape && !arraycmp(v1.shape, v2.shape, NULL, v1.ndim)) ||
2545 (v1.strides && !arraycmp(v1.strides, v2.strides, v1.shape, v1.ndim)) ||
2706 static_shape, /* shape */