From 502572ba51fde2a2a83da2ae983d3f29f8b4e947 Mon Sep 17 00:00:00 2001 From: dcerkoney Date: Tue, 24 Oct 2023 04:15:12 -0400 Subject: [PATCH] WIP: Fix factor bug & update tests --- src/computational_graph/feynmangraph.jl | 1 - src/computational_graph/graph.jl | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/computational_graph/feynmangraph.jl b/src/computational_graph/feynmangraph.jl index 74636f2d..326f5b1d 100644 --- a/src/computational_graph/feynmangraph.jl +++ b/src/computational_graph/feynmangraph.jl @@ -360,7 +360,6 @@ function linear_combination(g1::FeynmanGraph{F,W}, g2::FeynmanGraph{F,W}, c1=F(1 # subgraph_factors[2] *= g2.subgraph_factors[1] * g2.factor subgraphs[2] = g2.subgraphs[1] end - # g = FeynmanGraph([g1, g2], properties; subgraph_factors=[F(c1), F(c2)], operator=Sum(), ftype=F, wtype=W) if subgraphs[1] == subgraphs[2] g = FeynmanGraph([subgraphs[1]], properties; subgraph_factors=[sum(subgraph_factors)], operator=Sum(), orders=orders(g1), ftype=F, wtype=W) diff --git a/src/computational_graph/graph.jl b/src/computational_graph/graph.jl index 8703b6e3..76f950a6 100644 --- a/src/computational_graph/graph.jl +++ b/src/computational_graph/graph.jl @@ -124,6 +124,7 @@ function Base.:*(g1::Graph{F,W}, c2) where {F,W} # Convert trivial unary link to in-place form if unary_istrivial(g1) && onechild(g1) g.subgraph_factors[1] *= g1.subgraph_factors[1] + # g.subgraph_factors[1] *= g1.subgraph_factors[1] * g1.factor g.subgraphs = g1.subgraphs end return g @@ -143,6 +144,7 @@ function Base.:*(c1, g2::Graph{F,W}) where {F,W} # Convert trivial unary link to in-place form if unary_istrivial(g2) && onechild(g2) g.subgraph_factors[1] *= g2.subgraph_factors[1] + # g.subgraph_factors[1] *= g2.subgraph_factors[1] * g2.factor g.subgraphs = g2.subgraphs end return g @@ -169,10 +171,12 @@ function linear_combination(g1::Graph{F,W}, g2::Graph{F,W}, c1=F(1), c2=F(1)) wh # Convert trivial unary links to in-place form if unary_istrivial(g1) && onechild(g1) subgraph_factors[1] *= g1.subgraph_factors[1] + # subgraph_factors[1] *= g1.subgraph_factors[1] * g1.factor subgraphs[1] = g1.subgraphs[1] end if unary_istrivial(g2) && onechild(g2) subgraph_factors[2] *= g2.subgraph_factors[1] + # subgraph_factors[2] *= g2.subgraph_factors[1] * g2.factor subgraphs[2] = g2.subgraphs[1] end @@ -211,6 +215,7 @@ function linear_combination(graphs::Vector{Graph{F,W}}, constants::AbstractVecto for (i, sub_g) in enumerate(graphs) if unary_istrivial(sub_g) && onechild(sub_g) subgraph_factors[i] *= sub_g.subgraph_factors[1] + # subgraph_factors[i] *= sub_g.subgraph_factors[1] * sub_g.factor subgraphs[i] = sub_g.subgraphs[1] end end @@ -283,10 +288,12 @@ function multi_product(g1::Graph{F,W}, g2::Graph{F,W}, c1=F(1), c2=F(1)) where { # Convert trivial unary links to in-place form if unary_istrivial(g1) && onechild(g1) subgraph_factors[1] *= g1.subgraph_factors[1] + # subgraph_factors[1] *= g1.subgraph_factors[1] * g1.factor subgraphs[1] = g1.subgraphs[1] end if unary_istrivial(g2) && onechild(g2) subgraph_factors[2] *= g2.subgraph_factors[1] + # subgraph_factors[2] *= g2.subgraph_factors[1] * g2.factor subgraphs[2] = g2.subgraphs[1] end @@ -324,6 +331,7 @@ function multi_product(graphs::Vector{Graph{F,W}}, constants::AbstractVector=one for (i, sub_g) in enumerate(graphs) if unary_istrivial(sub_g) && onechild(sub_g) subgraph_factors[i] *= sub_g.subgraph_factors[1] + # subgraph_factors[i] *= sub_g.subgraph_factors[1] * sub_g.factor subgraphs[i] = sub_g.subgraphs[1] end end