Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

inverse

Inverse of a permutation


Description

Calculates the inverse of a permutation in either word or cycle form

Usage

inverse(x)
## S3 method for class 'word'
inverse(x)
## S3 method for class 'cycle'
inverse(x)
inverse_word_single(W)
inverse_cyclist_single(cyc)

Arguments

x

Object of class permutation to be inverted

W

In function inverse_word_single(), a vector corresponding to a permutation in word form (that is, one row of a word object)

cyc

In function inverse_cyclist_single(), a cyclist to be inverted

Details

The package provides methods to invert objects of class word (the R idiom is W[W] <- seq_along(W)) and also objects of class cycle (the idiom is lapply(cyc,function(o){c(o[1],rev(o[-1]))})).

The user should use inverse() directly, which dispatches to either inverse.word() or inverse.cycle() as appropriate.

Sometimes, using idiom such as x^-1 or id/x gives neater code, although these may require coercion between word form and cycle form.

Value

Function inverse() returns an object of the same class as its argument.

Author(s)

Robin K. S. Hankin

See Also

Examples

x <- rperm(10,6)
inverse(x)

all(is.id(x*inverse(x)))  # should be TRUE

inverse(as.cycle(matrix(1:8,9,8)))

permutations

The Symmetric Group: Permutations of a Finite Set

v1.0-9
GPL-2
Authors
Robin K. S. Hankin [aut, cre] (<https://orcid.org/0000-0001-5982-0415>), Paul Egeler [ctb] (<https://orcid.org/0000-0001-6948-9498>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.