`Base.Matrix`

— Method`Matrix(f::DiscreteFunction)`

returns an `n`

-by-`n`

zero-one matrix in which there is a `1`

in position `i,j`

exactly when `f(i)==j`

.

`DiscreteFunctions.DiscreteFunction`

— Type`DiscreteFunction`

is a function from `{1,2,...,n}`

to itself. It can be created by `DiscreteFunction(list)`

where `list`

is a one-dimensional array of positive integers. Alternatively, it can be created using positive integer arguments.

The following are equivalent:

```
DiscreteFunction([1,4,2,3])
DiscreteFunction(1,4,2,3)
```

`DiscreteFunctions.DiscreteFunction`

— Method`DiscreteFunction(A)`

creates a new discrete function based on the square matrix `A`

. It is required that each row of `A`

have exactly one nonzero element. Note that if `A=Matrix(f)`

then `DiscreteFunction(A)==f`

.

`Base.:+`

— MethodIf `f`

and `g`

are of type `DiscreteFunction`

, then `f+g`

is their *disjoint sum*.

`Base.sqrt`

— Method`sqrt(g::DiscreteFunction)`

returns a function `f`

such that `f*f==g`

or throws an error if no such function exists. This method uses integer linear programming.

`DiscreteFunctions.IdentityFunction`

— Method`IdentityFunction(n)`

creates the identity `DiscreteFunction`

on the set `{1,2,...,n}`

.

`DiscreteFunctions.RandomFunction`

— Method`RandomFunction(n)`

creates a random `DiscreteFunction`

on `{1,2,...,n}`

.

`DiscreteFunctions.all_functions`

— Method`all_functions(n)`

returns a generator that produces all `DiscreteFunctions`

on `{1,2,...,n}`

`DiscreteFunctions.all_sqrts`

— Method`all_sqrts(f::DiscreteFunction)`

returns an array consisting of all `g`

such that `g*g==f`

.

`DiscreteFunctions.all_squares`

— Method`all_squares(n)`

returns a list of all function on `[n]`

that are perfect compositional squares.

`DiscreteFunctions.has_inv`

— Method`has_inv(f::DiscreteFunction)`

tests if `f`

is invertible.

`DiscreteFunctions.has_sqrt`

— Method`has_sqrt(f::DiscreteFunction)`

checks if there is a function `g`

such that `g*g==f`

. Returns `true`

if so and `false`

otherwise.

`DiscreteFunctions.image`

— Method`image("f::DiscreteFunction")`

returns a `Set`

containing all the output values of `f`

.

`DiscreteFunctions.is_permutation`

— Method`is_permutation(f::DiscreteFunction)`

returns `true`

if `f`

is a bijection on its domain.

`DiscreteFunctions.quick_sqrt_test`

— Method`quick_sqrt_test(f::DiscreteFunction)`

is a quick check of a necessary condition for `f`

to have a square root. If this returns `false`

then `f`

does *not* have a square root. If it returns `true`

, it might.

`DiscreteFunctions.random_square`

— Method`random_square(n)`

returns a `DiscreteFunction`

on `n`

elements that has a compositional square root.

`DiscreteFunctions.reduced_eigvals`

— Method`reduced_eigvals(f::DiscreteFunction)`

returns the nonzero eigenvalues of `f`

's matrix.

`DiscreteFunctions.sources`

— Method`sources(f::DiscreteFunction)`

returns a list of all inputs to `f`

that are not the output of `f`

. That is, this is a list of the vertices with out-degree 0 in the graph of `f`

.

`LinearAlgebra.eigvals`

— Method`eigvals(f::DiscreteFunction)`

returns the eigenvalues of `Matrix(f)`

.

`Permutations.cycles`

— Method`cycles(f::DiscreteFunction)`

returns a list of the cycles in `f`

.

`Permutations.fixed_points`

— Method`fixed_points(f::DiscreteFunction)`

returns a list of fixed points of the function, i.e., those values `x`

such that `f(x)==x`

.