NUMPY_API * SwapAxes */
| 635 | * SwapAxes |
| 636 | */ |
| 637 | NPY_NO_EXPORT PyObject * |
| 638 | PyArray_SwapAxes(PyArrayObject *ap, int a1, int a2) |
| 639 | { |
| 640 | PyArray_Dims new_axes; |
| 641 | npy_intp dims[NPY_MAXDIMS]; |
| 642 | int n = PyArray_NDIM(ap); |
| 643 | int i; |
| 644 | |
| 645 | if (check_and_adjust_axis_msg(&a1, n, npy_ma_str_axis1) < 0) { |
| 646 | return NULL; |
| 647 | } |
| 648 | if (check_and_adjust_axis_msg(&a2, n, npy_ma_str_axis2) < 0) { |
| 649 | return NULL; |
| 650 | } |
| 651 | |
| 652 | for (i = 0; i < n; ++i) { |
| 653 | dims[i] = i; |
| 654 | } |
| 655 | dims[a1] = a2; |
| 656 | dims[a2] = a1; |
| 657 | |
| 658 | new_axes.ptr = dims; |
| 659 | new_axes.len = n; |
| 660 | |
| 661 | return PyArray_Transpose(ap, &new_axes); |
| 662 | } |
| 663 | |
| 664 | |
| 665 | /*NUMPY_API |
no test coverage detected