Return the exact cumulative rank where the solved-regime theorem applies.
Source code in src/tensorsig/offset_coded_signatures/pascal_rank.py
| def binary_pascal_rank(degree: int, window: int, weight: int) -> int | None:
"""Return the exact cumulative rank where the solved-regime theorem applies."""
_validate_parameters(degree, window, weight)
if window == 2:
ell = (degree - 1) // 2
if degree in (2, 4):
increments = (0, 1)
elif degree == 3:
increments = (0, 1, 1)
elif degree % 2:
increments = (0, 1, ell, ell - 1)
else:
gamma = degree // 6
increments = (0, 1, gamma, ell - 1, ell - 1 - gamma)
return sum(increments[: weight + 1])
if (
weight < window
or window >= degree - 1
or (
weight <= window
and (2 * window >= degree + 2 or (degree, window) == (5, 3))
)
):
return sum(binary_lie_weight_dimension(degree, k) for k in range(weight + 1))
return None
|