Skip to content

Commit

Permalink
Remove add_sum! function (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfasi committed Feb 2, 2024
1 parent 5d6d644 commit d31b593
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
2 changes: 0 additions & 2 deletions docs/src/graph.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Graphs and their manipulation


Expand All @@ -18,7 +17,6 @@ In general a graph is composed of linear combinations ``C = \alpha A + \beta B``
add_lincomb!
add_mult!
add_ldiv!
add_sum!
```

The graph can have multiple outputs and the behavior controlled.
Expand Down
36 changes: 0 additions & 36 deletions src/compgraph_struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export get_topo_order
export add_mult!
export add_lincomb!
export add_ldiv!
export add_sum!
export add_output!
export del_output!
export clear_outputs!
Expand Down Expand Up @@ -111,7 +110,6 @@ end
The operation `α1*p1+α2*p2` is added to the graph.
The result is stored in node `node`.
See also [`add_sum!`](@ref).
"""
function add_lincomb!(graph, node, α1, p1, α2, p2)
check_node_name_legality(graph, node)
Expand Down Expand Up @@ -243,40 +241,6 @@ function rename_node!(graph, src, dest, cref = Vector())
return nothing
end

"""
cref=add_sum!(graph,node,c,nodelist,base_name=node)
Adds a linear combination of more than two nodes, given in `nodelist::Vector`,
with coefficients given in `c`. The `base_name` is temporary variables for the
summing. The sum is stored in `node`.
Returns `cref` list with references.
"""
function add_sum!(graph, node, c, nodelist, base_name = node)
if size(nodelist, 1) == 1
error("Summing one element not allowed.")
elseif (size(nodelist, 1) == 2)
# Direct call to lincomb if we sum two nodes
add_lincomb!(graph, node, c[1], nodelist[1], c[2], nodelist[2])
return [(node, 1), (node, 2)]
end

cref = Vector{Tuple{Symbol,Int}}()
key = Symbol("$(base_name)2")
add_lincomb!(graph, key, c[1], nodelist[1], c[2], nodelist[2])
push!(cref, (key, 1))
push!(cref, (key, 2))
for k = 3:size(nodelist, 1)
prev_key = key
key = Symbol("$(base_name)$k")
add_lincomb!(graph, key, 1, prev_key, c[k], nodelist[k])
push!(cref, (key, 2))
end
# Rename the final sum as the target node
rename_node!(graph, key, node, cref)
return cref
end

"""
del_node!(graph,node)
Expand Down

0 comments on commit d31b593

Please sign in to comment.