Base.Matrix
— MethodMatrix(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
— TypeDiscreteFunction
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
— MethodDiscreteFunction(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
— Methodsqrt(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
— MethodIdentityFunction(n)
creates the identity DiscreteFunction
on the set {1,2,...,n}
.
DiscreteFunctions.RandomFunction
— MethodRandomFunction(n)
creates a random DiscreteFunction
on {1,2,...,n}
.
DiscreteFunctions.all_functions
— Methodall_functions(n)
returns a generator that produces all DiscreteFunctions
on {1,2,...,n}
DiscreteFunctions.all_sqrts
— Methodall_sqrts(f::DiscreteFunction)
returns an array consisting of all g
such that g*g==f
.
DiscreteFunctions.all_squares
— Methodall_squares(n)
returns a list of all function on [n]
that are perfect compositional squares.
DiscreteFunctions.has_inv
— Methodhas_inv(f::DiscreteFunction)
tests if f
is invertible.
DiscreteFunctions.has_sqrt
— Methodhas_sqrt(f::DiscreteFunction)
checks if there is a function g
such that g*g==f
. Returns true
if so and false
otherwise.
DiscreteFunctions.image
— Methodimage("f::DiscreteFunction")
returns a Set
containing all the output values of f
.
DiscreteFunctions.is_permutation
— Methodis_permutation(f::DiscreteFunction)
returns true
if f
is a bijection on its domain.
DiscreteFunctions.quick_sqrt_test
— Methodquick_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
— Methodrandom_square(n)
returns a DiscreteFunction
on n
elements that has a compositional square root.
DiscreteFunctions.reduced_eigvals
— Methodreduced_eigvals(f::DiscreteFunction)
returns the nonzero eigenvalues of f
's matrix.
DiscreteFunctions.sources
— Methodsources(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
— Methodeigvals(f::DiscreteFunction)
returns the eigenvalues of Matrix(f)
.
Permutations.cycles
— Methodcycles(f::DiscreteFunction)
returns a list of the cycles in f
.
Permutations.fixed_points
— Methodfixed_points(f::DiscreteFunction)
returns a list of fixed points of the function, i.e., those values x
such that f(x)==x
.