sgn: Sign of a permutation

View source: R/permfuns.R

sgnR Documentation

Sign of a permutation

Description

\loadmathjax

Returns the sign of a permutation

Usage

sgn(x)
is.even(x)
is.odd(x)

Arguments

x

permutation object

Details

The sign of a permutation is \mjeqn\pm 1+/-1 depending on whether it is even or odd. A permutation is even if it can be written as a product of an even number of transpositions, and odd if it can be written as an odd number of transpositions. The map \mjeqn\operatornamesgn\colon S_n\longrightarrow\left\lbrace +1,-1\right\rbraceomitted is a homomorphism; see examples.

Note

Internally, function sgn() coerces to cycle form.

The sign of the null permutation is NULL.

Author(s)

Robin K. S. Hankin

See Also

shape

Examples


sgn(id)  # always problematic

sgn(rperm(10,5))

x <- rperm(40,6)
y <- rperm(40,6)


stopifnot(all(sgn(x*y) == sgn(x)*sgn(y)))   # sgn() is a homomorphism


z <- as.cycle(rperm(20,9,5))
z[is.even(z)]
z[is.odd(z)]


RobinHankin/permutations documentation built on March 29, 2024, 5:34 p.m.