* Helper for `PyArray_MapIterSwapAxes` (and related), see its documentation. */
| 76 | * Helper for `PyArray_MapIterSwapAxes` (and related), see its documentation. |
| 77 | */ |
| 78 | static void |
| 79 | _get_transpose(int fancy_ndim, int consec, int ndim, int getmap, npy_intp *dims) |
| 80 | { |
| 81 | /* |
| 82 | * For getting the array the tuple for transpose is |
| 83 | * (n1,...,n1+n2-1,0,...,n1-1,n1+n2,...,n3-1) |
| 84 | * n1 is the number of dimensions of the broadcast index array |
| 85 | * n2 is the number of dimensions skipped at the start |
| 86 | * n3 is the number of dimensions of the result |
| 87 | */ |
| 88 | |
| 89 | /* |
| 90 | * For setting the array the tuple for transpose is |
| 91 | * (n2,...,n1+n2-1,0,...,n2-1,n1+n2,...n3-1) |
| 92 | */ |
| 93 | int n1 = fancy_ndim; |
| 94 | int n2 = consec; /* axes to insert at */ |
| 95 | int n3 = ndim; |
| 96 | |
| 97 | /* use n1 as the boundary if getting but n2 if setting */ |
| 98 | int bnd = getmap ? n1 : n2; |
| 99 | int val = bnd; |
| 100 | int i = 0; |
| 101 | while (val < n1 + n2) { |
| 102 | dims[i++] = val++; |
| 103 | } |
| 104 | val = 0; |
| 105 | while (val < bnd) { |
| 106 | dims[i++] = val++; |
| 107 | } |
| 108 | val = n1 + n2; |
| 109 | while (val < n3) { |
| 110 | dims[i++] = val++; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | |
| 115 | /*NUMPY_API |
no outgoing calls
no test coverage detected