Skip to content

Commit 2be5b80

Browse files
committed
comment on rng copy
1 parent 5c5427f commit 2be5b80

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/sfdp.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ function Base.iterate(iter::LayoutIterator{<:SFDP}, state)
108108
end
109109
end
110110
if any(isnan, force)
111-
# if two points are at the exact same location
112-
# use random force in any direction
113-
rng = copy(algo.rng)
114-
force += randn(rng, Ftype)
111+
# if two points are at the exact same location use random force in any direction
112+
# copy rng from alg struct to not advance the "initial" rng state
113+
# otherwise algo(g)==algo(g) might be broken
114+
force += randn(copy(algo.rng), Ftype)
115115
end
116116
mask = (!).(pin[i]) # where pin=true mask will multiply with 0
117117
locs[i] = locs[i] .+ (step .* (force ./ norm(force))) .* mask

src/spring.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ function Base.iterate(iter::LayoutIterator{<:Spring}, state)
114114
else
115115
# if two points are at the exact same location
116116
# use random force in any direction
117-
rng = copy(algo.rng)
118-
force_vec += randn(rng, Ftype)
117+
# copy rng from alg struct to not advance the "initial" rng state
118+
# otherwise algo(g)==algo(g) might be broken
119+
force_vec += randn(copy(algo.rng), Ftype)
119120
end
120121

121122
end

0 commit comments

Comments
 (0)