| 3968 | */ |
| 3969 | |
| 3970 | NPY_NO_EXPORT void |
| 3971 | _array_fill_strides(npy_intp *strides, npy_intp const *dims, int nd, size_t itemsize, |
| 3972 | int inflag, int *objflags) |
| 3973 | { |
| 3974 | int i; |
| 3975 | npy_bool not_cf_contig = 0; |
| 3976 | npy_bool nod = 0; /* A dim != 1 was found */ |
| 3977 | |
| 3978 | /* Check if new array is both F- and C-contiguous */ |
| 3979 | for (i = 0; i < nd; i++) { |
| 3980 | if (dims[i] != 1) { |
| 3981 | if (nod) { |
| 3982 | not_cf_contig = 1; |
| 3983 | break; |
| 3984 | } |
| 3985 | nod = 1; |
| 3986 | } |
| 3987 | } |
| 3988 | |
| 3989 | /* Only make Fortran strides if not contiguous as well */ |
| 3990 | if ((inflag & (NPY_ARRAY_F_CONTIGUOUS|NPY_ARRAY_C_CONTIGUOUS)) == |
| 3991 | NPY_ARRAY_F_CONTIGUOUS) { |
| 3992 | for (i = 0; i < nd; i++) { |
| 3993 | strides[i] = itemsize; |
| 3994 | if (dims[i]) { |
| 3995 | itemsize *= dims[i]; |
| 3996 | } |
| 3997 | else { |
| 3998 | not_cf_contig = 0; |
| 3999 | } |
| 4000 | #if NPY_RELAXED_STRIDES_DEBUG |
| 4001 | /* For testing purpose only */ |
| 4002 | if (dims[i] == 1) { |
| 4003 | strides[i] = NPY_MAX_INTP; |
| 4004 | } |
| 4005 | #endif /* NPY_RELAXED_STRIDES_DEBUG */ |
| 4006 | } |
| 4007 | if (not_cf_contig) { |
| 4008 | *objflags = ((*objflags)|NPY_ARRAY_F_CONTIGUOUS) & |
| 4009 | ~NPY_ARRAY_C_CONTIGUOUS; |
| 4010 | } |
| 4011 | else { |
| 4012 | *objflags |= (NPY_ARRAY_F_CONTIGUOUS|NPY_ARRAY_C_CONTIGUOUS); |
| 4013 | } |
| 4014 | } |
| 4015 | else { |
| 4016 | for (i = nd - 1; i >= 0; i--) { |
| 4017 | strides[i] = itemsize; |
| 4018 | if (dims[i]) { |
| 4019 | itemsize *= dims[i]; |
| 4020 | } |
| 4021 | else { |
| 4022 | not_cf_contig = 0; |
| 4023 | } |
| 4024 | #if NPY_RELAXED_STRIDES_DEBUG |
| 4025 | /* For testing purpose only */ |
| 4026 | if (dims[i] == 1) { |
| 4027 | strides[i] = NPY_MAX_INTP; |
no outgoing calls
no test coverage detected