Lines Matching refs:ndim
246 (view->suboffsets && view->suboffsets[dest->ndim-1] >= 0)
251 assert(dest->ndim > 0 && src->ndim > 0); in last_dim_is_contiguous()
254 dest->strides[dest->ndim-1] == dest->itemsize && in last_dim_is_contiguous()
255 src->strides[src->ndim-1] == src->itemsize); in last_dim_is_contiguous()
289 if (dest->ndim != src->ndim) in equiv_shape()
292 for (i = 0; i < dest->ndim; i++) { in equiv_shape()
352 copy_rec(const Py_ssize_t *shape, Py_ssize_t ndim, Py_ssize_t itemsize, in copy_rec() argument
359 assert(ndim >= 1); in copy_rec()
361 if (ndim == 1) { in copy_rec()
373 copy_rec(shape+1, ndim-1, itemsize, in copy_rec()
386 assert(dest->ndim == 1); in copy_single()
418 assert(dest->ndim > 0); in copy_buffer()
424 mem = PyMem_Malloc(dest->shape[dest->ndim-1] * dest->itemsize); in copy_buffer()
431 copy_rec(dest->shape, dest->ndim, dest->itemsize, in copy_buffer()
448 assert(view->ndim > 0); in init_strides_from_shape()
450 view->strides[view->ndim-1] = view->itemsize; in init_strides_from_shape()
451 for (i = view->ndim-2; i >= 0; i--) in init_strides_from_shape()
461 assert(view->ndim > 0); in init_fortran_strides_from_shape()
464 for (i = 1; i < view->ndim; i++) in init_fortran_strides_from_shape()
478 assert(src->ndim >= 1); in buffer_to_contiguous()
482 strides = PyMem_Malloc(src->ndim * (sizeof *src->strides)); in buffer_to_contiguous()
536 if (src->ndim == 0) { in init_shape_strides()
541 if (src->ndim == 1) { in init_shape_strides()
547 for (i = 0; i < src->ndim; i++) in init_shape_strides()
550 for (i = 0; i < src->ndim; i++) in init_shape_strides()
567 for (i = 0; i < src->ndim; i++) in init_suboffsets()
578 for (i = 0; i < view->ndim; i++) in init_len()
592 switch (view->ndim) { in init_flags()
620 memory_alloc(int ndim) in memory_alloc() argument
625 PyObject_GC_NewVar(PyMemoryViewObject, &PyMemoryView_Type, 3*ndim); in memory_alloc()
633 mv->view.ndim = ndim; in memory_alloc()
635 mv->view.strides = mv->ob_array + ndim; in memory_alloc()
636 mv->view.suboffsets = mv->ob_array + 2 * ndim; in memory_alloc()
660 if (src->ndim > PyBUF_MAX_NDIM) { in mbuf_add_view()
667 mv = memory_alloc(src->ndim); in mbuf_add_view()
691 int ndim) in mbuf_add_incomplete_view() argument
699 assert(ndim <= PyBUF_MAX_NDIM); in mbuf_add_incomplete_view()
701 mv = memory_alloc(ndim); in mbuf_add_incomplete_view()
841 assert(src->ndim > 0); in memory_from_contiguous_copy()
858 mv = (PyMemoryViewObject *)mbuf_add_incomplete_view(mbuf, NULL, src->ndim); in memory_from_contiguous_copy()
869 for (i = 0; i < src->ndim; i++) { in memory_from_contiguous_copy()
992 fb = PyMem_Malloc(sizeof *fb + 3 * src->ndim * (sizeof *fb->array)); in PyBuffer_ToContiguous()
997 fb->view.ndim = src->ndim; in PyBuffer_ToContiguous()
999 fb->view.strides = fb->array + src->ndim; in PyBuffer_ToContiguous()
1000 fb->view.suboffsets = fb->array + 2 * src->ndim; in PyBuffer_ToContiguous()
1184 assert(view->ndim >= 1); in cast_to_1D()
1185 assert(Py_SIZE(mv) == 3*view->ndim); in cast_to_1D()
1187 assert(view->strides == mv->ob_array + view->ndim); in cast_to_1D()
1188 assert(view->suboffsets == mv->ob_array + 2*view->ndim); in cast_to_1D()
1223 view->ndim = 1; in cast_to_1D()
1239 copy_shape(Py_ssize_t *shape, const PyObject *seq, Py_ssize_t ndim, in copy_shape() argument
1245 for (i = 0; i < ndim; i++) { in copy_shape()
1278 cast_to_ND(PyMemoryViewObject *mv, const PyObject *shape, int ndim) in cast_to_ND() argument
1283 assert(view->ndim == 1); /* ndim from cast_to_1D() */ in cast_to_ND()
1284 assert(Py_SIZE(mv) == 3*(ndim==0?1:ndim)); /* ndim of result array */ in cast_to_ND()
1286 assert(view->strides == mv->ob_array + (ndim==0?1:ndim)); in cast_to_ND()
1289 view->ndim = ndim; in cast_to_ND()
1290 if (view->ndim == 0) { in cast_to_ND()
1296 len = copy_shape(view->shape, shape, ndim, view->itemsize); in cast_to_ND()
1319 for (i = 0; i < view->ndim; i++) in zero_in_shape()
1345 Py_ssize_t ndim = 1; in memory_cast() local
1363 if ((shape || self->view.ndim != 1) && zero_in_shape(self)) { in memory_cast()
1370 ndim = PySequence_Fast_GET_SIZE(shape); in memory_cast()
1371 if (ndim > PyBUF_MAX_NDIM) { in memory_cast()
1377 if (self->view.ndim != 1 && ndim != 1) { in memory_cast()
1385 mbuf_add_incomplete_view(self->mbuf, &self->view, ndim==0 ? 1 : (int)ndim); in memory_cast()
1391 if (shape && cast_to_ND(mv, shape, (int)ndim) < 0) in memory_cast()
1473 view->ndim = 1; in memory_getbuf()
2046 tolist_rec(const char *ptr, Py_ssize_t ndim, const Py_ssize_t *shape, in tolist_rec() argument
2053 assert(ndim >= 1); in tolist_rec()
2057 if (ndim == 1) in tolist_rec()
2066 item = tolist_rec(xptr, ndim-1, shape+1, in tolist_rec()
2092 if (view->ndim == 0) { in memory_tolist()
2095 else if (view->ndim == 1) { in memory_tolist()
2101 return tolist_rec(view->buf, view->ndim, view->shape, in memory_tolist()
2208 if (nindices > view->ndim) { in ptr_from_tuple()
2211 view->ndim, nindices); in ptr_from_tuple()
2243 if (view->ndim == 0) { in memory_item()
2247 if (view->ndim == 1) { in memory_item()
2274 if (nindices < view->ndim) { in memory_item_multi()
2363 if (view->ndim == 0) { in memory_subscript()
2439 if (view->ndim == 0) { in memory_ass_sub()
2454 if (1 < view->ndim) { in memory_ass_sub()
2468 if (PySlice_Check(key) && view->ndim == 1) { in memory_ass_sub()
2496 if (PyTuple_GET_SIZE(key) < view->ndim) { in memory_ass_sub()
2523 return self->view.ndim == 0 ? 1 : self->view.shape[0]; in memory_length()
2687 Py_ssize_t ndim, const Py_ssize_t *shape, in cmp_rec() argument
2695 assert(ndim >= 1); in cmp_rec()
2700 if (ndim == 1) { in cmp_rec()
2710 equal = cmp_rec(xp, xq, ndim-1, shape+1, in cmp_rec()
2786 if (vv->ndim == 0) { in memory_richcompare()
2790 else if (vv->ndim == 1) { in memory_richcompare()
2797 equal = cmp_rec(vv->buf, ww->buf, vv->ndim, vv->shape, in memory_richcompare()
2945 return _IntTupleFromSsizet(self->view.ndim, self->view.shape); in memory_shape_get()
2952 return _IntTupleFromSsizet(self->view.ndim, self->view.strides); in memory_strides_get()
2959 return _IntTupleFromSsizet(self->view.ndim, self->view.suboffsets); in memory_suboffsets_get()
2973 return PyLong_FromLong(self->view.ndim); in memory_ndim_get()