sgn: Sign of a permutation

Description Usage Arguments Details Author(s) See Also Examples

View source: R/permfuns.R

Description

The sign of a permutation is +/-1 depending on whether it is even or odd

Usage

1
2
3
sgn(x)
is.even(x)
is.odd(x)

Arguments

x

permutation object

Details

Coerces to cycle form

Author(s)

Robin K. S. Hankin

See Also

shape

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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)]

permutations documentation built on Nov. 13, 2020, 1:14 a.m.