Skip to content

Commit be84b43

Browse files
committed
Add residual_order_condition
1 parent fdd291c commit be84b43

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1212
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
1313
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
1414
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
15+
RootedTrees = "47965b36-3f3e-11e9-0dcf-4570dfd42a8c"
1516
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1617

1718
[compat]
@@ -22,6 +23,7 @@ DiffEqProblemLibrary = "4.5"
2223
NLsolve = "4.2"
2324
RecipesBase = "0.7, 0.8, 1.0"
2425
RecursiveArrayTools = "2"
26+
RootedTrees = "1"
2527
julia = "1"
2628

2729
[extras]

src/DiffEqDevTools.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export test_convergence, analyticless_test_convergence, appxtrue!, appxtrue
4040
export get_sample_errors
4141

4242
#Plot Functions
43-
export stability_region
43+
export stability_region, residual_order_condition
4444

4545
#Tableaus
4646
export deduce_Butcher_tableau

src/tableau_info.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NLsolve, LinearAlgebra
1+
using NLsolve, LinearAlgebra, RootedTrees
22
"""
33
`Base.length(tab::ODERKTableau)`
44
@@ -29,3 +29,16 @@ function stability_region(tab::ODERKTableau; initial_guess=-3.0)
2929
sol = nlsolve(residual!, [initial_guess])
3030
sol.zero[1]
3131
end
32+
33+
function RootedTrees.residual_order_condition(tab::ODERKTableau, order::Int, reducer=nothing, mapper=x->x^2)
34+
if reducer === nothing
35+
resid = map(RootedTreeIterator(order)) do t
36+
residual_order_condition(t, tab.A, tab.α, tab.c)
37+
end
38+
else
39+
resid = mapreduce(reducer, RootedTreeIterator(order)) do t
40+
mapper(residual_order_condition(t, tab.A, tab.α, tab.c))
41+
end
42+
end
43+
return resid
44+
end

0 commit comments

Comments
 (0)