Skip to content

Commit 20d5fa3

Browse files
committed
Add diffeq! to improve ODE recursion rule allocs
1 parent f673c2e commit 20d5fa3

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

src/TaylorIntegration.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,28 @@ function __init__()
3232
end
3333
end
3434

35+
function diffeq!(a::Taylor1{T}, b::Taylor1{T}, k::Int) where {T<:TaylorSeries.NumberNotSeries}
36+
a[k] = b[k-1]/k
37+
return nothing
38+
end
39+
40+
@inline function diffeq!(res::Taylor1{Taylor1{T}}, a::Taylor1{Taylor1{T}},
41+
k::Int) where {T<:TaylorSeries.NumberNotSeries}
42+
for l in eachindex(a[k-1])
43+
res[k][l] = a[k-1][l]/k
44+
end
45+
return nothing
46+
end
47+
48+
@inline function diffeq!(res::Taylor1{TaylorN{T}}, a::Taylor1{TaylorN{T}},
49+
k::Int) where {T<:TaylorSeries.NumberNotSeries}
50+
for l in eachindex(a[k-1])
51+
for m in eachindex(a[k-1][l])
52+
res[k][l][m] = a[k-1][l][m]/k
53+
end
54+
end
55+
return nothing
56+
end
57+
3558

3659
end #module

src/parse_eqs.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,8 @@ function _recursionloop(fnargs, bkkeep::BookKeeping)
10401040

10411041
if ll == 3
10421042
rec_preamb = sanitize( :( $(fnargs[1]).coeffs[2] = $(bkkeep.retvar).coeffs[1] ) )
1043-
rec_fnbody = sanitize( :( $(fnargs[1]).coeffs[ordnext+1] = $(bkkeep.retvar).coeffs[ordnext]/ordnext ) )
1043+
# rec_fnbody = sanitize( :( $(fnargs[1]).coeffs[ordnext+1] = $(bkkeep.retvar).coeffs[ordnext]/ordnext ) )
1044+
rec_fnbody = sanitize( :( TaylorIntegration.diffeq!($(fnargs[1]), $(bkkeep.retvar), ordnext) ) )
10441045

10451046
elseif ll == 4
10461047
bkkeep.retvar = fnargs[1]
@@ -1050,8 +1051,9 @@ function _recursionloop(fnargs, bkkeep::BookKeeping)
10501051
end))
10511052
rec_fnbody = sanitize(:(
10521053
for __idx in eachindex($(fnargs[2]))
1053-
$(fnargs[2])[__idx].coeffs[ordnext+1] =
1054-
$(bkkeep.retvar)[__idx].coeffs[ordnext]/ordnext
1054+
# $(fnargs[2])[__idx].coeffs[ordnext+1] =
1055+
# $(bkkeep.retvar)[__idx].coeffs[ordnext]/ordnext
1056+
TaylorIntegration.diffeq!($(fnargs[2])[__idx], $(bkkeep.retvar)[__idx], ordnext)
10551057
end))
10561058

10571059
else

test/runtests.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
# This file is part of the TaylorIntegration.jl package; MIT licensed
22

33
testfiles = (
4-
"solution.jl",
5-
"one_ode.jl",
6-
"many_ode.jl",
7-
"complex.jl",
8-
"jettransport.jl",
9-
"lyapunov.jl",
10-
"bigfloats.jl",
11-
"common.jl",
12-
"rootfinding.jl",
4+
# "one_ode.jl",
5+
# "many_ode.jl",
6+
# "complex.jl",
7+
# "jettransport.jl",
8+
# "lyapunov.jl",
9+
# "bigfloats.jl",
10+
# "common.jl",
11+
# "rootfinding.jl",
1312
"taylorize.jl",
14-
"aqua.jl",
13+
# "aqua.jl",
1514
)
1615

1716
for file in testfiles

0 commit comments

Comments
 (0)