Skip to content

Commit 83d0d6c

Browse files
committed
Merge remote-tracking branch 'mine/kf/copy' into kf/pantelidesvarwhitelist
2 parents e639a9f + a9dc0e6 commit 83d0d6c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/bipartite_graph.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ end
5959
Base.size(m::Matching) = Base.size(m.match)
6060
Base.getindex(m::Matching, i::Integer) = m.match[i]
6161
Base.iterate(m::Matching, state...) = iterate(m.match, state...)
62-
function Base.copy(m::Matching)
63-
Matching(copy(m.match), m.inv_match === nothing ? nothing : copy(m.inv_match))
62+
function Base.copy(m::Matching{U}) where {U}
63+
Matching{U}(copy(m.match), m.inv_match === nothing ? nothing : copy(m.inv_match))
6464
end
6565
function Base.setindex!(m::Matching{U}, v::Union{Integer, U}, i::Integer) where {U}
6666
if m.inv_match !== nothing

src/systems/systemstructure.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ struct DiffGraph <: Graphs.AbstractGraph{Int}
3737
primal_to_diff::Vector{Union{Int, Nothing}}
3838
diff_to_primal::Union{Nothing, Vector{Union{Int, Nothing}}}
3939
end
40+
4041
DiffGraph(primal_to_diff::Vector{Union{Int, Nothing}}) = DiffGraph(primal_to_diff, nothing)
4142
function DiffGraph(n::Integer, with_badj::Bool = false)
4243
DiffGraph(Union{Int, Nothing}[nothing for _ in 1:n],
4344
with_badj ? Union{Int, Nothing}[nothing for _ in 1:n] : nothing)
4445
end
4546

47+
function Base.copy(dg::DiffGraph)
48+
DiffGraph(copy(dg.primal_to_diff),
49+
dg.diff_to_primal === nothing ? nothing : copy(dg.diff_to_primal))
50+
end
51+
4652
@noinline function require_complete(dg::DiffGraph)
4753
dg.diff_to_primal === nothing &&
4854
error("Not complete. Run `complete` first.")
@@ -145,6 +151,13 @@ Base.@kwdef mutable struct SystemStructure
145151
solvable_graph::Union{BipartiteGraph{Int, Nothing}, Nothing}
146152
only_discrete::Bool
147153
end
154+
155+
function Base.copy(structure::SystemStructure)
156+
SystemStructure(copy(structure.var_to_diff), copy(structure.eq_to_diff),
157+
copy(structure.graph), copy(structure.solvable_graph),
158+
structure.only_discrete)
159+
end
160+
148161
is_only_discrete(s::SystemStructure) = s.only_discrete
149162
isdervar(s::SystemStructure, i) = invview(s.var_to_diff)[i] !== nothing
150163
function isalgvar(s::SystemStructure, i)

0 commit comments

Comments
 (0)