Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend ruleSPMultiplicationAGPN #108

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/engines/julia/update_rules/multiplication.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ruleSPMultiplicationIn1PNP(msg_out::Message{PointMass, Multivariate}, msg_in1::N
# Namely, Ax = y, where A ∈ R^{nx1}, x ∈ R^1, and y ∈ R^n. In this case, the matrix A
# can be represented by a n-dimensional vector, and x by a scalar. Before computation,
# quantities are converted to their proper dimensions (see situational sketch below).
#
#
# | a ~ Multivariate -> R^{nx1}
# v out ~ Multivariate -> R^n
# -->[x]-->
Expand All @@ -117,4 +117,6 @@ function ruleSPMultiplicationIn1GNP(msg_out::Message{F, Multivariate},
(dims(msg_in1_mult.dist) == 1) || error("Implicit conversion to Univariate failed for $(msg_in1_mult.dist)")

return Message(Univariate, GaussianWeightedMeanPrecision, xi=msg_in1_mult.dist.params[:xi][1], w=msg_in1_mult.dist.params[:w][1,1])
end
end

ruleSPMultiplicationAGPN(msg_out::Message{F, Multivariate}, msg_in1::Message{PointMass, Multivariate}, msg_a::Nothing) where F<:Gaussian = ruleSPMultiplicationIn1GNP(msg_out, nothing, msg_in1)
1 change: 1 addition & 0 deletions test/factor_nodes/test_multiplication.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ end
@test isApplicable(SPMultiplicationAGPN, [Message{Gaussian}, Message{PointMass}, Nothing])

@test ruleSPMultiplicationAGPN(Message(Univariate, GaussianWeightedMeanPrecision, xi=1.0, w=3.0), Message(Univariate, PointMass, m=2.0), nothing) == Message(Univariate, GaussianWeightedMeanPrecision, xi=2.0, w=12.0)
@test ruleSPMultiplicationAGPN(Message(Multivariate, GaussianWeightedMeanPrecision, xi=[1.0], w=[3.0]), Message(Multivariate, PointMass, m=[2.0]), nothing) == Message(Univariate, GaussianWeightedMeanPrecision, xi=2.0, w=12.0 + tiny)
end

@testset "SPMultiplicationAPPN" begin
Expand Down