Skip to content

delay_history ¤

Chronological indexing of bounded, overwritable accepted-step history.

Classes:

Name Description
DelayTimes

Ring timestamps with a logical ascending view, without rotating storage.

DelayTimes ¤

Bases: Module

Ring timestamps with a logical ascending view, without rotating storage.

Methods:

Name Description
physical

Map chronological indices to physical storage slots.

search

Right insertion point in the valid chronological prefix; O(log capacity).

time

Gather chronological timestamps without rotating storage.

physical ¤

physical(logical: ArrayLike) -> Array

Map chronological indices to physical storage slots.

Source code in circulax/solvers/delay_history.py
def physical(self, logical: ArrayLike) -> jax.Array:
    """Map chronological indices to physical storage slots."""
    return (self.start + logical) % self.times.shape[0]

search ¤

search(query: Array) -> Array

Right insertion point in the valid chronological prefix; O(log capacity).

Source code in circulax/solvers/delay_history.py
def search(self, query: jax.Array) -> jax.Array:
    """Right insertion point in the valid chronological prefix; O(log capacity)."""

    def body(_: int, bounds: tuple[jax.Array, jax.Array]) -> tuple[jax.Array, jax.Array]:
        lo, hi = bounds
        mid = (lo + hi) // 2
        right = (mid < self.count) & (self.time(mid) <= query)
        return jnp.where(right, mid + 1, lo), jnp.where(right, hi, mid)

    lo, _ = jax.lax.fori_loop(
        0,
        self.times.shape[0].bit_length(),
        body,
        (jnp.zeros_like(query, dtype=jnp.int32), jnp.full_like(query, self.count, dtype=jnp.int32)),
    )
    return lo

time ¤

time(logical: ArrayLike) -> Array

Gather chronological timestamps without rotating storage.

Source code in circulax/solvers/delay_history.py
def time(self, logical: ArrayLike) -> jax.Array:
    """Gather chronological timestamps without rotating storage."""
    return self.times[self.physical(logical)]