Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
houpc committed Oct 24, 2023
1 parent 651b735 commit dd6e1a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/computational_graph/feynmangraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ function linear_combination(g1::FeynmanGraph{F,W}, g2::FeynmanGraph{F,W}, c1::C=
end

"""
function linear_combination(graphs::Vector{FeynmanGraph{F,W}}, constants::Vector{C}) where {F,W,C}
function linear_combination(graphs::Vector{FeynmanGraph{F,W}}, constants::Vector{C}=ones(length(graphs))) where {F,W,C<:Number}
Given a vector 𝐠 of graphs each with the same type and external/internal vertices and
an equally-sized vector 𝐜 of constants, returns a new graph representing the linear combination (𝐜 ⋅ 𝐠).
Expand All @@ -339,7 +339,7 @@ end
# Arguments:
- `graphs` vector of input FeymanGraphs
- `constants` vector of scalar multiples (defaults to ones(C, length(graphs))).
- `constants` vector of scalar multiples (defaults to ones(length(graphs))).
# Returns:
- A new `FeynmanGraph{F,W}` object representing the linear combination of the unique input `graphs` weighted by the constants,
Expand All @@ -348,7 +348,7 @@ where duplicate graphs in the input `graphs` are combined by summing their assoc
# Example:
Given graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.
"""
function linear_combination(graphs::Vector{FeynmanGraph{F,W}}, constants::Vector{C}=ones(C, length(graphs))) where {F,W,C}
function linear_combination(graphs::Vector{FeynmanGraph{F,W}}, constants::Vector{C}=ones(length(graphs))) where {F,W,C<:Number}
@assert alleq(diagram_type.(graphs)) "Graphs are not all of the same graph type."
@assert alleq(orders.(graphs)) "Graphs do not all have the same order."
@assert alleq(Set.(external_operators.(graphs))) "Graphs do not share the same set of external vertices."
Expand Down
10 changes: 5 additions & 5 deletions src/computational_graph/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function linear_combination(g1::Graph{F,W}, g2::Graph{F,W}, c1::C=1, c2::C=1) wh
end

"""
function linear_combination(graphs::Vector{Graph{F,W}}, constants::Vector{C}) where {F,W,C}
function linear_combination(graphs::Vector{Graph{F,W}}, constants::Vector{C}=ones(length(graphs))) where {F,W,C<:Number}
Given a vector 𝐠 of graphs and an equally-sized vector 𝐜 of constants, returns a new
graph representing the linear combination (𝐜 ⋅ 𝐠).
Expand All @@ -179,7 +179,7 @@ end
# Arguments:
- `graphs` vector of computational graphs
- `constants` vector of scalar multiples (defaults to ones(C, length(graphs))).
- `constants` vector of scalar multiples (defaults to ones(length(graphs))).
# Returns:
- A new `Graph{F,W}` object representing the linear combination of the unique input `graphs` weighted by the constants,
Expand All @@ -188,7 +188,7 @@ where duplicate graphs in the input `graphs` are combined by summing their assoc
# Example:
Given graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1+c3)*g1 + c2*g2`.
"""
function linear_combination(graphs::Vector{Graph{F,W}}, constants::Vector{C}=ones(C, length(graphs))) where {F,W,C}
function linear_combination(graphs::Vector{Graph{F,W}}, constants::Vector{C}=ones(length(graphs))) where {F,W,C<:Number}
@assert alleq(orders.(graphs)) "Graphs do not all have the same order."
subgraphs, subgraph_factors = graphs, constants
# parameters = union(getproperty.(graphs, :parameters))
Expand Down Expand Up @@ -295,7 +295,7 @@ function multi_product(g1::Graph{F,W}, g2::Graph{F,W}, c1::C=1, c2::C=1) where {
end

"""
multi_product(graphs::Vector{Graph{F,W}}, constants::Vector{C}=ones(C, length(graphs.subgraphs))) where {F,W,C}
function multi_product(graphs::Vector{Graph{F,W}}, constants::Vector{C}=ones(length(graphs))) where {F,W,C<:Number}
Construct a product graph from multiple input graphs, where each graph can be weighted by a constant.
For graphs that are repeated more than once, it adds a power operator to the subgraph to represent the repetition.
Expand All @@ -311,7 +311,7 @@ Returns:
# Example:
Given graphs `g1`, `g2`, `g1` and constants `c1`, `c2`, `c3`, the function computes `(c1*c3)*(g1)^2 * c2*g2`.
"""
function multi_product(graphs::Vector{Graph{F,W}}, constants::Vector{C}=ones(C, length(graphs))) where {F,W,C}
function multi_product(graphs::Vector{Graph{F,W}}, constants::Vector{C}=ones(length(graphs))) where {F,W,C<:Number}
subgraphs, subgraph_factors = graphs, constants
# Convert multiplicative links to in-place form
for (i, sub_g) in enumerate(graphs)
Expand Down

0 comments on commit dd6e1a8

Please sign in to comment.