Combinators¶
Combinators for building complex manifolds from simpler ones.
Provides product manifolds (Pair, Triple), homogeneous products (Replicated), and the zero-dimensional Null. Each combinator stores coordinates as a flat concatenation and provides split_coords / join_coords for component access.
Class Hierarchy¶
Null Manifold¶
Product Manifolds¶
- class Tuple[source]¶
-
Abstract Cartesian product of manifolds, with coordinates stored as a flat concatenation.
Mathematically, the Cartesian product \(\mathcal M_1 \times \cdots \times \mathcal M_k\) has \(\dim = \sum_i \dim(\mathcal M_i)\). Subclasses (
Pair,Triple) fix the arity and provide typedsplit_coords/join_coords.
- class Pair[source]¶
-
Binary Cartesian product, with coordinates stored as
[fst | snd].- abstract property fst_man: First¶
First component manifold.
- abstract property snd_man: Second¶
Second component manifold.
- class Triple[source]¶
-
Product of three manifolds, with coordinates stored as
[fst | snd | trd].- abstract property fst_man: First¶
First component manifold.
- abstract property snd_man: Second¶
Second component manifold.
- abstract property trd_man: Third¶
Third component manifold.
- class Replicated(rep_man: M, n_reps: int)[source]¶
-
Homogeneous product of \(n\) copies of the same manifold, stored flat as
[n_reps * rep_man.dim].Used for collections where every element lives on the same manifold (e.g. mixture components, time series states). The
mapmethod applies a function across copies viavmap.Mathematically, the \(n\)-fold product \(\mathcal M^n = \mathcal M \times \cdots \times \mathcal M\) with \(\dim = n \cdot \dim(\mathcal M)\). Unlike
Tuple, the homogeneity allowsvmap-based operations over the copies.- rep_man: M¶
The base manifold being replicated.
- get_replicate(coords: Array, idx: int) Array[source]¶
Extract the
idx-th replicate from flat coordinates.
- to_2d(coords: Array) Array[source]¶
Convert flat coordinates to 2D array with shape
[n_reps, rep_man.dim].
- map(f: Callable[[Array], Array], coords: Array, flatten: bool = False) Array[source]¶
Map a function across replicates.
By default, returns stacked 2D results for easier indexing and inspection. Use
flatten=Truewhen the result should be flat coordinates on another manifold.- Parameters:
f – Function that takes coordinates for one replicate (shape
[rep_man.dim])coords – Flat array of replicated coordinates (shape
[n_reps * rep_man.dim])flatten – If True, return flat array
[n_reps * f_result_dim]. If False (default), return stacked array[n_reps, *f_result_shape]for easier indexing and inspection.
- Returns:
Stacked 2D array by default, or flat 1D array if
flatten=True