perm

package module
v0.0.0-...-d1bd854 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2017 License: MIT Imports: 3 Imported by: 0

README

perm

Package perm.

GoDoc

Documentation

Overview

Package perm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(k int) <-chan Perm

All function returns a channel receiving all permutations of a given length.

func AllEven

func AllEven(k int) <-chan Perm

AllEven function returns a channel receiving all even permutations of a given length.

func AllOdd

func AllOdd(k int) <-chan Perm

AllOdd function returns a channel receiving all odd permutations of a given length.

func CyclicInequivalent

func CyclicInequivalent(k int) <-chan Perm

CyclicInequivalent function returns a channel that receives all of the cyclic-inequivalent permutations of a given length.

func MirrorCyclicInequivalent

func MirrorCyclicInequivalent(k int) <-chan Perm

MirrorCyclicInequivalent function returns a channel that receives all of the mirror- and cyclic-inequivalent permutations of a given length.

Types

type Perm

type Perm []int

A Perm type represents a collection of objects labeled by integers.

func Identity

func Identity(n int) Perm

Identity function returns the identity permutation.

func (Perm) AllLeftShifts

func (p Perm) AllLeftShifts() <-chan Perm

AllLeftShifts method returns a channel that receives all of the cyclic left shifts of a given permutation.

func (Perm) AllRightShifts

func (p Perm) AllRightShifts() <-chan Perm

AllRightShifts method returns a channel that receives all of the cyclic right shifts of a given permutation.

func (Perm) Inversions

func (p Perm) Inversions() int64

Inversions method returns the number of inversions in a given permutation.

func (Perm) Len

func (p Perm) Len() int

Len method returns the integer number of items in the permutation.

func (Perm) Mirror

func (p Perm) Mirror() Perm

Mirror method returns a permutation made by completely inverting a given permutation.

func (Perm) ShiftLeft

func (p Perm) ShiftLeft() Perm

ShiftLeft method returns a permutation made by cyclically-shifting all elements of a given permutation to the left.

func (Perm) ShiftRight

func (p Perm) ShiftRight() Perm

ShiftRight method returns a permutation made by cyclically-shifting all elements of a given permutation to the right.

func (Perm) Shuffle

func (p Perm) Shuffle() Perm

Shuffle method returns a permutation made by randomly shuffling a given permutation.

func (Perm) Sign

func (p Perm) Sign() int

Sign method returns 1 if a given permutation has an even number of inversions, -1 otherwise.

func (Perm) Sort

func (p Perm) Sort() Perm

Sort method.

func (Perm) String

func (p Perm) String() string

String method returns the string representation of a Perm as a sequence of integers separated by dashes.

func (Perm) Swap

func (p Perm) Swap(i, j int)

Swap method swaps the ith and jth entry in the permutation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL