Internals
The tensor algebra of the rules: multiplying a tensor by a vector or a tensor along some of its axes, and summing those axes out. The rules of DiscreteTransition are built from these two; they are not exported.
DiscreteTransitionMessagePassingRules.multiply_dimensions! — Function
multiply_dimensions!(tensor, dims::NTuple{N, Int}, values) -> tensorMultiply tensor, elementwise and in place, by values along the axes dims: the k-th axis of values runs along the axis dims[k] of tensor, and dims must be increasing, since values is reshaped, not permuted. When the element types differ, both are promoted first and a new tensor is returned; otherwise tensor itself.
Examples
julia> DiscreteTransitionMessagePassingRules.multiply_dimensions!([1.0 2.0; 3.0 4.0], (2,), [10.0, 100.0])
2×2 Matrix{Float64}:
10.0 200.0
30.0 400.0See also sum_out_dimensions.
DiscreteTransitionMessagePassingRules.sum_out_dimensions — Function
sum_out_dimensions(tensor, dims::NTuple{N, Int}, values) -> ArrayMultiply tensor by values along the axes dims, as multiply_dimensions! does (and so in place, when the element types agree), and sum those axes out, keeping them as singletons: the inner product of tensor and values over dims.
Examples
julia> DiscreteTransitionMessagePassingRules.sum_out_dimensions([1.0 2.0; 3.0 4.0], (2,), [0.5, 0.5])
2×1 Matrix{Float64}:
1.5
3.5