ipermutedims
.. ipermutedims(A, perm)
Like :func:`permutedims`, except the inverse of the given permutation is applied.
Examples
In the Julia programming language, the function ipermutedims(A, perm)
is similar to permutedims
, but it applies the inverse of the given permutation.
julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Array{Int64,2}:
1 2 3
4 5 6
7 8 9
julia> ipermutedims(A, (2, 1))
3×3 Array{Int64,2}:
1 4 7
2 5 8
3 6 9
This example demonstrates applying the inverse permutation (2, 1)
to the matrix A
. The rows and columns are swapped accordingly.
Common mistake example:
julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Array{Int64,2}:
1 2 3
4 5 6
7 8 9
julia> ipermutedims(A, (1, 2, 3))
ERROR: ArgumentError: permutation (1, 2, 3) is not valid for the input array
In this example, the provided permutation (1, 2, 3)
is not valid for the given array A
. It's important to ensure that the permutation is a valid rearrangement of the dimensions of the array before using ipermutedims
.
See Also
User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.