Maps
This module provides the Map class, which implements linear multiplicative maps on trees
and allows for their manipulation with respect to different Hopf algebras. In particular, this covers
characters on the Hopf algebra, as well as more complicated maps.
- class Map(func: Callable[[Tree], int | float | Tree | CommutativeForest | ForestSum], anti: bool = False, extension: str = 'concat')[source]
A linear map on rooted trees, with a choice of forest-extension convention. The class is callable.
When
extension="concat"(default, used by BCK, NCK, CEM, GL, PGL), the map extends multiplicatively over forest concatenation:f(t1 * t2 * ... * tk) = f(t1) * f(t2) * ... * f(tk). Ifanti=True, the map extends as a concatenation anti-homomorphism (reversed order), as required for antipodes of noncommutative Hopf algebras (NCK, PGL).When
extension="shuffle"(used by MKW),funcis expected to accept any MKW basis element (tree orOrderedForest) and return a scalar;__call__()extends it linearly over aForestSum. Base characters (tree values only) should be wrapped withkauri.generic_algebra.mkw_base_char_func()so that forest inputs are handled by the shuffle-symmetric Pi/k! extension; convolution results fromkauri.mkw.map_product()already have a basis-awarefuncthat recurses through the paper’s forest coproduct.antiis not meaningful here (the shuffle product is commutative) and must beFalse.- Parameters:
func (Callable) – A function taking a basis element (tree or forest for shuffle extension; tree for concat) and returning a scalar, Tree, Forest or ForestSum.
anti (bool) – If True, use the concat anti-homomorphism extension (reversed order). Requires
extension="concat".extension (str) –
"concat"(default) or"shuffle".
- __add__(other: Map) Map[source]
Returns the pointwise sum of two maps, given by
\[(f + g)(t) := f(t) + g(t)\]- Return type:
Example usage:
m1 = 2 * bck.antipode m2 = bck.antipode + bck.antipode # Same as m1
- __and__(other: Map) Map[source]
Returns the composition of two maps, given by
\[(f \, \& \, g)(t) := (f \circ g)(t) := f(g(t))\]- Return type:
Example usage:
t = Tree([[]]) kr.display((bck.antipode & bck.antipode)(t)) kr.display(bck.antipode(bck.antipode(t))) #Same as above
- __mul__(other: Map | int | float) Map[source]
Returns the product of maps in the BCK Hopf algebra, defined by
\[(f \cdot g)(t) := \mu \circ (f \otimes g) \circ \Delta_{BCK} (t).\]If other is of type int or float, returns the map scaled by other.
- Parameters:
other – Map | int | float
- Return type:
Example usage:
ident = Map(lambda x : x) counit = ident * bck.antipode ident_2 = 2 * ident # ident_2(t) = 2 * t for any tree t
- __pow__(exponent: int) Map[source]
Returns the power of the map in the BCK Hopf algebra, where the product of functions is defined by
\[(f \cdot g)(t) := \mu \circ (f \otimes g) \circ \Delta_{BCK} (t)\]and negative powers are defined as \(f^{-n} = (f \circ S_{BCK})^n\), where \(S_{BCK}\) is the BCK antipode.
- Parameters:
exponent (int) – Exponent
- Return type:
Example usage:
ident = Map(lambda x : x) S = ident ** (-1) # BCK antipode ident_sq = ident ** 2 # identity squared
- exp() Map[source]
Returns the exponential of the map, defined as
\[\exp(\phi) = \phi \star e\]where \(e(t) = 1 / t!\) is the elementary weights function of the exact solution [CHV10, Mur06].
- Returns:
Exponential map
- Return type:
- log() Map[source]
Returns the logarithm of the map, defined as
\[\log(\phi) = \phi \star e^{\star (-1)}\]where \(e(t) = 1 / t!\) is the elementary weights function of the exact solution and \(e^{\star (-1)} = e \circ S_{CEM}\) [CHV10, Mur06].
- Returns:
Logarithm map
- Return type:
- modified_equation() Map[source]
Assuming the given map \(\phi\) corresponds to the elementary weights function of a B-series method, returns the map corresponding to the coefficients of the modified (B-series) vector field, \(\widetilde{\phi}\), defined by
\[(\widetilde{\phi} \star e)(t) = \phi(t)\]where \(e(t) = 1 / t!\) is the elementary weights function of the exact solution, or equivalently
\[\widetilde{\phi}(t) = (\phi \star e^{\star (-1)})(t)\]and \(e^{\star (-1)} = e \circ S_{CEM}\) [CHV10].
- Returns:
Map corresponding to the modified vector field
- preprocessed_integrator() Map[source]
Assuming the given map \(\phi\) corresponds to the elementary weights function of a B-series method, returns the map corresponding to the preprocessed integrator, \(\widetilde{\phi}\), defined by
\[(\widetilde{\phi} \star \phi)(t) = e(t)\]where \(e(t) = 1 / t!\) is the elementary weights function of the exact solution, or equivalently
\[\widetilde{\phi}(t) = (e \star \phi^{\star (-1)})(t)\]and \(\phi^{\star (-1)} = \phi \circ S_{CEM}\) [CHV10].
- Returns:
Map corresponding to the preprocessed integrator
Batch evaluation
Use Map.evaluate_many() to evaluate one map on several inputs while
preserving input order.
from kauri import Map, trees_of_order
weights = Map(lambda t: 1 / t.factorial())
inputs = tuple(trees_of_order(5))
serial_values = weights.evaluate_many(inputs)
threaded_values = weights.evaluate_many(inputs, workers=4)
Instances
We provide a few common instances of the Map class for convenience.
- ident
The identity map, \(t \mapsto t\).
- sign
The sign map, or canonical involution, \(t \mapsto (-1)^{|t|} t\).
- exact_weights
The elementary weights function of the exact solution, \(t \mapsto 1/t!\).