Lines Matching refs:ndim
256 (view->suboffsets && view->suboffsets[dest->ndim-1] >= 0)
261 assert(dest->ndim > 0 && src->ndim > 0); in last_dim_is_contiguous()
264 dest->strides[dest->ndim-1] == dest->itemsize && in last_dim_is_contiguous()
265 src->strides[src->ndim-1] == src->itemsize); in last_dim_is_contiguous()
299 if (dest->ndim != src->ndim) in equiv_shape()
302 for (i = 0; i < dest->ndim; i++) { in equiv_shape()
362 copy_rec(const Py_ssize_t *shape, Py_ssize_t ndim, Py_ssize_t itemsize, in copy_rec() argument
369 assert(ndim >= 1); in copy_rec()
371 if (ndim == 1) { in copy_rec()
383 copy_rec(shape+1, ndim-1, itemsize, in copy_rec()
396 assert(dest->ndim == 1); in copy_single()
428 assert(dest->ndim > 0); in copy_buffer()
434 mem = PyMem_Malloc(dest->shape[dest->ndim-1] * dest->itemsize); in copy_buffer()
441 copy_rec(dest->shape, dest->ndim, dest->itemsize, in copy_buffer()
458 assert(view->ndim > 0); in init_strides_from_shape()
460 view->strides[view->ndim-1] = view->itemsize; in init_strides_from_shape()
461 for (i = view->ndim-2; i >= 0; i--) in init_strides_from_shape()
471 assert(view->ndim > 0); in init_fortran_strides_from_shape()
474 for (i = 1; i < view->ndim; i++) in init_fortran_strides_from_shape()
488 assert(src->ndim >= 1); in buffer_to_contiguous()
492 strides = PyMem_Malloc(src->ndim * (sizeof *src->strides)); in buffer_to_contiguous()
546 if (src->ndim == 0) { in init_shape_strides()
551 if (src->ndim == 1) { in init_shape_strides()
557 for (i = 0; i < src->ndim; i++) in init_shape_strides()
560 for (i = 0; i < src->ndim; i++) in init_shape_strides()
577 for (i = 0; i < src->ndim; i++) in init_suboffsets()
588 for (i = 0; i < view->ndim; i++) in init_len()
602 switch (view->ndim) { in init_flags()
630 memory_alloc(int ndim) in memory_alloc() argument
635 PyObject_GC_NewVar(PyMemoryViewObject, &PyMemoryView_Type, 3*ndim); in memory_alloc()
643 mv->view.ndim = ndim; in memory_alloc()
645 mv->view.strides = mv->ob_array + ndim; in memory_alloc()
646 mv->view.suboffsets = mv->ob_array + 2 * ndim; in memory_alloc()
670 if (src->ndim > PyBUF_MAX_NDIM) { in mbuf_add_view()
677 mv = memory_alloc(src->ndim); in mbuf_add_view()
701 int ndim) in mbuf_add_incomplete_view() argument
709 assert(ndim <= PyBUF_MAX_NDIM); in mbuf_add_incomplete_view()
711 mv = memory_alloc(ndim); in mbuf_add_incomplete_view()
851 assert(src->ndim > 0); in memory_from_contiguous_copy()
868 mv = (PyMemoryViewObject *)mbuf_add_incomplete_view(mbuf, NULL, src->ndim); in memory_from_contiguous_copy()
879 for (i = 0; i < src->ndim; i++) { in memory_from_contiguous_copy()
1004 fb = PyMem_Malloc(sizeof *fb + 3 * src->ndim * (sizeof *fb->array)); in PyBuffer_ToContiguous()
1009 fb->view.ndim = src->ndim; in PyBuffer_ToContiguous()
1011 fb->view.strides = fb->array + src->ndim; in PyBuffer_ToContiguous()
1012 fb->view.suboffsets = fb->array + 2 * src->ndim; in PyBuffer_ToContiguous()
1204 assert(view->ndim >= 1); in cast_to_1D()
1205 assert(Py_SIZE(mv) == 3*view->ndim); in cast_to_1D()
1207 assert(view->strides == mv->ob_array + view->ndim); in cast_to_1D()
1208 assert(view->suboffsets == mv->ob_array + 2*view->ndim); in cast_to_1D()
1243 view->ndim = 1; in cast_to_1D()
1259 copy_shape(Py_ssize_t *shape, const PyObject *seq, Py_ssize_t ndim, in copy_shape() argument
1265 for (i = 0; i < ndim; i++) { in copy_shape()
1298 cast_to_ND(PyMemoryViewObject *mv, const PyObject *shape, int ndim) in cast_to_ND() argument
1303 assert(view->ndim == 1); /* ndim from cast_to_1D() */ in cast_to_ND()
1304 assert(Py_SIZE(mv) == 3*(ndim==0?1:ndim)); /* ndim of result array */ in cast_to_ND()
1306 assert(view->strides == mv->ob_array + (ndim==0?1:ndim)); in cast_to_ND()
1309 view->ndim = ndim; in cast_to_ND()
1310 if (view->ndim == 0) { in cast_to_ND()
1316 len = copy_shape(view->shape, shape, ndim, view->itemsize); in cast_to_ND()
1339 for (i = 0; i < view->ndim; i++) in zero_in_shape()
1373 Py_ssize_t ndim = 1; in memoryview_cast_impl() local
1382 if ((shape || self->view.ndim != 1) && zero_in_shape(self)) { in memoryview_cast_impl()
1389 ndim = PySequence_Fast_GET_SIZE(shape); in memoryview_cast_impl()
1390 if (ndim > PyBUF_MAX_NDIM) { in memoryview_cast_impl()
1396 if (self->view.ndim != 1 && ndim != 1) { in memoryview_cast_impl()
1404 mbuf_add_incomplete_view(self->mbuf, &self->view, ndim==0 ? 1 : (int)ndim); in memoryview_cast_impl()
1410 if (shape && cast_to_ND(mv, shape, (int)ndim) < 0) in memoryview_cast_impl()
1513 view->ndim = 1; in memory_getbuf()
2086 tolist_rec(const char *ptr, Py_ssize_t ndim, const Py_ssize_t *shape, in tolist_rec() argument
2093 assert(ndim >= 1); in tolist_rec()
2097 if (ndim == 1) in tolist_rec()
2106 item = tolist_rec(xptr, ndim-1, shape+1, in tolist_rec()
2139 if (view->ndim == 0) { in memoryview_tolist_impl()
2142 else if (view->ndim == 1) { in memoryview_tolist_impl()
2148 return tolist_rec(view->buf, view->ndim, view->shape, in memoryview_tolist_impl()
2313 if (nindices > view->ndim) { in ptr_from_tuple()
2316 view->ndim, nindices); in ptr_from_tuple()
2348 if (view->ndim == 0) { in memory_item()
2352 if (view->ndim == 1) { in memory_item()
2379 if (nindices < view->ndim) { in memory_item_multi()
2469 if (view->ndim == 0) { in memory_subscript()
2545 if (view->ndim == 0) { in memory_ass_sub()
2560 if (1 < view->ndim) { in memory_ass_sub()
2574 if (PySlice_Check(key) && view->ndim == 1) { in memory_ass_sub()
2602 if (PyTuple_GET_SIZE(key) < view->ndim) { in memory_ass_sub()
2629 return self->view.ndim == 0 ? 1 : self->view.shape[0]; in memory_length()
2793 Py_ssize_t ndim, const Py_ssize_t *shape, in cmp_rec() argument
2801 assert(ndim >= 1); in cmp_rec()
2806 if (ndim == 1) { in cmp_rec()
2816 equal = cmp_rec(xp, xq, ndim-1, shape+1, in cmp_rec()
2892 if (vv->ndim == 0) { in memory_richcompare()
2896 else if (vv->ndim == 1) { in memory_richcompare()
2903 equal = cmp_rec(vv->buf, ww->buf, vv->ndim, vv->shape, in memory_richcompare()
3051 return _IntTupleFromSsizet(self->view.ndim, self->view.shape); in memory_shape_get()
3058 return _IntTupleFromSsizet(self->view.ndim, self->view.strides); in memory_strides_get()
3065 return _IntTupleFromSsizet(self->view.ndim, self->view.suboffsets); in memory_suboffsets_get()
3079 return PyLong_FromLong(self->view.ndim); in memory_ndim_get()
3227 int ndims = obj->view.ndim; in memory_iter()