invperm

invperm(v)

Return the inverse permutation of v.

Examples

Inverse Permutation using invperm()

The invperm(v) function in Julia returns the inverse permutation of the input vector v.

julia> v = [3, 1, 4, 2];
julia> invperm(v)
4-element Array{Int64,1}:
 2
 4
 1
 3

This example shows the inverse permutation of the input vector [3, 1, 4, 2].

Common mistake example:

julia> v = [1, 2, 3];
julia> invperm(v)
ERROR: ArgumentError: invalid permutation

In this example, an error occurs because the input vector [1, 2, 3] is not a valid permutation. It must contain all unique integers from 1 to length(v). Ensure that the input vector is a valid permutation before using invperm().

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.

*Required Field
Details

Checking you are not a robot: