Skip to content

LieQuotientPlan

from tensorsig.offset_coded_signatures.quotients import LieQuotientPlan

Intrinsic normal-form basis and sparse bracket table for one quotient.

Unlike the former plan representation, this object contains no required ambient Hall basis or dense projection matrices. basis contains the retained Hall trees for upper-set quotients and exact trace normal forms for graph quotients. Tensor evaluation constructs its word projection lazily.

dimension property

dimension: int

Dimension of the quotient Lie algebra.

ambient_dimension property

ambient_dimension: int

Dimension of the ambient free step-nilpotent Lie algebra.

level_dimensions property

level_dimensions: tuple[int, ...]

Quotient dimensions in homogeneous levels 1..max_depth.

to

to(device: device | str | None = None, dtype: dtype | None = None) -> 'LieQuotientPlan'

Return an intrinsic plan with runtime tensors on device/dtype.

Source code in src/tensorsig/offset_coded_signatures/_lie_quotients/compiler.py
def to(
    self,
    device: torch.device | str | None = None,
    dtype: torch.dtype | None = None,
) -> "LieQuotientPlan":
    """Return an intrinsic plan with runtime tensors on ``device``/``dtype``."""
    target_device = (
        self.generator_map.device if device is None else torch.device(device)
    )
    target_dtype = self.generator_map.dtype if dtype is None else dtype
    if not target_dtype.is_floating_point:
        raise ValueError("dtype must be floating-point.")
    if (
        target_device == self.generator_map.device
        and target_dtype == self.generator_map.dtype
    ):
        return self
    cache_key = (target_device, target_dtype)
    cached = self._bound_cache.get(cache_key)
    if cached is not None:
        return cached
    moved = LieQuotientPlan(
        quotient=self.quotient,
        alphabet=self.alphabet,
        max_depth=self.max_depth,
        basis=self.basis,
        generator_map=self.generator_map.to(
            device=target_device,
            dtype=target_dtype,
        ),
        bracket_indices=self.bracket_indices.to(device=target_device),
        bracket_values=self.bracket_values.to(
            device=target_device,
            dtype=target_dtype,
        ),
        bracket_coefficients=self.bracket_coefficients,
        basis_depths=self.basis_depths.to(device=target_device),
        coordinate_aligned=self.coordinate_aligned,
        compiler=self.compiler,
    )
    if self._word_bridge_cache is not None:
        object.__setattr__(
            moved,
            "_word_bridge_cache",
            _WordsBridge(
                ambient_words=self._word_bridge_cache.ambient_words,
                quotient_matrix=(
                    self._word_bridge_cache.quotient_matrix.to_dense()
                    if target_device.type == "mps"
                    and self._word_bridge_cache.quotient_matrix.layout
                    != torch.strided
                    else self._word_bridge_cache.quotient_matrix
                ).to(
                    device=target_device,
                    dtype=target_dtype,
                ),
                active_columns=self._word_bridge_cache.active_columns,
            ),
        )
    source_key = (self.generator_map.device, self.generator_map.dtype)
    self._bound_cache.setdefault(source_key, self)
    self._bound_cache[cache_key] = moved
    object.__setattr__(moved, "_bound_cache", self._bound_cache)
    return moved

summary

summary() -> str

Return a compact structural and computational summary.

Source code in src/tensorsig/offset_coded_signatures/_lie_quotients/compiler.py
def summary(self) -> str:
    """Return a compact structural and computational summary."""
    return (
        f"{self.compiler}: {self.ambient_dimension} -> {self.dimension} "
        f"primitives; levels={self.level_dimensions}; "
        f"brackets={len(self.bracket_values)}"
    )