Scruff.Utils

Scruff.Utils.FactorType
struct Factor{N}

Representation of a factor over N instances.

arguments

dims a tuple of dimensions of the instances
keys ids of the instances
entries a vector of factor values
source
Scruff.Utils.GraphType
struct Graph

A simple graph with nodes (Int), edges (outgoing), and a size property for each node

source
Base.showMethod
function show(f::Factor)

Print the factor in an easy to read format.

source
Scruff.Utils.cartesian_productMethod
cartesian_product(xs::Tuple)
cartesian_product(xs::Array)

Given an array of arrays, returns the cartesian product of those arrays.

Examples

julia> cartesian_product([[1,2],[3,4]])
4-element Array{Array{Int64,1},1}:
 [1, 3]
 [1, 4]
 [2, 3]
 [2, 4]

julia> cartesian_product([[1,2],[3,4],[5,6]])
8-element Array{Array{Int64,1},1}:
 [1, 3, 5]
 [1, 3, 6]
 [1, 4, 5]
 [1, 4, 6]
 [2, 3, 5]
 [2, 3, 6]
 [2, 4, 5]
 [2, 4, 6]
source
Scruff.Utils.normalizeMethod
function normalize(f::Factor)

Return a new factor equal to the given factor except that entries sum to 1

source
Scruff.Utils.normalized_productMethod
normalized_product(xss, n)

Compute the product of the given arrays of length n and normalize the result. Uses log computations to avoid underflow.

source
Scruff.Utils.topsortMethod
topsort(graph::Dict{T, Vector{T}}) :: Vector{T} where T

Performs a topological sort on the given graph. In a cyclic graph, the order of variables in the cycle is arbitrary, but they will be correctly sorted relative to other variables.

source