Header menu logo FSharp.Stats

Permutation Module

The Permutation module defines a type and helper functions for representing and constructing permutations from integer arrays.

Functions and values

Function or value Description

Permutation.identity k

Full Usage: Permutation.identity k

Parameters:
    k : int

Returns: int
k : int
Returns: int

Permutation.inverse size p

Full Usage: Permutation.inverse size p

Parameters:
    size : int
    p : int -> int

Returns: Permutation
size : int
p : int -> int
Returns: Permutation

Permutation.ofArray arr

Full Usage: Permutation.ofArray arr

Parameters:
    arr : int[] - An array of length n that should represent a valid permutation of 0..n-1.

Returns: Permutation A Permutation function representing the same reordering as arr.

Makes a copy of arr, then calls ofFreshArray. Useful for preserving the original array.

arr : int[]

An array of length n that should represent a valid permutation of 0..n-1.

Returns: Permutation

A Permutation function representing the same reordering as arr.

Permutation.ofFreshArray arr

Full Usage: Permutation.ofFreshArray arr

Parameters:
    arr : int[] - The array containing the permutation. Each element arr[i] must be a unique integer in [0..n-1].

Returns: Permutation A permutation function Permutation where P(i) = arr[i].

Validates that the given integer array arr is a valid permutation of length n (i.e., it contains every integer from 0 to n-1 exactly once), then returns a function P(i) = arr[i].
Throws an exception if arr is invalid.

arr : int[]

The array containing the permutation. Each element arr[i] must be a unique integer in [0..n-1].

Returns: Permutation

A permutation function Permutation where P(i) = arr[i].

Permutation.ofPairs mappings

Full Usage: Permutation.ofPairs mappings

Parameters:
    mappings : (int * int) seq

Returns: int -> int
mappings : (int * int) seq
Returns: int -> int

Permutation.reversal size

Full Usage: Permutation.reversal size

Parameters:
    size : int

Returns: int -> int
size : int
Returns: int -> int

Permutation.rotation size distance

Full Usage: Permutation.rotation size distance

Parameters:
    size : int
    distance : int

Returns: int -> int
size : int
distance : int
Returns: int -> int

Permutation.sign n P

Full Usage: Permutation.sign n P

Parameters:
Returns: float

Computes the sign (+1.0 or -1.0) of a permutation P, given its domain size n. sign(P) = (-1)^(n - numCycles).

n : int
P : Permutation
Returns: float

Permutation.swap n m k

Full Usage: Permutation.swap n m k

Parameters:
    n : int
    m : int
    k : int

Returns: int
n : int
m : int
k : int
Returns: int

Type something to start searching.