This module defines the
DiscreteFunction type which represents a
function defined on the set
n must be positive).
DiscreteFunction is created by providing a list of values either by
passing an array of
Int values or as a list of
julia> using DiscreteFunctions julia> f = DiscreteFunction([2,3,1,4]); julia> g = DiscreteFunction(2,3,1,4); julia> f==g true
Function evaluation may use either
f[x]. It is possible
to change the value of
x using the latter.
p is a
DiscreteFunction(p) creates a
DiscreteFunction based on
julia> using Permutations julia> p = RandomPermutation(6) (1,6)(2,5,3,4) julia> DiscreteFunction(p) DiscreteFunction on  1 2 3 4 5 6 6 5 4 2 3 1
f is a
DiscreteFunction that is invertible, it can be
converted to a
A be a square matrix with exactly one nonzero element in each row.
DiscreteFunction(A) creates a
f such that
f[i]==j exactly when
A[i,j] != 0.
This is the inverse of the
Matrix function (see below). That is,
IdentityFunction(n)creates the identity function on the set
RandomFunction(n)creates a random function on the set
The composition of functions
g is computed with
Exponentiation signals repeated composition,
f^4 is the same as
We can test if
f is invertible using
inv(f) returns the
inverse function (or throws an error if no inverse exists). This can also
be computed as
f^-1 and, in general, if
f is invertible it can be raised
to negative exponents. The function
is_permutation is a synonym for
length(f)returns the number of elements in
fixed_points(f)returns a list of the fixed points in the function.
cycles(f)returns a list of the cycles in the function.
Setcontaining the output values of
sources(f)returns a list of all inputs to
fthat are not outputs of
Matrix(f)returns a square, zero-one matrix with a one in position
eigvals(f)returns the eigenvalues of
all_functions(n)returns an iterator for all functions defined on
1:n. Note that there are
n^nsuch functions so this grows quickly.
f*f==gor throws an error if no such function exists. Found using integer linear programming.
all_sqrts(g)returns a list of all square roots of
g. Very slow.
This is some additional code that is not automatically loaded by
include on the appropriate file in the
This file defines
tree2function(G::SimpleGraph). It assumes that
G is a
tree with vertex set
1:n and returns a
DiscreteFunction defined by
pointing all edges to the root,
This file defines
draw(f) to give a picture of
about 2 months ago