Skip to content

Commit 66ea504

Browse files
committed
.bw back to matrix
1 parent 4db0185 commit 66ea504

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

src/entities/DFGVariable.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $(TYPEDFIELDS)
1818
"""
1919
mutable struct VariableNodeData{T<:InferenceVariable, P}
2020
val::Vector{P}
21-
bw::Vector{Vector{Float64}}
21+
bw::Matrix{Float64}
2222
BayesNetOutVertIDs::Vector{Symbol}
2323
dimIDs::Vector{Int} # Likely deprecate
2424

@@ -43,7 +43,7 @@ mutable struct VariableNodeData{T<:InferenceVariable, P}
4343
VariableNodeData{T,P}(w...) where {T <:InferenceVariable, P} = new{T,P}(w...)
4444
VariableNodeData{T,P}(;solveKey::Symbol=:default ) where {T <:InferenceVariable, P} = new{T,P}(
4545
Vector{P}(),
46-
Vector{Vector{Float64}}(),
46+
zeros(0,0),
4747
Symbol[],
4848
Int[],
4949
0,
@@ -68,7 +68,7 @@ end
6868
VariableNodeData{T}(;solveKey::Symbol=:default ) where T <: InferenceVariable = VariableNodeData{T, getPointType(T)}(solveKey=solveKey)
6969

7070
VariableNodeData( val::Vector{P},
71-
bw::Vector{Vector{Float64}},
71+
bw::Matrix{<:Real},
7272
BayesNetOutVertIDs::AbstractVector{Symbol},
7373
dimIDs::AbstractVector{Int},
7474
dims::Int,
@@ -95,7 +95,7 @@ VariableNodeData( val::Vector{P},
9595
#
9696

9797
VariableNodeData(val::Vector{P},
98-
bw::Vector{Vector{Float64}},
98+
bw::Matrix{<:Real},
9999
BayesNetOutVertIDs::AbstractVector{Symbol},
100100
dimIDs::AbstractVector{Int},
101101
dims::Int,
@@ -123,7 +123,7 @@ function VariableNodeData(variableType::T; solveKey::Symbol=:default) where T <:
123123
# p0 = getPointIdentity(T)
124124
P0 = Vector{getPointType(T)}()
125125
# P0[1] = p0
126-
BW = Vector{Vector{Float64}}()
126+
BW = zeros(0,0)
127127
# BW[1] = zeros(getDimension(T))
128128
VariableNodeData( P0, BW, Symbol[], Int[],
129129
0, false, :NOTHING, Symbol[],

src/services/Serialization.jl

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ function packVariableNodeData(::G, d::VariableNodeData{T}) where {G <: AbstractD
216216
zeros(1,0)
217217
end
218218
_val = castval[:]
219-
castbw = if 0 < length(d.bw)
220-
@cast castbw[i,j] := d.bw[j][i]
221-
castbw
222-
else
223-
zeros(1,0)
224-
end
225-
_bw = castbw[:]
219+
# castbw = if 0 < length(d.bw)
220+
# @cast castbw[i,j] := d.bw[j][i]
221+
# castbw
222+
# else
223+
# zeros(1,0)
224+
# end
225+
# _bw = castbw[:]
226226
return PackedVariableNodeData(_val, size(castval,1),
227-
_bw, size(castbw,1),
227+
d.bw[:], size(d.bw,1),
228228
d.BayesNetOutVertIDs,
229229
d.dimIDs, d.dims, d.eliminated,
230230
d.BayesNetVertID, d.separator,
@@ -258,14 +258,10 @@ function unpackVariableNodeData(dfg::G, d::PackedVariableNodeData) where G <: Ab
258258

259259
r4 = d.dimbw
260260
c4 = r4 > 0 ? floor(Int,length(d.vecbw)/r4) : 0
261-
M4 = reshape(d.vecbw,r4,c4)
262-
bw = Vector{Vector{Float64}}(undef,size(M4,2))
263-
for j in 1:size(M4,2)
264-
bw[j] = collect(M4[:,j])
265-
end
261+
BW = reshape(d.vecbw,r4,c4)
266262

267263
#
268-
return VariableNodeData{T, getPointType(T)}(vals, bw, d.BayesNetOutVertIDs,
264+
return VariableNodeData{T, getPointType(T)}(vals, BW, d.BayesNetOutVertIDs,
269265
d.dimIDs, d.dims, d.eliminated, d.BayesNetVertID, d.separator,
270266
T(), d.initialized, d.inferdim, d.ismargin, d.dontmargin,
271267
d.solveInProgress, d.solvedCount, d.solveKey,

test/compareTests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ vnd3 = VariableNodeData(TestVariableType2())
1414

1515
@test vnd1 == vnd2
1616
push!(vnd1.val, [1.0;])
17-
# vnd2.val = Vector{Vector{Float64}}(undef,1)
1817
push!(vnd2.val, [1.0;])
1918
@test vnd1 == vnd2
2019
vnd2.val[1] = [0.1;]

test/testBlocks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ function VSDTestBlock!(fg, v1)
741741
retVnd = updateVariableSolverData!(fg, :a, altVnd, false, [:inferdim;])
742742
@test retVnd == altVnd
743743

744-
push!(altVnd.bw, [-1.0;])
744+
altVnd.bw = -ones(1,1)
745745
retVnd = updateVariableSolverData!(fg, :a, altVnd, false, [:bw;])
746746
@test retVnd == altVnd
747747

0 commit comments

Comments
 (0)