Skip to content

Commit c471c77

Browse files
authored
root_color (#75)
* add root_color interface * bump version
1 parent 50cdd09 commit c471c77

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RootedTrees"
22
uuid = "47965b36-3f3e-11e9-0dcf-4570dfd42a8c"
33
authors = ["Hendrik Ranocha <mail@ranocha.de> and contributors"]
4-
version = "2.9.2"
4+
version = "2.10.0"
55

66
[deps]
77
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"

src/RootedTrees.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export RootedTree, rootedtree, rootedtree!, RootedTreeIterator,
1515

1616
export butcher_representation
1717

18-
export α, β, γ, density, σ, symmetry, order
18+
export α, β, γ, density, σ, symmetry, order, root_color
1919

2020
export residual_order_condition, elementary_weight, derivative_weight
2121

src/colored_trees.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ Base.empty(t::ColoredRootedTree) = ColoredRootedTree(empty(t.level_sequence), em
9292
return t_dst
9393
end
9494

95+
"""
96+
root_color(t::ColoredRootedTree)
97+
98+
Return the color of the root of `t`.
99+
"""
100+
root_color(t::ColoredRootedTree) = first(t.color_sequence)
101+
95102
# Internal interface
96103
@inline function unsafe_deleteat!(t::ColoredRootedTree, i)
97104
deleteat!(t.level_sequence, i)
@@ -548,14 +555,14 @@ function butcher_representation(t::ColoredRootedTree, normalize::Bool=true;
548555
if order(t) == 0
549556
return ""
550557
elseif order(t) == 1
551-
return "τ" * colormap[first(t.color_sequence)]
558+
return "τ" * colormap[root_color(t)]
552559
end
553560

554561
result = ""
555562
for subtree in SubtreeIterator(t)
556563
result = result * butcher_representation(subtree, normalize, colormap=colormap)
557564
end
558-
result = "[" * result * "]" * colormap[first(t.color_sequence)]
565+
result = "[" * result * "]" * colormap[root_color(t)]
559566

560567
if normalize
561568
# normalize the result by grouping repeated occurrences of τ

src/time_integration_methods.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ end
194194
# Colored trees are used for order conditions of additive Runge-Kutta methods.
195195
# The function `color_to_index` maps a color to a one-based index of ARK
196196
# coefficients.
197+
# This is considered to be an internal interface but stable across minor/patch
198+
# releases.
197199
color_to_index(color::Integer) = Int(color)
198200
color_to_index(color::Bool) = 1 + color
199201

0 commit comments

Comments
 (0)