Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
fsxbhyy committed Oct 19, 2023
1 parent feb9c3b commit 9f6419d
Showing 1 changed file with 14 additions and 41 deletions.
55 changes: 14 additions & 41 deletions example/taylor_expansion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,25 @@ G6 = (g1 + g2) * (0.5 * g1 + g3) * g1 # (0.5 * g1 + g3)
using FeynmanDiagram.Taylor:
TaylorSeries, getcoeff, set_variables

set_variables("x y", order=4)
set_variables("x y", order=6)
@time T5 = taylorexpansion!(G6)
print("$(count_operation(T5.coeffs))\n")
for (order, coeff) in (T5.coeffs)
#gs = Compilers.to_julia_str([coeff,], name="eval_graph!")
#println("$(order) ", gs, "\n")
print("$(order) $(eval!(coeff)) $(count_operation(coeff))\n")
end

@time T5_compare = build_derivative_backAD!(G6)
print("$(count_operation(T5_compare.coeffs))\n")
for (order, coeff) in (T5_compare.coeffs)
#gs = Compilers.to_julia_str([coeff,], name="eval_graph!")
#println("$(order) ", gs, "\n")
print("$(order) $(eval!(coeff)) $(eval!(T5.coeffs[order])) $(count_operation(coeff))\n")
end

# derive = build_all_leaf_derivative(G6, 3)
# T6 = TaylorSeries(typeof(G6), typeof(G6), "", derive, var)
# for (order_vec, graph) in derive
# print("$(order_vec), $(eval!(graph)) \n")
order = [0, 3]
@time print(T5.coeffs[order])
# print("$(count_operation(T5.coeffs))\n")
# for (order, coeff) in (T5.coeffs)
# #gs = Compilers.to_julia_str([coeff,], name="eval_graph!")
# #println("$(order) ", gs, "\n")
# print("$(order) $(eval!(coeff)) $(count_operation(coeff))\n")
# end

# derive = build_all_leaf_derivative(G5, 3)
# #var = Set(leaf for leaf in Leaves(G5))
# var = Dict(leaf.id => leaf for leaf in Leaves(G5))
# T5 = TaylorSeries(typeof(G5), typeof(G5), "", derive, var)
# for (order_vec, graph) in derive
# print("$(order_vec), $(eval!(graph)) \n")
# @time T5_compare = build_derivative_backAD!(G6)
# print("$(count_operation(T5_compare.coeffs))\n")
# for (order, coeff) in (T5_compare.coeffs)
# #gs = Compilers.to_julia_str([coeff,], name="eval_graph!")
# #println("$(order) ", gs, "\n")
# print("$(order) $(eval!(coeff)) $(eval!(T5.coeffs[order])) $(count_operation(coeff))\n")
# end

# T = T5 * T6
# for (order_vec, graph) in T.expansion
# print("T5*T6 $(order_vec), $(eval!(graph)) \n")
# end

# G = G5 * G6
# derive = build_all_leaf_derivative(G, 5)
# #var = Set(leaf for leaf in Leaves(G))
# var = Dict(leaf.id => leaf for leaf in Leaves(G))
# T_compare = TaylorSeries(typeof(G), typeof(G), "", derive, var)

# for (order_vec, graph) in T_compare.expansion
# value = eval!(graph)
# @assert value == eval!(T.expansion[order_vec])
# print("compare T5*T6 $(order_vec), $(value) \n")
# end


0 comments on commit 9f6419d

Please sign in to comment.