-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from numericalEFT/tao_AD
Add Taylor Series
- Loading branch information
Showing
16 changed files
with
1,181 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using FeynmanDiagram | ||
using FeynmanDiagram.Taylor | ||
using FeynmanDiagram.ComputationalGraphs: | ||
eval!, forwardAD, node_derivative, backAD, build_all_leaf_derivative, count_operation | ||
using FeynmanDiagram.Utility: | ||
taylorexpansion!, build_derivative_backAD! | ||
g1 = Graph([]) | ||
g2 = Graph([]) | ||
g3 = Graph([]) #, factor=2.0) | ||
g4 = Graph([]) | ||
g5 = Graph([]) | ||
g6 = Graph([]) | ||
G3 = g1 | ||
G4 = 1.0 * g1 * g1 | ||
G5 = 1.0 * (3.0 * G3 + 0.5 * G4) | ||
#G6 = (0.5 * g1 * g2 + 0.5 * g2 * g3) | ||
#G6 = (g1 + g2) * (0.5 * g1 + g3) * g1 # (0.5 * g1 + g3) | ||
#G6 = g1 * g2 * g3 * g4 * g5 * g6 | ||
G6 = (1.0 * g1 + 2.0 * g2) * (g1 + g3) | ||
#G6 = 1.5 * g1*g1 + 0.5 * g2 * 1.5 * g1 + 0.5*g2*g3 | ||
using FeynmanDiagram.Taylor: | ||
TaylorSeries, getcoeff, set_variables | ||
|
||
|
||
# set_variables("x y", order=3) | ||
# @time T5 = taylorexpansion!(G5) | ||
# print(T5) | ||
set_variables("x y z a", order=7) | ||
@time T5 = taylorexpansion!(G6) | ||
#order = [0, 0, 0, 0, 0, 0] | ||
#@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)) $(eval!(getcoeff(T5,order))) $(coeff.id) $(count_operation(coeff))\n") | ||
# end | ||
|
||
print("TaylorSeries $(T5)\n") | ||
|
||
@time T5_compare = build_derivative_backAD!(G6) | ||
print("$(count_operation(T5_compare.coeffs))\n") | ||
for (order, coeff) in (T5_compare.coeffs) | ||
@assert (eval!(coeff)) == (eval!(Taylor.taylor_factorial(order) * T5.coeffs[order])) | ||
# gs = Compilers.to_julia_str([coeff,], name="eval_graph!") | ||
# println("$(order) ", gs, "\n") | ||
# print("$(order) $(eval!(coeff)) $(eval!(getderivative(T5,order))) $(count_operation(coeff))\n") | ||
end | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
TaylorSeries | ||
A Julia package for Taylor expansions in one or more independent variables. | ||
The basic constructors is [`TaylorSeries`](@ref). | ||
""" | ||
module Taylor | ||
|
||
using ..ComputationalGraphs | ||
#using Markdown | ||
|
||
|
||
#export show_params_TaylorN, show_monomials, displayBigO, use_show_default, | ||
|
||
include("parameter.jl") | ||
include("constructors.jl") | ||
include("print.jl") | ||
include("arithmetic.jl") | ||
export TaylorSeries | ||
|
||
export get_order, get_numvars, | ||
set_variables, get_variables, | ||
get_variable_names, get_variable_symbols, | ||
displayBigO, use_show_default, | ||
getcoeff, taylor_factorial | ||
|
||
end # module |
Oops, something went wrong.