Skip to content

Commit 980745a

Browse files
committed
comment on rng copy
1 parent 5c5427f commit 980745a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/sfdp.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ 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
111+
# if two points are at the exact same location use random force in any direction
112+
# copy rng from alg struct to keep initial random state intact for future invocations
113+
# otherwise algo(g)==algo(g) might be broken
113114
rng = copy(algo.rng)
114115
force += randn(rng, Ftype)
115116
end

src/spring.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ 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+
# copy rng from alg struct to keep initial random state intact for future invocations
118+
# otherwise algo(g)==algo(g) might be broken
117119
rng = copy(algo.rng)
118120
force_vec += randn(rng, Ftype)
119121
end

0 commit comments

Comments
 (0)