Skip to content

Manifolds API

This page documents the core manifold operations in Hyperbolix. Each manifold is a class that provides geometric operations and automatic dtype casting.

Overview

Hyperbolix provides seven base manifold classes plus a composition class:

  • Euclidean: Flat Euclidean space (baseline)
  • Poincaré Ball: Conformal model of hyperbolic space
  • Hyperboloid: Lorentz/Minkowski model of hyperbolic space
  • Proper Velocity: Unconstrained \(\mathbb{R}^n\) model from special relativity (Chen et al. 2026)
  • κ-Stereographic: Signed-curvature model unifying hyperbolic, Euclidean, and spherical geometry in one manifold (Bachmann et al. 2020)
  • Klein: Beltrami–Klein ball model — straight-chord geodesics and Einstein gyrovector operations (Mao et al. 2024; Zhang et al. 2026)
  • HalfSpace: Poincaré upper half-space model — the height is the last coordinate, and the gyrovector operations are Möbius operations carried over from the ball by the Cayley transform
  • Product Manifold: Heterogeneous-curvature product spaces \(M_1 \times M_2 \times \dots \times M_n\) (Gu et al. 2019)

All manifolds share a common interface defined by the Manifold protocol and support:

  • Automatic dtype casting: Pass dtype=jnp.float64 for higher precision (needs jax_enable_x64)
  • vmap-native methods: Methods operate on single points; use jax.vmap for batching
  • JIT compatibility: All methods are JIT-compilable
  • Learnable curvature: Use the LearnableCurvature module to add trainable curvature to any model (positive softplus/log or signed identity reparameterization, clamped by default to [init_c/10, init_c·10], or [-10, 10] for identity)

Manifold Protocol

The Curvature type

Manifold methods take the curvature as a positional c: Curvature argument (hyperbolix.manifolds.Curvature). It is the union ScalarCurvature | Sequence[ScalarCurvature], where ScalarCurvature = float | jax.Array: every single manifold (Poincare, Hyperboloid, ProperVelocity, Klein, HalfSpace, Stereographic, Euclidean) takes a scalar c, while ProductManifold takes a sequence of per-factor scalars. Passing a traced jax.Array (e.g. the value returned by a LearnableCurvature call) makes the curvature differentiable.

hyperbolix.manifolds.protocol.Manifold

Bases: Protocol

Structural protocol for manifold classes.

All concrete manifold classes (Poincare, Hyperboloid, ProperVelocity, Klein, HalfSpace, Euclidean, Stereographic, ProductManifold) satisfy this protocol without modification.

c is typed ScalarCurvature -- this is the scalar-curvature interface, which is what every single manifold accepts and what the arithmetic inside them requires. ProductManifold declares the wider Curvature union (scalar or per-factor sequence) and therefore still satisfies the protocol: a parameter may always be wider than the one it implements. Code that means to pass a per-factor sequence should annotate the manifold as ProductManifold, not as Manifold.

The method signatures use the minimal common interface so that manifold-specific optional parameters do not break compatibility. Two such parameters are nevertheless uniform across every implementation, and are part of the protocol:

  • dist / dist_0 take a trailing version_idx: int. Manifolds with a single distance implementation accept and ignore it (documented on each), so a generic caller can always forward one.
  • is_in_manifold / is_in_tangent_space take a trailing atol: float | None = None, resolved through :func:~hyperbolix.manifolds._base.default_atol when None. No implementation floors, clamps, or silently drops an explicit value; unconstrained manifolds (Euclidean, ProperVelocity) document that a finiteness test has no tolerance to apply.

The two curvature types are exported from hyperbolix.manifolds:

hyperbolix.manifolds.protocol.ScalarCurvature module-attribute

ScalarCurvature = float | Float[Array, '']

hyperbolix.manifolds.protocol.Curvature module-attribute

Curvature = ScalarCurvature | Sequence[ScalarCurvature]

Euclidean

Flat Euclidean space (identity operations).

hyperbolix.manifolds.euclidean.Euclidean

Euclidean(dtype: dtype = jnp.float32)

Bases: ManifoldBase

Euclidean manifold with automatic dtype casting.

Provides all manifold operations with automatic casting of array inputs to the specified dtype. Curvature is always fixed at 0.0.

Args: dtype: Target JAX dtype for computations (default: jnp.float32)

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds.euclidean import Euclidean >>> >>> manifold = Euclidean(dtype=jnp.float64) >>> x = jnp.array([1.0, 2.0]) >>> y = jnp.array([3.0, 4.0]) >>> d = manifold.dist(x, y)

Source code in hyperbolix/manifolds/euclidean.py
def __init__(self, dtype: jnp.dtype = jnp.float32) -> None:
    super().__init__(dtype, c=0.0)

proj

proj(
    x: Float[Array, dim], c: ScalarCurvature = 0.0
) -> Float[Array, dim]

Project point onto Euclidean space (identity).

Source code in hyperbolix/manifolds/euclidean.py
def proj(self, x: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Project point onto Euclidean space (identity)."""
    return _proj(self._cast(x), self._cast_c(c))

addition

addition(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Add Euclidean points.

Source code in hyperbolix/manifolds/euclidean.py
def addition(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Add Euclidean points."""
    return _addition(self._cast(x), self._cast(y), self._cast_c(c))

scalar_mul

scalar_mul(
    r: float | Float[Array, ""],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Scalar multiplication.

Source code in hyperbolix/manifolds/euclidean.py
def scalar_mul(self, r: float | Float[Array, ""], x: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Scalar multiplication."""
    x = self._cast(x)
    r_cast = jnp.asarray(r, dtype=x.dtype)
    return _scalar_mul(r_cast, x, self._cast_c(c))  # type: ignore[arg-type]

dist

dist(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature = 0.0,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Compute distance (version_idx accepted and ignored — see the module docstring).

Source code in hyperbolix/manifolds/euclidean.py
def dist(
    self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature = 0.0, version_idx: int = VERSION_DEFAULT
) -> Float[Array, ""]:
    """Compute distance (``version_idx`` accepted and ignored — see the module docstring)."""
    del version_idx
    return _dist(self._cast(x), self._cast(y), self._cast_c(c))

dist_0

dist_0(
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Distance from origin (version_idx accepted and ignored).

Source code in hyperbolix/manifolds/euclidean.py
def dist_0(self, x: Float[Array, "dim"], c: ScalarCurvature = 0.0, version_idx: int = VERSION_DEFAULT) -> Float[Array, ""]:
    """Distance from origin (``version_idx`` accepted and ignored)."""
    del version_idx
    return _dist_0(self._cast(x), self._cast_c(c))

expmap

expmap(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Exponential map.

Source code in hyperbolix/manifolds/euclidean.py
def expmap(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Exponential map."""
    return _expmap(self._cast(v), self._cast(x), self._cast_c(c))

expmap_0

expmap_0(
    v: Float[Array, dim], c: ScalarCurvature = 0.0
) -> Float[Array, dim]

Exponential map from origin.

Source code in hyperbolix/manifolds/euclidean.py
def expmap_0(self, v: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Exponential map from origin."""
    return _expmap_0(self._cast(v), self._cast_c(c))

retraction

retraction(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Retraction.

Source code in hyperbolix/manifolds/euclidean.py
def retraction(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Retraction."""
    return _retraction(self._cast(v), self._cast(x), self._cast_c(c))

logmap

logmap(
    y: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Logarithmic map.

Source code in hyperbolix/manifolds/euclidean.py
def logmap(self, y: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Logarithmic map."""
    return _logmap(self._cast(y), self._cast(x), self._cast_c(c))

logmap_0

logmap_0(
    y: Float[Array, dim], c: ScalarCurvature = 0.0
) -> Float[Array, dim]

Logarithmic map from origin.

Source code in hyperbolix/manifolds/euclidean.py
def logmap_0(self, y: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Logarithmic map from origin."""
    return _logmap_0(self._cast(y), self._cast_c(c))

ptransp

ptransp(
    v: Float[Array, dim],
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Parallel transport.

Source code in hyperbolix/manifolds/euclidean.py
def ptransp(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature = 0.0
) -> Float[Array, "dim"]:
    """Parallel transport."""
    return _ptransp(self._cast(v), self._cast(x), self._cast(y), self._cast_c(c))

ptransp_0

ptransp_0(
    v: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Parallel transport from origin.

Source code in hyperbolix/manifolds/euclidean.py
def ptransp_0(self, v: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Parallel transport from origin."""
    return _ptransp_0(self._cast(v), self._cast(y), self._cast_c(c))

tangent_inner

tangent_inner(
    u: Float[Array, dim],
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, ""]

Tangent inner product.

Source code in hyperbolix/manifolds/euclidean.py
def tangent_inner(
    self, u: Float[Array, "dim"], v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature = 0.0
) -> Float[Array, ""]:
    """Tangent inner product."""
    return _tangent_inner(self._cast(u), self._cast(v), self._cast(x), self._cast_c(c))

tangent_norm

tangent_norm(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, ""]

Tangent norm.

Source code in hyperbolix/manifolds/euclidean.py
def tangent_norm(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, ""]:
    """Tangent norm."""
    return _tangent_norm(self._cast(v), self._cast(x), self._cast_c(c))

egrad2rgrad

egrad2rgrad(
    grad: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Euclidean to Riemannian gradient.

Source code in hyperbolix/manifolds/euclidean.py
def egrad2rgrad(self, grad: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Euclidean to Riemannian gradient."""
    return _egrad2rgrad(self._cast(grad), self._cast(x), self._cast_c(c))

tangent_proj

tangent_proj(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
) -> Float[Array, dim]

Project onto tangent space.

Source code in hyperbolix/manifolds/euclidean.py
def tangent_proj(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature = 0.0) -> Float[Array, "dim"]:
    """Project onto tangent space."""
    return _tangent_proj(self._cast(v), self._cast(x), self._cast_c(c))

is_in_manifold

is_in_manifold(
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
    atol: float | None = None,
) -> Array

Check that all entries are finite (Euclidean space has no other constraint).

Source code in hyperbolix/manifolds/euclidean.py
def is_in_manifold(self, x: Float[Array, "dim"], c: ScalarCurvature = 0.0, atol: float | None = None) -> Array:
    """Check that all entries are finite (Euclidean space has no other constraint)."""
    return _is_in_manifold(self._cast(x), self._cast_c(c), atol)

is_in_tangent_space

is_in_tangent_space(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature = 0.0,
    atol: float | None = None,
) -> Array

Check that all entries are finite (T_x R^n = R^n has no other constraint).

Source code in hyperbolix/manifolds/euclidean.py
def is_in_tangent_space(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature = 0.0, atol: float | None = None
) -> Array:
    """Check that all entries are finite (T_x R^n = R^n has no other constraint)."""
    return _is_in_tangent_space(self._cast(v), self._cast(x), self._cast_c(c), atol)

Poincaré Ball

The Poincaré ball model with Möbius operations.

Distance Versions

The Poincaré dist method has a version_idx parameter selecting between 3 formulations:

  • VERSION_MOBIUS_DIRECT (0): direct Möbius distance formula (default)
  • VERSION_MOBIUS (1): Möbius via addition
  • VERSION_METRIC_TENSOR (2): Direct metric tensor integration

Constants are available as poincare.VERSION_MOBIUS_DIRECT etc., or from hyperbolix.manifolds.poincare.

Slots 0 and 2 compute the same asinh distance, accurate to the ball chart's ceiling; slot 1 saturates there:

\[d(x, y) = \frac{2}{\sqrt{c}}\operatorname{arcsinh}\!\left(\frac{\sqrt{c}\,\lVert x-y\rVert}{\sqrt{(1-c\lVert x\rVert^2)(1-c\lVert y\rVert^2)}}\right)\]

Measured values: Which Version to Use?.

Apollonian weak metric

apollonian_dist(x, y, c) is the non-symmetric Apollonian weak metric \(\delta\) (Papadopoulos & Troyanov, Weak metrics on Euclidean domains, Thm 2) — a weak metric, not a geodesic distance:

\[\delta_c(x,y) = \log\!\left(\frac{\sqrt{c}\,\lVert x-y\rVert + \sqrt{c^2\lVert x\rVert^2\lVert y\rVert^2 - 2c\langle x,y\rangle + 1}}{1-c\lVert y\rVert^2}\right)\]

It satisfies \(\delta(x,x)=0\), \(\delta\ge 0\) and the triangle inequality, but \(\delta(x,y) \neq \delta(y,x)\) in general. Its symmetrization recovers the geodesic distance: \(\delta(x,y) + \delta(y,x) = \sqrt{c}\cdot\) dist(x, y, c).

Warning

The antisymmetric part of \(\delta\) is an exact coboundary (a difference of a per-point potential), so it carries no circulation and is useless as an asymmetric quasimetric energy. For that, use the busemann coordinate below with an external quasimetric combinator.

Busemann function (Chen et al. 2026)

busemann(x, v, c) is the closed-form point-to-horosphere coordinate \(B^v(x)\) for a unit ideal direction \(v\in\mathbb{S}^{n-1}\) — the horospherical analog of the point-to-hyperplane compute_mlr/compute_mlr_pp. v must be unit-norm (not normalized internally). It is an intrinsic quantity, so Poincare.busemann and Hyperboloid.busemann agree under poincare_to_hyperboloid, and \(B^v(\text{origin})=0\). Backs the *Busemann MLR/FC layers.

\[\mathbb{P}^n:\ B^v(x) = \tfrac{1}{\sqrt c}\log\!\frac{\lVert v-\sqrt c\,x\rVert^2}{1-c\lVert x\rVert^2} \qquad\quad \mathbb{L}^n:\ B^v(x) = \tfrac{1}{\sqrt c}\log\!\big(\sqrt c\,(x_t-\langle x_s,v\rangle)\big)\]

hyperbolix.manifolds.poincare.Poincare

Poincare(dtype: dtype = jnp.float32, *, c: float = 1.0)

Bases: ManifoldBase

Poincaré ball manifold with automatic dtype casting.

Provides all manifold operations with automatic casting of array inputs to the specified dtype. This eliminates the need for manual casting and provides better numerical stability control.

Args: dtype: Target JAX dtype for computations (default: jnp.float32) c: Curvature value (default: 1.0). Must be positive.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds.poincare import Poincare, VERSION_MOBIUS_DIRECT >>> >>> # Create manifold with float64 for better precision >>> manifold = Poincare(dtype=jnp.float64) >>> >>> # Static curvature >>> manifold = Poincare(c=0.1) >>> c = manifold.c # returns 0.1

Source code in hyperbolix/manifolds/_base.py
def __init__(
    self,
    dtype: jnp.dtype = jnp.float32,
    *,
    c: float = 1.0,
) -> None:
    self.dtype = dtype
    self._c_val = c

proj

proj(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Project point onto Poincaré ball by clipping norm.

Source code in hyperbolix/manifolds/poincare.py
def proj(self, x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Project point onto Poincaré ball by clipping norm."""
    return _proj(self._cast(x), self._cast_c(c))

proj_batch

proj_batch(
    x: Float[Array, "... dim"], c: ScalarCurvature
) -> Float[Array, "... dim"]

Project batched points onto the ball (handles arbitrary leading dimensions).

Batched sibling of :meth:proj, matching Hyperboloid.proj_batch. Equivalent to jax.vmap(proj, in_axes=(0, None)) on a 2D input, without materializing the vmap.

Source code in hyperbolix/manifolds/poincare.py
def proj_batch(self, x: Float[Array, "... dim"], c: ScalarCurvature) -> Float[Array, "... dim"]:
    """Project batched points onto the ball (handles arbitrary leading dimensions).

    Batched sibling of :meth:`proj`, matching ``Hyperboloid.proj_batch``. Equivalent to
    ``jax.vmap(proj, in_axes=(0, None))`` on a 2D input, without materializing the vmap.
    """
    return _proj_batch(self._cast(x), self._cast_c(c))

gyration

gyration(
    x: Float[Array, dim],
    y: Float[Array, dim],
    z: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Compute gyration gyr[x,y]z to restore commutativity.

Source code in hyperbolix/manifolds/poincare.py
def gyration(
    self, x: Float[Array, "dim"], y: Float[Array, "dim"], z: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Compute gyration gyr[x,y]z to restore commutativity."""
    return _gyration(self._cast(x), self._cast(y), self._cast(z), self._cast_c(c))

addition

addition(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Möbius gyrovector addition x ⊕ y.

Source code in hyperbolix/manifolds/poincare.py
def addition(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Möbius gyrovector addition x ⊕ y."""
    return _addition(self._cast(x), self._cast(y), self._cast_c(c))

scalar_mul

scalar_mul(
    r: float | Float[Array, ""],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Scalar multiplication r ⊗ x on Poincaré ball.

Source code in hyperbolix/manifolds/poincare.py
def scalar_mul(self, r: float | Float[Array, ""], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Scalar multiplication r ⊗ x on Poincaré ball."""
    x = self._cast(x)
    r_cast = jnp.asarray(r, dtype=x.dtype)
    return _scalar_mul(r_cast, x, self._cast_c(c))  # type: ignore[arg-type]

dist

dist(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_MOBIUS_DIRECT,
) -> Float[Array, ""]

Compute geodesic distance between Poincaré ball points.

Source code in hyperbolix/manifolds/poincare.py
def dist(
    self,
    x: Float[Array, "dim"],
    y: Float[Array, "dim"],
    c: ScalarCurvature,
    version_idx: int = VERSION_MOBIUS_DIRECT,
) -> Float[Array, ""]:
    """Compute geodesic distance between Poincaré ball points."""
    return _dist(self._cast(x), self._cast(y), self._cast_c(c), version_idx)

dist_0

dist_0(
    x: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_MOBIUS_DIRECT,
) -> Float[Array, ""]

Compute geodesic distance from Poincaré ball origin.

Source code in hyperbolix/manifolds/poincare.py
def dist_0(self, x: Float[Array, "dim"], c: ScalarCurvature, version_idx: int = VERSION_MOBIUS_DIRECT) -> Float[Array, ""]:
    """Compute geodesic distance from Poincaré ball origin."""
    return _dist_0(self._cast(x), self._cast_c(c), version_idx)

apollonian_dist

apollonian_dist(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Apollonian weak metric δ(x, y) — non-symmetric; symmetrizes to √c·dist(x, y).

.. warning:: Although δ is non-symmetric, its antisymmetric part is an exact coboundary (δ(x, y) - δ(y, x) is a difference of a per-point potential), so it carries no circulation and is useless as a quasimetric energy. Do not reach for this expecting genuine asymmetry — use a :meth:busemann coordinate fed to an external quasimetric combinator (IQE/MRN) instead.

Source code in hyperbolix/manifolds/poincare.py
def apollonian_dist(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Apollonian weak metric δ(x, y) — non-symmetric; symmetrizes to √c·dist(x, y).

    .. warning::
        Although ``δ`` is non-symmetric, its antisymmetric part is an exact **coboundary**
        (``δ(x, y) - δ(y, x)`` is a difference of a per-point potential), so it carries
        **no circulation** and is useless as a quasimetric energy. Do not reach for this
        expecting genuine asymmetry — use a :meth:`busemann` coordinate fed to an external
        quasimetric combinator (IQE/MRN) instead.
    """
    return _apollonian_dist(self._cast(x), self._cast(y), self._cast_c(c))

expmap

expmap(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Exponential map: map tangent vector v at point x to manifold.

Source code in hyperbolix/manifolds/poincare.py
def expmap(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map: map tangent vector v at point x to manifold."""
    return _expmap(self._cast(v), self._cast(x), self._cast_c(c))

expmap_0

expmap_0(
    v: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Exponential map from origin: map tangent vector v at origin to manifold.

Source code in hyperbolix/manifolds/poincare.py
def expmap_0(self, v: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map from origin: map tangent vector v at origin to manifold."""
    return _expmap_0(self._cast(v), self._cast_c(c))

retraction

retraction(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Retraction: first-order approximation of exponential map.

Source code in hyperbolix/manifolds/poincare.py
def retraction(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Retraction: first-order approximation of exponential map."""
    return _retraction(self._cast(v), self._cast(x), self._cast_c(c))

logmap

logmap(
    y: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Logarithmic map: map point y to tangent space at point x.

Source code in hyperbolix/manifolds/poincare.py
def logmap(self, y: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map: map point y to tangent space at point x."""
    return _logmap(self._cast(y), self._cast(x), self._cast_c(c))

logmap_0

logmap_0(
    y: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Logarithmic map from origin: map point y to tangent space at origin.

Source code in hyperbolix/manifolds/poincare.py
def logmap_0(self, y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map from origin: map point y to tangent space at origin."""
    return _logmap_0(self._cast(y), self._cast_c(c))

ptransp

ptransp(
    v: Float[Array, dim],
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport tangent vector v from point x to point y.

Source code in hyperbolix/manifolds/poincare.py
def ptransp(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Parallel transport tangent vector v from point x to point y."""
    return _ptransp(self._cast(v), self._cast(x), self._cast(y), self._cast_c(c))

ptransp_0

ptransp_0(
    v: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport tangent vector v from origin to point y.

Source code in hyperbolix/manifolds/poincare.py
def ptransp_0(self, v: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Parallel transport tangent vector v from origin to point y."""
    return _ptransp_0(self._cast(v), self._cast(y), self._cast_c(c))

tangent_inner

tangent_inner(
    u: Float[Array, dim],
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Compute inner product of tangent vectors u and v at point x.

Source code in hyperbolix/manifolds/poincare.py
def tangent_inner(
    self, u: Float[Array, "dim"], v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, ""]:
    """Compute inner product of tangent vectors u and v at point x."""
    return _tangent_inner(self._cast(u), self._cast(v), self._cast(x), self._cast_c(c))

tangent_norm

tangent_norm(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Compute norm of tangent vector v at point x.

Source code in hyperbolix/manifolds/poincare.py
def tangent_norm(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Compute norm of tangent vector v at point x."""
    return _tangent_norm(self._cast(v), self._cast(x), self._cast_c(c))

egrad2rgrad

egrad2rgrad(
    grad: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Convert Euclidean gradient to Riemannian gradient.

Source code in hyperbolix/manifolds/poincare.py
def egrad2rgrad(self, grad: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Convert Euclidean gradient to Riemannian gradient."""
    return _egrad2rgrad(self._cast(grad), self._cast(x), self._cast_c(c))

tangent_proj

tangent_proj(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Project vector v onto tangent space at point x.

Source code in hyperbolix/manifolds/poincare.py
def tangent_proj(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Project vector v onto tangent space at point x."""
    return _tangent_proj(self._cast(v), self._cast(x), self._cast_c(c))

is_in_manifold

is_in_manifold(
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check if point x lies in Poincaré ball (atol default: :func:default_atol).

Source code in hyperbolix/manifolds/poincare.py
def is_in_manifold(self, x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None) -> Array:
    """Check if point x lies in Poincaré ball (``atol`` default: :func:`default_atol`)."""
    return _is_in_manifold(self._cast(x), self._cast_c(c), atol)

is_in_tangent_space

is_in_tangent_space(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check that v has finite entries (T_x B = R^d, so there is no other constraint).

Source code in hyperbolix/manifolds/poincare.py
def is_in_tangent_space(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None
) -> Array:
    """Check that v has finite entries (T_x B = R^d, so there is no other constraint)."""
    return _is_in_tangent_space(self._cast(v), self._cast(x), self._cast_c(c), atol)

conformal_factor

conformal_factor(
    x: Float[Array, "... dim"], c: ScalarCurvature
) -> Float[Array, "... 1"]

Numerically stable conformal factor lambda(x) = 2 / (1 - c||x||^2).

Batch-compatible version that handles arbitrary leading dimensions.

Source code in hyperbolix/manifolds/poincare.py
def conformal_factor(self, x: Float[Array, "... dim"], c: ScalarCurvature) -> Float[Array, "... 1"]:
    """Numerically stable conformal factor lambda(x) = 2 / (1 - c||x||^2).

    Batch-compatible version that handles arbitrary leading dimensions.
    """
    return _conformal_factor_batch(self._cast(x), self._cast_c(c))

embed_spatial_0

embed_spatial_0(
    v_spatial: Float[Array, "... n"],
) -> Float[Array, "... n"]

Identity embedding (the ball has no time coordinate). Kept for API parity.

Source code in hyperbolix/manifolds/poincare.py
def embed_spatial_0(self, v_spatial: Float[Array, "... n"]) -> Float[Array, "... n"]:
    """Identity embedding (the ball has no time coordinate). Kept for API parity."""
    return _embed_spatial_0(self._cast(v_spatial))

compute_mlr_pp

compute_mlr_pp(
    x: Float[Array, "batch in_dim"],
    z: Float[Array, "out_dim in_dim"],
    r: Float[Array, "out_dim 1"],
    c: ScalarCurvature,
    min_enorm: float = 1e-15,
) -> Float[Array, "batch out_dim"]

Compute HNN++ multinomial linear regression on the Poincare ball.

Source code in hyperbolix/manifolds/poincare.py
def compute_mlr_pp(
    self,
    x: Float[Array, "batch in_dim"],
    z: Float[Array, "out_dim in_dim"],
    r: Float[Array, "out_dim 1"],
    c: ScalarCurvature,
    min_enorm: float = 1e-15,
) -> Float[Array, "batch out_dim"]:
    """Compute HNN++ multinomial linear regression on the Poincare ball."""
    return _compute_mlr_pp(self._cast(x), self._cast(z), self._cast(r), self._cast_c(c), min_enorm)

beta_concat

beta_concat(
    points: Float[Array, "M n_i"], c: ScalarCurvature
) -> Float[Array, n]

Beta-concatenation of M equal-dimensional Poincaré ball points.

Source code in hyperbolix/manifolds/poincare.py
def beta_concat(self, points: Float[Array, "M n_i"], c: ScalarCurvature) -> Float[Array, "n"]:
    """Beta-concatenation of M equal-dimensional Poincaré ball points."""
    return _beta_concat(self._cast(points), self._cast_c(c))

busemann

busemann(
    x: Float[Array, dim],
    v: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Closed-form Poincaré Busemann function B^v(x) = (1/√c)·log(‖v - √c·x‖²/(1 - c‖x‖²)).

Point-to-horosphere coordinate (Chen et al. 2026, Eq. 3). v must be a unit direction — it is not normalized internally. Single point (d,) → scalar; use :func:jax.vmap for batching and over a direction set. B^v(origin) = 0, and it matches :meth:Hyperboloid.busemann under the Poincaré↔Hyperboloid isometry.

See Also

For an asymmetric quasimetric energy, compose this Busemann coordinate with an external Euclidean quasimetric (e.g. IQE/MRN). Do not reach for :meth:apollonian_dist expecting asymmetry — it is a coboundary (symmetrizes to √c·dist) and cannot deliver circulation.

Source code in hyperbolix/manifolds/poincare.py
def busemann(self, x: Float[Array, "dim"], v: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Closed-form Poincaré Busemann function ``B^v(x) = (1/√c)·log(‖v - √c·x‖²/(1 - c‖x‖²))``.

    Point-to-horosphere coordinate (Chen et al. 2026, Eq. 3). ``v`` must be a *unit*
    direction — it is **not** normalized internally. Single point ``(d,)`` → scalar; use
    :func:`jax.vmap` for batching and over a direction set. ``B^v(origin) = 0``, and it
    matches :meth:`Hyperboloid.busemann` under the Poincaré↔Hyperboloid isometry.

    See Also
    --------
    For an *asymmetric* quasimetric energy, compose this Busemann coordinate with an
    external Euclidean quasimetric (e.g. IQE/MRN). Do **not** reach for
    :meth:`apollonian_dist` expecting asymmetry — it is a coboundary (symmetrizes to
    ``√c·dist``) and cannot deliver circulation.
    """
    return _busemann(self._cast(x), self._cast(v), self._cast_c(c))

κ-Stereographic

A single constant-curvature manifold spanning hyperbolic, Euclidean, and spherical geometry via a signed curvature c (Bachmann et al. 2020). It generalizes the Poincaré ball across zero curvature using curvature-generalized ("\(\kappa\)-") trigonometric functions (\(\tan_\kappa\), \(\tan_\kappa^{-1}\)), enabling a network to learn the sign of curvature from data.

Signed-curvature convention (sectional curvature \(= -c\))

Unlike the other manifolds (which require \(c > 0\)), Stereographic takes a signed \(c\):

c sectional curvature geometry
\(> 0\) \(< 0\) hyperbolic — the Poincare(c) geometry (see below)
\(= 0\) \(0\) Euclidean (factor-2 limit; see below)
\(< 0\) \(> 0\) spherical (stereographic projection of the sphere)

Internally the paper's \(\kappa = -c\). This is sign-flipped from the paper/geoopt \(\kappa\) (their \(\kappa > 0\) = spherical), chosen so c matches every other hyperbolix manifold and so Stereographic(c) matches Poincare(c) for \(c > 0\). Most ops return Poincare's bits; dist, logmap, expmap, expmap_0, logmap_0 and scalar_mul agree only to rounding (see κ-Stereographic numerics).

The Euclidean limit carries a factor of 2

The conformal factor is \(\lambda^\kappa_x = 2/(1 - c\lVert x\rVert^2)\), so \(\lambda^\kappa_0 = 2\) and the metric at \(c = 0\) is \(4\cdot I\), not \(I\). As \(c \to 0\): addition/expmap/logmap reduce to the bare Euclidean \(x{+}y\) / \(x{+}v\) / \(y{-}x\), but dist \(\to 2\lVert x-y\rVert\) and tangent_norm \(\to 2\lVert v\rVert\) (paper Thm. 3). This matches Poincaré's own dist_0 \(\to 2\lVert x\rVert\), and therefore does not equal the separate Euclidean manifold's dist (bare metric \(I\)). Use Euclidean for un-scaled flat geometry; use Stereographic at \(c=0\) only as the continuous limit of the curved family.

Curvature derivatives at zero

The shared Möbius denominator evaluates separate signed factorizations on the \(c>0\) and \(c\le0\) sides. For nonzero operands they match the literal polynomial value and curvature derivative at \(c=0\); an exactly zero operand retains only the bounded residual from the existing MIN_NORM radial floor.

Scope

Provides the complete core Riemannian manifold — the Manifold protocol plus conformal_factor, gyration, geodesic, geodesic_unit, and antipode. The \(\kappa\)-GCN neural-network layers and building blocks (mobius_matvec, weighted gyromidpoint, dist2plane, sproj/inv_sproj) are not yet included. Signed learnable curvature — spanning hyperbolic/Euclidean/spherical — is available via LearnableCurvature(parameterization="identity") (with a symmetric default clamp around zero); the softplus/log parameterizations remain positive-only. Double precision (dtype=jnp.float64) is strongly recommended, per Bachmann et al.

hyperbolix.manifolds.stereographic.Stereographic

Stereographic(
    dtype: dtype = jnp.float32, *, c: float = 1.0
)

Bases: ManifoldBase

κ-Stereographic manifold (Bachmann et al. 2020) with automatic dtype casting.

A single constant-curvature manifold spanning hyperbolic, Euclidean, and spherical geometry via a signed curvature c (sectional curvature = -c): c > 0 hyperbolic (the geometry of :class:~hyperbolix.manifolds.Poincare; some ops agree with it only to rounding), c = 0 Euclidean (with the gyrovector factor-2 metric — see the module docstring), c < 0 spherical. See the module docstring for the full convention table, which ops match Poincare bit for bit, the Euclidean-limit factor-2 gotcha, and precision notes.

Args: dtype: Target JAX dtype for computations (default: jnp.float32; float64 recommended). c: Default (signed) curvature stored on the instance (default: 1.0, i.e. hyperbolic). The geometry methods take c explicitly per call, so this is metadata only.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import Stereographic >>> m = Stereographic(dtype=jnp.float64) >>> x, y = jnp.array([0.1, 0.2]), jnp.array([0.3, 0.4]) >>> m.dist(x, y, c=1.0) # hyperbolic >>> m.dist(x, y, c=-1.0) # spherical

Source code in hyperbolix/manifolds/stereographic.py
def __init__(self, dtype: jnp.dtype = jnp.float32, *, c: float = 1.0) -> None:
    super().__init__(dtype, c=c)

proj

proj(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Project point onto the manifold (identity for c ≤ 0).

Source code in hyperbolix/manifolds/stereographic.py
def proj(self, x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Project point onto the manifold (identity for ``c ≤ 0``)."""
    return _proj(self._cast(x), self._cast_c(c))

conformal_factor

conformal_factor(
    x: Float[Array, "... dim"], c: ScalarCurvature
) -> Float[Array, "... 1"]

Conformal factor λ^κ_x = 2/(1 - c‖x‖²), batch-compatible over arbitrary leading dims.

Source code in hyperbolix/manifolds/stereographic.py
def conformal_factor(self, x: Float[Array, "... dim"], c: ScalarCurvature) -> Float[Array, "... 1"]:
    """Conformal factor ``λ^κ_x = 2/(1 - c‖x‖²)``, batch-compatible over arbitrary leading dims."""
    return _conformal_factor_batch(self._cast(x), self._cast_c(c))

gyration

gyration(
    x: Float[Array, dim],
    y: Float[Array, dim],
    z: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Gyration gyr[x, y]z.

Source code in hyperbolix/manifolds/stereographic.py
def gyration(
    self, x: Float[Array, "dim"], y: Float[Array, "dim"], z: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Gyration ``gyr[x, y]z``."""
    return _gyration(self._cast(x), self._cast(y), self._cast(z), self._cast_c(c))

addition

addition(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

κ-Möbius gyrovector addition x ⊕_κ y (paper Eq. 2).

Source code in hyperbolix/manifolds/stereographic.py
def addition(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """κ-Möbius gyrovector addition ``x ⊕_κ y`` (paper Eq. 2)."""
    return _addition(self._cast(x), self._cast(y), self._cast_c(c))

scalar_mul

scalar_mul(
    r: float | Float[Array, ""],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

κ-scalar multiplication r ⊗_κ x (paper Eq. 3).

Source code in hyperbolix/manifolds/stereographic.py
def scalar_mul(self, r: float | Float[Array, ""], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """κ-scalar multiplication ``r ⊗_κ x`` (paper Eq. 3)."""
    x = self._cast(x)
    r_cast = jnp.asarray(r, dtype=x.dtype)
    return _scalar_mul(r_cast, x, self._cast_c(c))

dist

dist(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance d_κ(x, y) (paper Eq. 4). Note → 2‖x - y‖ as c → 0.

version_idx is accepted and ignored — there is a single κ-stereographic distance. It exists so manifold-generic callers that always forward one (e.g. hyperbolix.utils.helpers.compute_pairwise_distances) work here too.

Source code in hyperbolix/manifolds/stereographic.py
def dist(
    self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature, version_idx: int = VERSION_DEFAULT
) -> Float[Array, ""]:
    """Geodesic distance ``d_κ(x, y)`` (paper Eq. 4). Note ``→ 2‖x - y‖`` as ``c → 0``.

    ``version_idx`` is accepted and ignored — there is a single κ-stereographic distance.
    It exists so manifold-generic callers that always forward one (e.g.
    ``hyperbolix.utils.helpers.compute_pairwise_distances``) work here too.
    """
    del version_idx
    return _dist(self._cast(x), self._cast(y), self._cast_c(c))

dist_0

dist_0(
    x: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance to the origin d_κ(0, x) (version_idx accepted and ignored).

Note → 2‖x‖ as c → 0.

Source code in hyperbolix/manifolds/stereographic.py
def dist_0(self, x: Float[Array, "dim"], c: ScalarCurvature, version_idx: int = VERSION_DEFAULT) -> Float[Array, ""]:
    """Geodesic distance to the origin ``d_κ(0, x)`` (``version_idx`` accepted and ignored).

    Note ``→ 2‖x‖`` as ``c → 0``.
    """
    del version_idx
    return _dist_0(self._cast(x), self._cast_c(c))

expmap

expmap(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Exponential map exp^κ_x(v) (paper Eq. 6).

Source code in hyperbolix/manifolds/stereographic.py
def expmap(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map ``exp^κ_x(v)`` (paper Eq. 6)."""
    return _expmap(self._cast(v), self._cast(x), self._cast_c(c))

expmap_0

expmap_0(
    v: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Exponential map at the origin exp^κ_0(v).

Source code in hyperbolix/manifolds/stereographic.py
def expmap_0(self, v: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map at the origin ``exp^κ_0(v)``."""
    return _expmap_0(self._cast(v), self._cast_c(c))

retraction

retraction(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

First-order retraction proj(x + v).

Source code in hyperbolix/manifolds/stereographic.py
def retraction(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """First-order retraction ``proj(x + v)``."""
    return _retraction(self._cast(v), self._cast(x), self._cast_c(c))

logmap

logmap(
    y: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Logarithmic map log^κ_x(y) (paper Eq. 7).

Source code in hyperbolix/manifolds/stereographic.py
def logmap(self, y: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map ``log^κ_x(y)`` (paper Eq. 7)."""
    return _logmap(self._cast(y), self._cast(x), self._cast_c(c))

logmap_0

logmap_0(
    y: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Logarithmic map at the origin log^κ_0(y).

Source code in hyperbolix/manifolds/stereographic.py
def logmap_0(self, y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map at the origin ``log^κ_0(y)``."""
    return _logmap_0(self._cast(y), self._cast_c(c))

ptransp

ptransp(
    v: Float[Array, dim],
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport v from x to y.

Source code in hyperbolix/manifolds/stereographic.py
def ptransp(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Parallel transport ``v`` from ``x`` to ``y``."""
    return _ptransp(self._cast(v), self._cast(x), self._cast(y), self._cast_c(c))

ptransp_0

ptransp_0(
    v: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport v from the origin to y.

Source code in hyperbolix/manifolds/stereographic.py
def ptransp_0(self, v: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Parallel transport ``v`` from the origin to ``y``."""
    return _ptransp_0(self._cast(v), self._cast(y), self._cast_c(c))

tangent_inner

tangent_inner(
    u: Float[Array, dim],
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Riemannian inner product ⟨u, v⟩_x.

Source code in hyperbolix/manifolds/stereographic.py
def tangent_inner(
    self, u: Float[Array, "dim"], v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, ""]:
    """Riemannian inner product ``⟨u, v⟩_x``."""
    return _tangent_inner(self._cast(u), self._cast(v), self._cast(x), self._cast_c(c))

tangent_norm

tangent_norm(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Riemannian norm ‖v‖_x.

Source code in hyperbolix/manifolds/stereographic.py
def tangent_norm(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Riemannian norm ``‖v‖_x``."""
    return _tangent_norm(self._cast(v), self._cast(x), self._cast_c(c))

egrad2rgrad

egrad2rgrad(
    grad: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Euclidean → Riemannian gradient.

Source code in hyperbolix/manifolds/stereographic.py
def egrad2rgrad(self, grad: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Euclidean → Riemannian gradient."""
    return _egrad2rgrad(self._cast(grad), self._cast(x), self._cast_c(c))

tangent_proj

tangent_proj(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Project v onto the tangent space at x (identity).

Source code in hyperbolix/manifolds/stereographic.py
def tangent_proj(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Project ``v`` onto the tangent space at ``x`` (identity)."""
    return _tangent_proj(self._cast(v), self._cast(x), self._cast_c(c))

is_in_manifold

is_in_manifold(
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check whether x lies on the manifold (atol default: :func:default_atol).

Source code in hyperbolix/manifolds/stereographic.py
def is_in_manifold(self, x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None) -> Array:
    """Check whether ``x`` lies on the manifold (``atol`` default: :func:`default_atol`)."""
    return _is_in_manifold(self._cast(x), self._cast_c(c), atol)

is_in_tangent_space

is_in_tangent_space(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check that v has finite entries (the tangent space is all of R^d).

Source code in hyperbolix/manifolds/stereographic.py
def is_in_tangent_space(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None
) -> Array:
    """Check that ``v`` has finite entries (the tangent space is all of R^d)."""
    return _is_in_tangent_space(self._cast(v), self._cast(x), self._cast_c(c), atol)

geodesic

geodesic(
    t: Float[Array, ""],
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Point at time t on the geodesic through x and y (paper Eq. 5).

Source code in hyperbolix/manifolds/stereographic.py
def geodesic(
    self, t: Float[Array, ""], x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Point at time ``t`` on the geodesic through ``x`` and ``y`` (paper Eq. 5)."""
    x = self._cast(x)
    t_cast = jnp.asarray(t, dtype=x.dtype)
    return _geodesic(t_cast, x, self._cast(y), self._cast_c(c))

geodesic_unit

geodesic_unit(
    t: Float[Array, ""],
    x: Float[Array, dim],
    u: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Point at time t on the unit-speed geodesic from x in direction u.

Source code in hyperbolix/manifolds/stereographic.py
def geodesic_unit(
    self, t: Float[Array, ""], x: Float[Array, "dim"], u: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Point at time ``t`` on the unit-speed geodesic from ``x`` in direction ``u``."""
    x = self._cast(x)
    t_cast = jnp.asarray(t, dtype=x.dtype)
    return _geodesic_unit(t_cast, x, self._cast(u), self._cast_c(c))

antipode

antipode(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Antipode of x (diametrically-opposite point for c < 0; -x otherwise).

Source code in hyperbolix/manifolds/stereographic.py
def antipode(self, x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Antipode of ``x`` (diametrically-opposite point for ``c < 0``; ``-x`` otherwise)."""
    return _antipode(self._cast(x), self._cast_c(c))

Hyperboloid

The hyperboloid (Lorentz) model with Minkowski geometry.

Distance Versions

The Hyperboloid dist method has a version_idx parameter selecting between 2 formulations:

  • VERSION_DEFAULT (0): cancellation-free hyperbolic-haversine distance (default; see the measured range and remaining input-representation limits in the numerical-stability guide)
  • VERSION_SMOOTHENED (1): same evaluation, with a strictly-positive floor at coincidence

The same two slots select an arm of dist_0, which is a separate implementation:

  • VERSION_DEFAULT (0): arcsinh(√c·‖x_s‖)/√c, read off the spatial part (default, with no domain clamp)
  • VERSION_SMOOTHENED (1): the same with ‖x_s‖ floored in quadrature, giving a floor of arcsinh(20·eps)/√c (≈2.4e-6/√c float32, ≈4.4e-15/√c float64)

A version_idx outside {0, 1} raises ValueError.

Constants are available as hyperboloid.VERSION_DEFAULT etc., or from hyperbolix.manifolds.hyperboloid. See the numerical-stability guide for when to use each, the cancellation failure mode VERSION_DEFAULT fixes, and the origin-chart rewrite behind the dist_0 arms.

Lorentz Operations

The Hyperboloid class includes specialized operations for convolutional layers:

  • lorentz_boost: Lorentz boost transformation
  • hcat: Lorentz direct concatenation for convolutions
  • log_radius_concat: log-radius–preserving concatenation (digamma-scaled hcat; Shi et al. 2026, Sec. 4.3)

Origin derivatives

gyro_difference and ptransp use Cartesian formulas when either endpoint's scaled spatial radius is at most 1e-1, and retain the stable polar frame otherwise. logmap uses the regular Cartesian expression at an exact origin endpoint and the stable polar frame otherwise. Ordinary autodiff preserves derivatives with respect to an origin endpoint. busemann uses a projected-coordinate branch whose value and constrained first derivative agree at its branch surface. See Origin derivatives and the Cartesian chart.

hyperbolix.manifolds.hyperboloid.Hyperboloid

Hyperboloid(dtype: dtype = jnp.float32, *, c: float = 1.0)

Bases: ManifoldBase

Hyperboloid manifold with automatic dtype casting.

Provides all manifold operations with automatic casting of array inputs to the specified dtype. This eliminates the need for manual casting and provides better numerical stability control.

Args: dtype: Target JAX dtype for computations (default: jnp.float32) c: Curvature value (default: 1.0). Must be positive.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds.hyperboloid import Hyperboloid, VERSION_DEFAULT >>> >>> # Create manifold with float64 for better precision >>> manifold = Hyperboloid(dtype=jnp.float64) >>> >>> # Custom curvature >>> manifold = Hyperboloid(c=0.5) >>> c = manifold.c # returns 0.5

Source code in hyperbolix/manifolds/_base.py
def __init__(
    self,
    dtype: jnp.dtype = jnp.float32,
    *,
    c: float = 1.0,
) -> None:
    self.dtype = dtype
    self._c_val = c

create_origin

create_origin(
    c: ScalarCurvature, dim: int
) -> Float[Array, dim_plus_1]

Create hyperboloid origin [1/√c, 0, ..., 0].

Source code in hyperbolix/manifolds/hyperboloid.py
def create_origin(self, c: ScalarCurvature, dim: int) -> Float[Array, "dim_plus_1"]:
    """Create hyperboloid origin [1/√c, 0, ..., 0]."""
    return _create_origin(self._cast_c(c), dim, self.dtype)

minkowski_inner

minkowski_inner(
    x: Float[Array, dim_plus_1], y: Float[Array, dim_plus_1]
) -> Float[Array, ""]

Compute Minkowski inner product ⟨x, y⟩_L = -x₀y₀ + ⟨x_rest, y_rest⟩.

This is the literal form -x₀·y₀ + ⟨x_s, y_s⟩, whose two terms are each O(cosh²(a)/c) and cancel, so the absolute rounding error is about eps·cosh²(a)/c (float32: 0.26 at a = 8, reaching 1 at a ≈ 8.7 for c = 1). Nothing inside the library calls it; do not use it to recover ⟨x, x⟩_L = -1/c, to check manifold membership, or to form distances — use dist/sqdist/tangent_inner/is_in_manifold, which are cancellation-free (see docs/user-guide/numerical-stability.md).

Source code in hyperbolix/manifolds/hyperboloid.py
def minkowski_inner(self, x: Float[Array, "dim_plus_1"], y: Float[Array, "dim_plus_1"]) -> Float[Array, ""]:
    """Compute Minkowski inner product ⟨x, y⟩_L = -x₀y₀ + ⟨x_rest, y_rest⟩.

    This is the literal form ``-x₀·y₀ + ⟨x_s, y_s⟩``, whose two terms are each
    ``O(cosh²(a)/c)`` and cancel, so the absolute rounding error is about ``eps·cosh²(a)/c``
    (float32: 0.26 at ``a = 8``, reaching 1 at ``a ≈ 8.7`` for ``c = 1``). Nothing inside the library calls it; do not
    use it to recover ``⟨x, x⟩_L = -1/c``, to check manifold membership, or to form distances —
    use ``dist``/``sqdist``/``tangent_inner``/``is_in_manifold``, which are cancellation-free
    (see ``docs/user-guide/numerical-stability.md``).
    """
    return _minkowski_inner(self._cast(x), self._cast(y))

proj

proj(
    x: Float[Array, dim_plus_1], c: ScalarCurvature
) -> Float[Array, dim_plus_1]

Project point onto hyperboloid.

Source code in hyperbolix/manifolds/hyperboloid.py
def proj(self, x: Float[Array, "dim_plus_1"], c: ScalarCurvature) -> Float[Array, "dim_plus_1"]:
    """Project point onto hyperboloid."""
    return _proj(self._cast(x), self._cast_c(c))

proj_batch

proj_batch(
    x: Float[Array, "... dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "... dim_plus_1"]

Project batched points onto hyperboloid (handles arbitrary leading dimensions).

Source code in hyperbolix/manifolds/hyperboloid.py
def proj_batch(self, x: Float[Array, "... dim_plus_1"], c: ScalarCurvature) -> Float[Array, "... dim_plus_1"]:
    """Project batched points onto hyperboloid (handles arbitrary leading dimensions)."""
    return _proj_batch(self._cast(x), self._cast_c(c))

addition

addition(
    x: Float[Array, dim_plus_1],
    y: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Lorentz gyrovector addition x ⊕ y = Exp_x(PT_{0→x}(Log_0(y))).

The intrinsic Lorentz addition of Chen et al. (2025b) / Shi et al. (2026, Eq. 1). Forms a gyrocommutative gyrogroup with identity = origin and inverse ⊖x = (-1) ⊙ x = [x₀, -x_s]; matches Poincaré Möbius addition under the stereographic isometry. scalar_mul provides the companion gyro scaling (Eq. 2).

Source code in hyperbolix/manifolds/hyperboloid.py
def addition(
    self, x: Float[Array, "dim_plus_1"], y: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Lorentz gyrovector addition ``x ⊕ y = Exp_x(PT_{0→x}(Log_0(y)))``.

    The intrinsic Lorentz addition of Chen et al. (2025b) / Shi et al. (2026, Eq. 1).
    Forms a gyrocommutative gyrogroup with identity = origin and inverse
    ``⊖x = (-1) ⊙ x = [x₀, -x_s]``; matches Poincaré Möbius addition under the
    stereographic isometry. ``scalar_mul`` provides the companion gyro scaling (Eq. 2).
    """
    return _addition(self._cast(x), self._cast(y), self._cast_c(c))

gyro_difference

gyro_difference(
    x: Float[Array, dim_plus_1],
    y: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Gyro-difference (⊖x) ⊕ y, evaluated without the ambient cancellation.

Mathematically identical to addition(scalar_mul(-1, x), y); use this whenever the result is expected much closer to the origin than the operands (centering a batch, differences, distances between far points). See :func:_gyro_difference.

Source code in hyperbolix/manifolds/hyperboloid.py
def gyro_difference(
    self, x: Float[Array, "dim_plus_1"], y: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Gyro-difference ``(⊖x) ⊕ y``, evaluated without the ambient cancellation.

    Mathematically identical to ``addition(scalar_mul(-1, x), y)``; use this whenever the
    result is expected much closer to the origin than the operands (centering a batch,
    differences, distances between far points). See :func:`_gyro_difference`.
    """
    return _gyro_difference(self._cast(x), self._cast(y), self._cast_c(c))

scalar_mul

scalar_mul(
    r: float | Float[Array, ""],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Scalar multiplication on hyperboloid.

Source code in hyperbolix/manifolds/hyperboloid.py
def scalar_mul(
    self, r: float | Float[Array, ""], x: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Scalar multiplication on hyperboloid."""
    x = self._cast(x)
    r_cast = jnp.asarray(r, dtype=x.dtype)
    return _scalar_mul(r_cast, x, self._cast_c(c))  # type: ignore[arg-type]

dist

dist(
    x: Float[Array, dim_plus_1],
    y: Float[Array, dim_plus_1],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Compute geodesic distance between hyperboloid points.

Source code in hyperbolix/manifolds/hyperboloid.py
def dist(
    self,
    x: Float[Array, "dim_plus_1"],
    y: Float[Array, "dim_plus_1"],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]:
    """Compute geodesic distance between hyperboloid points."""
    return _dist(self._cast(x), self._cast(y), self._cast_c(c), version_idx)

dist_0

dist_0(
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance from the origin, arcsinh(√c·‖x_s‖)/√c.

Read off the spatial part; x₀ is ignored, so an off-sheet input gets the radius of its :meth:proj projection (the same convention proj itself follows). A raw jax.grad of this therefore has its support on x_s rather than x₀; the two differ by a multiple of the constraint normal, so the Riemannian gradient after :meth:egrad2rgrad / :meth:tangent_proj is identical and optimizers are unaffected.

Source code in hyperbolix/manifolds/hyperboloid.py
def dist_0(
    self, x: Float[Array, "dim_plus_1"], c: ScalarCurvature, version_idx: int = VERSION_DEFAULT
) -> Float[Array, ""]:
    """Geodesic distance from the origin, ``arcsinh(√c·‖x_s‖)/√c``.

    Read off the **spatial** part; ``x₀`` is ignored, so an off-sheet input gets the radius of
    its :meth:`proj` projection (the same convention ``proj`` itself follows). A raw
    ``jax.grad`` of this therefore has its support on ``x_s`` rather than ``x₀``; the two
    differ by a multiple of the constraint normal, so the Riemannian gradient after
    :meth:`egrad2rgrad` / :meth:`tangent_proj` is identical and optimizers are unaffected.

    """
    return _dist_0(self._cast(x), self._cast_c(c), version_idx)

sqdist

sqdist(
    x: Float[Array, dim_plus_1],
    y: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, ""]

Squared Lorentzian distance d_L²(x, y) = -2/c - 2⟨x,y⟩_L (Law et al. 2019).

That is the mathematical definition; it is now evaluated cancellation-free as d_L² = 4·sinh²(√c·d(x,y)/2)/c off the :func:_polar_frame decomposition instead of the literal -2/c - 2⟨x,y⟩_L subtraction, which loses precision the same way the old acosh form did (see :func:_sqdist's docstring for the full derivation).

A fast, acosh-free dissimilarity that is monotone in the geodesic :meth:dist (d_L² = (2/c)(cosh(√c·d) - 1)) but is not the squared geodesic distance and not a true metric. Prefer it where a smooth monotone distance proxy suffices (contrastive / commitment / attention scores); use :meth:dist when the geodesic length is required.

Source code in hyperbolix/manifolds/hyperboloid.py
def sqdist(self, x: Float[Array, "dim_plus_1"], y: Float[Array, "dim_plus_1"], c: ScalarCurvature) -> Float[Array, ""]:
    """Squared Lorentzian distance ``d_L²(x, y) = -2/c - 2⟨x,y⟩_L`` (Law et al. 2019).

    That is the mathematical definition; it is now evaluated cancellation-free as
    ``d_L² = 4·sinh²(√c·d(x,y)/2)/c`` off the :func:`_polar_frame` decomposition instead of the
    literal ``-2/c - 2⟨x,y⟩_L`` subtraction, which loses precision the same way the old
    ``acosh`` form did (see :func:`_sqdist`'s docstring for the full derivation).

    A fast, ``acosh``-free dissimilarity that is monotone in the geodesic :meth:`dist`
    (``d_L² = (2/c)(cosh(√c·d) - 1)``) but is **not** the squared geodesic distance and **not**
    a true metric. Prefer it where a smooth monotone distance proxy suffices (contrastive /
    commitment / attention scores); use :meth:`dist` when the geodesic length is required.
    """
    return _sqdist(self._cast(x), self._cast(y), self._cast_c(c))

expmap

expmap(
    v: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Exponential map: map tangent vector v at point x to manifold.

Source code in hyperbolix/manifolds/hyperboloid.py
def expmap(
    self, v: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Exponential map: map tangent vector v at point x to manifold."""
    return _expmap(self._cast(v), self._cast(x), self._cast_c(c))

expmap_0

expmap_0(
    v: Float[Array, dim_plus_1], c: ScalarCurvature
) -> Float[Array, dim_plus_1]

Exponential map from origin.

Source code in hyperbolix/manifolds/hyperboloid.py
def expmap_0(self, v: Float[Array, "dim_plus_1"], c: ScalarCurvature) -> Float[Array, "dim_plus_1"]:
    """Exponential map from origin."""
    return _expmap_0(self._cast(v), self._cast_c(c))

retraction

retraction(
    v: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Retraction: first-order approximation of exponential map.

Source code in hyperbolix/manifolds/hyperboloid.py
def retraction(
    self, v: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Retraction: first-order approximation of exponential map."""
    return _retraction(self._cast(v), self._cast(x), self._cast_c(c))

logmap

logmap(
    y: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Logarithmic map: map point y to tangent space at point x.

Source code in hyperbolix/manifolds/hyperboloid.py
def logmap(
    self, y: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Logarithmic map: map point y to tangent space at point x."""
    return _logmap(self._cast(y), self._cast(x), self._cast_c(c))

logmap_0

logmap_0(
    y: Float[Array, dim_plus_1], c: ScalarCurvature
) -> Float[Array, dim_plus_1]

Logarithmic map from the origin, [0, arcsinh(√c‖y_s‖)/(√c‖y_s‖) · y_s].

Like :meth:dist_0 it reads the radius off the spatial part and ignores y₀, so an off-sheet input is treated as its :meth:proj projection. ‖log_0(y)‖ = dist_0(y) holds by construction at every radius.

Source code in hyperbolix/manifolds/hyperboloid.py
def logmap_0(self, y: Float[Array, "dim_plus_1"], c: ScalarCurvature) -> Float[Array, "dim_plus_1"]:
    """Logarithmic map from the origin, ``[0, arcsinh(√c‖y_s‖)/(√c‖y_s‖) · y_s]``.

    Like :meth:`dist_0` it reads the radius off the **spatial** part and ignores ``y₀``, so an
    off-sheet input is treated as its :meth:`proj` projection. ``‖log_0(y)‖ = dist_0(y)`` holds
    by construction at every radius.
    """
    return _logmap_0(self._cast(y), self._cast_c(c))

ptransp

ptransp(
    v: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    y: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Parallel transport tangent vector v from point x to point y.

Source code in hyperbolix/manifolds/hyperboloid.py
def ptransp(
    self, v: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], y: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Parallel transport tangent vector v from point x to point y."""
    return _ptransp(self._cast(v), self._cast(x), self._cast(y), self._cast_c(c))

ptransp_0

ptransp_0(
    v: Float[Array, dim_plus_1],
    y: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Parallel transport tangent vector v from origin to point y.

Source code in hyperbolix/manifolds/hyperboloid.py
def ptransp_0(
    self, v: Float[Array, "dim_plus_1"], y: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Parallel transport tangent vector v from origin to point y."""
    return _ptransp_0(self._cast(v), self._cast(y), self._cast_c(c))

tangent_inner

tangent_inner(
    u: Float[Array, dim_plus_1],
    v: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, ""]

Compute inner product of tangent vectors u and v at point x.

Source code in hyperbolix/manifolds/hyperboloid.py
def tangent_inner(
    self, u: Float[Array, "dim_plus_1"], v: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, ""]:
    """Compute inner product of tangent vectors u and v at point x."""
    return _tangent_inner(self._cast(u), self._cast(v), self._cast(x), self._cast_c(c))

tangent_norm

tangent_norm(
    v: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, ""]

Compute norm of tangent vector v at point x.

Source code in hyperbolix/manifolds/hyperboloid.py
def tangent_norm(
    self, v: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, ""]:
    """Compute norm of tangent vector v at point x."""
    return _tangent_norm(self._cast(v), self._cast(x), self._cast_c(c))

egrad2rgrad

egrad2rgrad(
    grad: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Convert Euclidean gradient to Riemannian gradient.

Source code in hyperbolix/manifolds/hyperboloid.py
def egrad2rgrad(
    self, grad: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Convert Euclidean gradient to Riemannian gradient."""
    return _egrad2rgrad(self._cast(grad), self._cast(x), self._cast_c(c))

tangent_proj

tangent_proj(
    v: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
) -> Float[Array, dim_plus_1]

Project vector v onto tangent space at point x.

Source code in hyperbolix/manifolds/hyperboloid.py
def tangent_proj(
    self, v: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], c: ScalarCurvature
) -> Float[Array, "dim_plus_1"]:
    """Project vector v onto tangent space at point x."""
    return _tangent_proj(self._cast(v), self._cast(x), self._cast_c(c))

is_in_manifold

is_in_manifold(
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check if point x lies on hyperboloid (atol default: :func:default_atol).

Source code in hyperbolix/manifolds/hyperboloid.py
def is_in_manifold(self, x: Float[Array, "dim_plus_1"], c: ScalarCurvature, atol: float | None = None) -> Array:
    """Check if point x lies on hyperboloid (``atol`` default: :func:`default_atol`)."""
    return _is_in_manifold(self._cast(x), self._cast_c(c), atol)

is_in_tangent_space

is_in_tangent_space(
    v: Float[Array, dim_plus_1],
    x: Float[Array, dim_plus_1],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check if vector v lies in tangent space at point x (atol default: :func:default_atol).

Source code in hyperbolix/manifolds/hyperboloid.py
def is_in_tangent_space(
    self, v: Float[Array, "dim_plus_1"], x: Float[Array, "dim_plus_1"], c: ScalarCurvature, atol: float | None = None
) -> Array:
    """Check if vector v lies in tangent space at point x (``atol`` default: :func:`default_atol`)."""
    return _is_in_tangent_space(self._cast(v), self._cast(x), self._cast_c(c), atol)

hcat

hcat(
    points: Float[Array, "N n"], c: ScalarCurvature = 1.0
) -> Float[Array, dN_plus_1]

Hyperbolic concatenation of N points into one point.

Source code in hyperbolix/manifolds/hyperboloid.py
def hcat(
    self,
    points: Float[Array, "N n"],
    c: ScalarCurvature = 1.0,
) -> Float[Array, "dN_plus_1"]:
    """Hyperbolic concatenation of N points into one point."""
    return _hcat(self._cast(points), self._cast_c(c))

log_radius_concat

log_radius_concat(
    points: Float[Array, "N n"], c: ScalarCurvature = 1.0
) -> Float[Array, dN_plus_1]

Log-radius-preserving concatenation of N points (Shi et al. 2026, Sec. 4.3).

Like :meth:hcat, but shrinks each block's spatial part by the digamma factor s = exp(½·(ψ(d/2) - ψ(N·d/2))) ≈ 1/√N so the expected log spatial radius is invariant to the number of concatenated blocks. Reduces to :meth:hcat when N == 1.

Source code in hyperbolix/manifolds/hyperboloid.py
def log_radius_concat(
    self,
    points: Float[Array, "N n"],
    c: ScalarCurvature = 1.0,
) -> Float[Array, "dN_plus_1"]:
    """Log-radius-preserving concatenation of N points (Shi et al. 2026, Sec. 4.3).

    Like :meth:`hcat`, but shrinks each block's spatial part by the digamma factor
    ``s = exp(½·(ψ(d/2) - ψ(N·d/2))) ≈ 1/√N`` so the expected log spatial radius is
    invariant to the number of concatenated blocks. Reduces to :meth:`hcat` when
    ``N == 1``.
    """
    return _log_radius_concat(self._cast(points), self._cast_c(c))

embed_spatial_0

embed_spatial_0(
    v_spatial: Float[Array, "... n"],
) -> Float[Array, "... n_plus_1"]

Embed spatial vector as tangent vector at origin.

Source code in hyperbolix/manifolds/hyperboloid.py
def embed_spatial_0(self, v_spatial: Float[Array, "... n"]) -> Float[Array, "... n_plus_1"]:
    """Embed spatial vector as tangent vector at origin."""
    return _embed_spatial_0(self._cast(v_spatial))

compute_mlr

compute_mlr(
    x: Float[Array, "batch in_dim"],
    z: Float[Array, "out_dim in_dim_minus_1"],
    r: Float[Array, "out_dim 1"],
    c: ScalarCurvature,
    min_enorm: float = 1e-15,
) -> Float[Array, "batch out_dim"]

Compute multinomial linear regression on hyperboloid.

Source code in hyperbolix/manifolds/hyperboloid.py
def compute_mlr(
    self,
    x: Float[Array, "batch in_dim"],
    z: Float[Array, "out_dim in_dim_minus_1"],
    r: Float[Array, "out_dim 1"],
    c: ScalarCurvature,
    min_enorm: float = 1e-15,
) -> Float[Array, "batch out_dim"]:
    """Compute multinomial linear regression on hyperboloid."""
    return _compute_mlr(self._cast(x), self._cast(z), self._cast(r), self._cast_c(c), min_enorm)

busemann

busemann(
    x: Float[Array, dim_plus_1],
    v: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Closed-form Lorentz Busemann function B^v(x) = (1/√c)·log(√c·(x_t - ⟨x_s, v⟩)).

Point-to-horosphere coordinate (Chen et al. 2026, Eq. 4). v must be a unit spatial direction (dim d) — it is not normalized internally. Single point (d+1,) → scalar; use :func:jax.vmap for batching and over a direction set. B^v(origin) = 0.

See Also

For an asymmetric quasimetric energy, compose this Busemann coordinate with an external Euclidean quasimetric (e.g. IQE/MRN). Do not reach for :meth:Poincare.apollonian_dist expecting asymmetry — it is a coboundary (symmetrizes to √c·dist) and cannot deliver circulation.

Source code in hyperbolix/manifolds/hyperboloid.py
def busemann(self, x: Float[Array, "dim_plus_1"], v: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Closed-form Lorentz Busemann function ``B^v(x) = (1/√c)·log(√c·(x_t - ⟨x_s, v⟩))``.

    Point-to-horosphere coordinate (Chen et al. 2026, Eq. 4). ``v`` must be a *unit*
    spatial direction (dim ``d``) — it is **not** normalized internally. Single point
    ``(d+1,)`` → scalar; use :func:`jax.vmap` for batching and over a direction set.
    ``B^v(origin) = 0``.

    See Also
    --------
    For an *asymmetric* quasimetric energy, compose this Busemann coordinate with an
    external Euclidean quasimetric (e.g. IQE/MRN). Do **not** reach for
    :meth:`Poincare.apollonian_dist` expecting asymmetry — it is a coboundary
    (symmetrizes to ``√c·dist``) and cannot deliver circulation.
    """
    return _busemann(self._cast(x), self._cast(v), self._cast_c(c))

lorentz_boost

lorentz_boost(
    mu: Float[Array, dim_plus_1], c: ScalarCurvature
) -> Float[Array, "dim_plus_1 dim_plus_1"]

Lorentz boost matrix B with B @ mu = origin (sends mu to the origin).

Symmetric, proper, orthochronous Lorentz transformation. Boost a batch of row-vector points with x_NA @ B.T followed by :meth:proj_batch; the inverse boost is the boost of [mu₀, -mu_s]. Used to Fréchet-mean-center data for HoroPCA (Chami et al. 2021). See :func:_lorentz_boost.

Source code in hyperbolix/manifolds/hyperboloid.py
def lorentz_boost(self, mu: Float[Array, "dim_plus_1"], c: ScalarCurvature) -> Float[Array, "dim_plus_1 dim_plus_1"]:
    """Lorentz boost matrix ``B`` with ``B @ mu = origin`` (sends ``mu`` to the origin).

    Symmetric, proper, orthochronous Lorentz transformation. Boost a batch of
    row-vector points with ``x_NA @ B.T`` followed by :meth:`proj_batch`; the inverse
    boost is the boost of ``[mu₀, -mu_s]``. Used to Fréchet-mean-center data for
    HoroPCA (Chami et al. 2021). See :func:`_lorentz_boost`.
    """
    return _lorentz_boost(self._cast(mu), self._cast_c(c))

Proper Velocity

The Proper Velocity (PV) model — an unconstrained \(\mathbb{R}^n\) representation of hyperbolic geometry rooted in special relativity's proper velocity (Ungar 2022, Ch. 10). PV is algebraically a gyrovector space isomorphic to the Poincaré ball via \(\pi(x) = (\beta_x / (1 + \beta_x)) \cdot x\), and carries a Riemannian metric making that isomorphism an isometry.

Why Proper Velocity?

Unlike the bounded Poincaré ball (points must stay in the open unit ball) and the constrained hyperboloid (points must satisfy \(\langle x, x \rangle_L = -1/c\)), PV points live in all of \(\mathbb{R}^n\) with no constraint. This gives:

  • No projection step after updates — the manifold is \(\mathbb{R}^n\)
  • No boundary and no constraint to drift from; accuracy equals the hyperboloid's, since the pairwise ops go through it
  • Drop-in with Euclidean optimizers — the retraction reduces to \(x + v\)

The metric \(g_x(u,v) = \langle u, v\rangle - c\beta_x^2\langle x,u\rangle\langle x,v\rangle\) still gives sectional curvature \(-c\); only the coordinates change.

Convention

The paper uses curvature \(K < 0\) with \(\beta_x = 1/\sqrt{1 - K\|x\|^2}\). Hyperbolix keeps the \(c > 0\) convention (sectional curvature \(-c\)), substituting \(K = -c\), so \(\beta_x = 1/\sqrt{1 + c\|x\|^2}\).

Exact hyperboloid bridges

dist, logmap, expmap, gyro addition, gyro_difference, and ptransp evaluate through the direct isometry \(x\mapsto(\sqrt{1/c+\lVert x\rVert^2},x)\). For tangent operations, \(v\in T_x\) lifts to \((\langle x,v\rangle/X_0,v)\). The PV result is the spatial part of the hyperboloid result; no Poincaré chart conversion is used. gyro_difference, ptransp, and logmap inherit the hyperboloid's exact-origin Cartesian branch and its origin derivatives. ProperVelocityGyroBatchNorm centers with gyro_difference. See ProperVelocity operation bridges.

hyperbolix.manifolds.proper_velocity.ProperVelocity

ProperVelocity(
    dtype: dtype = jnp.float32, *, c: float = 1.0
)

Bases: ManifoldBase

Proper Velocity (PV) manifold with automatic dtype casting.

PV is an unconstrained representation of hyperbolic geometry rooted in special relativity's proper velocity (Ungar 2022, Ch. 10). Points live in R^n without any manifold constraint, which gives better numerical stability for large radii than the bounded Poincaré ball or the constrained hyperboloid (Chen et al. 2026, Tables 1-3).

Args: dtype: Target JAX dtype for computations (default: jnp.float32). c: Curvature value (default: 1.0). Must be positive.

Examples: >>> import jax >>> import jax.numpy as jnp >>> from hyperbolix.manifolds.proper_velocity import ProperVelocity >>> >>> manifold = ProperVelocity(dtype=jnp.float64) >>> x = jnp.array([0.1, 0.2], dtype=jnp.float32) >>> y = jnp.array([0.3, 0.4], dtype=jnp.float32) >>> with jax.enable_x64(True): # float64 needs x64 enabled ... d = manifold.dist(x, y, c=1.0) >>> d.dtype dtype('float64')

Source code in hyperbolix/manifolds/_base.py
def __init__(
    self,
    dtype: jnp.dtype = jnp.float32,
    *,
    c: float = 1.0,
) -> None:
    self.dtype = dtype
    self._c_val = c

create_origin

create_origin(
    c: ScalarCurvature, dim: int
) -> Float[Array, dim]

Create the PV origin (zero vector in R^n).

Source code in hyperbolix/manifolds/proper_velocity.py
def create_origin(self, c: ScalarCurvature, dim: int) -> Float[Array, "dim"]:
    """Create the PV origin (zero vector in R^n)."""
    return _create_origin(self._cast_c(c), dim, self.dtype)

beta

beta(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, ""]

PV beta factor β_x = 1/√(1 + c·||x||²).

Source code in hyperbolix/manifolds/proper_velocity.py
def beta(self, x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """PV beta factor β_x = 1/√(1 + c·||x||²)."""
    return _beta(self._cast(x), self._cast_c(c))

proj

proj(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Projection onto PV: the identity (PV is R^n; non-finite entries pass through).

Source code in hyperbolix/manifolds/proper_velocity.py
def proj(self, x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Projection onto PV: the identity (PV is R^n; non-finite entries pass through)."""
    return _proj(self._cast(x), self._cast_c(c))

addition

addition(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

PV gyroaddition x ⊕_U y.

Source code in hyperbolix/manifolds/proper_velocity.py
def addition(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """PV gyroaddition x ⊕_U y."""
    return _addition(self._cast(x), self._cast(y), self._cast_c(c))

gyro_difference

gyro_difference(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

PV gyro-difference (⊖x) ⊕ y, evaluated without the ambient cancellation.

Mathematically identical to addition(scalar_mul(-1, x), y); use this whenever the result is expected much closer to the origin than the operands (centering a batch, differences of two far points). The exact hyperboloid lift uses a Cartesian inverse boost when either endpoint's scaled spatial radius is at most 1e-1 and the stable polar frame otherwise. See :func:_gyro_difference.

Source code in hyperbolix/manifolds/proper_velocity.py
def gyro_difference(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """PV gyro-difference ``(⊖x) ⊕ y``, evaluated without the ambient cancellation.

    Mathematically identical to ``addition(scalar_mul(-1, x), y)``; use this whenever the
    result is expected much closer to the origin than the operands (centering a batch,
    differences of two far points). The exact hyperboloid lift uses a Cartesian
    inverse boost when either endpoint's scaled spatial radius is at most 1e-1
    and the stable polar frame otherwise. See :func:`_gyro_difference`.
    """
    return _gyro_difference(self._cast(x), self._cast(y), self._cast_c(c))

scalar_mul

scalar_mul(
    r: float | Float[Array, ""],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

PV scalar multiplication r ⊗_U x.

Source code in hyperbolix/manifolds/proper_velocity.py
def scalar_mul(self, r: float | Float[Array, ""], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """PV scalar multiplication r ⊗_U x."""
    x = self._cast(x)
    r_cast = jnp.asarray(r, dtype=x.dtype)
    return _scalar_mul(r_cast, x, self._cast_c(c))  # type: ignore[arg-type]

dist

dist(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance between PV points.

Source code in hyperbolix/manifolds/proper_velocity.py
def dist(
    self,
    x: Float[Array, "dim"],
    y: Float[Array, "dim"],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]:
    """Geodesic distance between PV points."""
    del version_idx  # only one implementation currently
    return _dist(self._cast(x), self._cast(y), self._cast_c(c))

dist_0

dist_0(
    x: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance from the PV origin.

Source code in hyperbolix/manifolds/proper_velocity.py
def dist_0(self, x: Float[Array, "dim"], c: ScalarCurvature, version_idx: int = VERSION_DEFAULT) -> Float[Array, ""]:
    """Geodesic distance from the PV origin."""
    del version_idx
    return _dist_0(self._cast(x), self._cast_c(c))

expmap

expmap(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Exponential map at x.

Source code in hyperbolix/manifolds/proper_velocity.py
def expmap(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map at x."""
    return _expmap(self._cast(v), self._cast(x), self._cast_c(c))

expmap_0

expmap_0(
    v: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Exponential map from the origin.

Source code in hyperbolix/manifolds/proper_velocity.py
def expmap_0(self, v: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map from the origin."""
    return _expmap_0(self._cast(v), self._cast_c(c))

logmap

logmap(
    y: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Logarithmic map at x through the exact hyperboloid lift.

A regular Cartesian expression is used when either endpoint is exactly the origin; otherwise the stable polar frame is used. Ordinary autodiff preserves the base-point derivative at the origin.

Source code in hyperbolix/manifolds/proper_velocity.py
def logmap(self, y: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map at x through the exact hyperboloid lift.

    A regular Cartesian expression is used when either endpoint is exactly the
    origin; otherwise the stable polar frame is used. Ordinary autodiff
    preserves the base-point derivative at the origin.
    """
    return _logmap(self._cast(y), self._cast(x), self._cast_c(c))

logmap_0

logmap_0(
    y: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Logarithmic map to the origin.

Source code in hyperbolix/manifolds/proper_velocity.py
def logmap_0(self, y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map to the origin."""
    return _logmap_0(self._cast(y), self._cast_c(c))

retraction

retraction(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Euclidean retraction (exact for PV).

Source code in hyperbolix/manifolds/proper_velocity.py
def retraction(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Euclidean retraction (exact for PV)."""
    return _retraction(self._cast(v), self._cast(x), self._cast_c(c))

ptransp

ptransp(
    v: Float[Array, dim],
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport v from T_x PV to T_y PV through the exact lift.

The lifted hyperboloid transport uses its Cartesian closed form when either endpoint's scaled spatial radius is at most 1e-1 and the stable polar frame otherwise.

Source code in hyperbolix/manifolds/proper_velocity.py
def ptransp(
    self,
    v: Float[Array, "dim"],
    x: Float[Array, "dim"],
    y: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Parallel transport v from T_x PV to T_y PV through the exact lift.

    The lifted hyperboloid transport uses its Cartesian closed form when either
    endpoint's scaled spatial radius is at most 1e-1 and the stable polar frame
    otherwise.
    """
    return _ptransp(self._cast(v), self._cast(x), self._cast(y), self._cast_c(c))

ptransp_0

ptransp_0(
    v: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport v from T_0 PV to T_y PV.

Source code in hyperbolix/manifolds/proper_velocity.py
def ptransp_0(self, v: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Parallel transport v from T_0 PV to T_y PV."""
    return _ptransp_0(self._cast(v), self._cast(y), self._cast_c(c))

tangent_inner

tangent_inner(
    u: Float[Array, dim],
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Riemannian inner product ⟨u, v⟩_x.

Source code in hyperbolix/manifolds/proper_velocity.py
def tangent_inner(
    self,
    u: Float[Array, "dim"],
    v: Float[Array, "dim"],
    x: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, ""]:
    """Riemannian inner product ⟨u, v⟩_x."""
    return _tangent_inner(self._cast(u), self._cast(v), self._cast(x), self._cast_c(c))

tangent_norm

tangent_norm(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Riemannian norm ||v||_x.

Source code in hyperbolix/manifolds/proper_velocity.py
def tangent_norm(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Riemannian norm ||v||_x."""
    return _tangent_norm(self._cast(v), self._cast(x), self._cast_c(c))

tangent_proj

tangent_proj(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Tangent-space projection (identity for PV).

Source code in hyperbolix/manifolds/proper_velocity.py
def tangent_proj(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Tangent-space projection (identity for PV)."""
    return _tangent_proj(self._cast(v), self._cast(x), self._cast_c(c))

egrad2rgrad

egrad2rgrad(
    grad: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Convert Euclidean gradient to Riemannian gradient.

Source code in hyperbolix/manifolds/proper_velocity.py
def egrad2rgrad(self, grad: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Convert Euclidean gradient to Riemannian gradient."""
    return _egrad2rgrad(self._cast(grad), self._cast(x), self._cast_c(c))

is_in_manifold

is_in_manifold(
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check that all entries are finite (PV has no constraint, so atol is unused).

Source code in hyperbolix/manifolds/proper_velocity.py
def is_in_manifold(self, x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None) -> Array:
    """Check that all entries are finite (PV has no constraint, so ``atol`` is unused)."""
    return _is_in_manifold(self._cast(x), self._cast_c(c), atol)

is_in_tangent_space

is_in_tangent_space(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check that v has finite entries (T_x PV = R^n, so atol is unused).

Source code in hyperbolix/manifolds/proper_velocity.py
def is_in_tangent_space(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None
) -> Array:
    """Check that v has finite entries (T_x PV = R^n, so ``atol`` is unused)."""
    return _is_in_tangent_space(self._cast(v), self._cast(x), self._cast_c(c), atol)

embed_spatial_0

embed_spatial_0(
    v_spatial: Float[Array, "... n"],
) -> Float[Array, "... n"]

Identity embedding (no time coordinate). Kept for API parity.

Source code in hyperbolix/manifolds/proper_velocity.py
def embed_spatial_0(self, v_spatial: Float[Array, "... n"]) -> Float[Array, "... n"]:
    """Identity embedding (no time coordinate). Kept for API parity."""
    return _embed_spatial_0(self._cast(v_spatial))

compute_mlr

compute_mlr(
    x: Float[Array, "batch in_dim"],
    z: Float[Array, "out_dim in_dim"],
    r: Float[Array, "out_dim 1"],
    c: ScalarCurvature,
    min_enorm: float = 1e-15,
) -> Float[Array, "batch out_dim"]

PV multinomial logistic regression (paper Thm 5.2).

Source code in hyperbolix/manifolds/proper_velocity.py
def compute_mlr(
    self,
    x: Float[Array, "batch in_dim"],
    z: Float[Array, "out_dim in_dim"],
    r: Float[Array, "out_dim 1"],
    c: ScalarCurvature,
    min_enorm: float = 1e-15,
) -> Float[Array, "batch out_dim"]:
    """PV multinomial logistic regression (paper Thm 5.2)."""
    return _compute_mlr(self._cast(x), self._cast(z), self._cast(r), self._cast_c(c), min_enorm)

Klein

The Beltrami–Klein model (the Klein model) uses the same open ball \(\lVert x\rVert < 1/\sqrt{c}\) as the Poincaré ball, with sectional curvature \(-c\), but its geodesics are the straight chords of the ball. The metric is not conformal:

\[g_x(u, v) = \frac{\langle u, v\rangle}{g_x} + \frac{c\,\langle x, u\rangle\langle x, v\rangle}{g_x^2}, \qquad g_x = 1 - c\lVert x\rVert^2.\]

The gyrovector structure is Ungar's Einstein gyrovector space (Ungar 2009): addition is Einstein addition \(\oplus_E\) and scalar_mul is Einstein scalar multiplication \(\otimes_E\). Klein conforms to the scalar-c Manifold protocol.

Relation to the Poincaré ball and the hyperboloid

A Klein point at geodesic distance \(d_0\) from the origin has \(\sqrt{c}\,\lVert x\rVert = \tanh(\sqrt{c}\,d_0)\), where a Poincaré point has \(\tanh(\sqrt{c}\,d_0/2)\). The isometries in isometry_mappings are the Einstein half and the Möbius double:

  • klein_to_poincare(k) \(= k/(1 + \sqrt{g_k})\), which is \(\tfrac12 \otimes_E k\)
  • poincare_to_klein(p) \(= 2p/(1 + c\lVert p\rVert^2)\), which is \(2 \otimes_M p\)
  • klein_to_hyperboloid(k) \(= \big(1/(\sqrt{c}\sqrt{g_k}),\ k/\sqrt{g_k}\big)\), hyperboloid_to_klein(x) \(= x_s/(\sqrt{c}\,x_0)\)
  • klein_to_pv(k) \(= k/\sqrt{g_k}\), pv_to_klein(x) \(= x/\sqrt{1 + c\lVert x\rVert^2}\)

Under the first pair, Einstein addition corresponds to Möbius addition. Einstein and Möbius scalar multiplication have the same formula, and so do the two models' expmap_0; Klein reuses Poincaré's code for both.

Distance: one formulation, cancellation-free

dist has a single implementation; version_idx is accepted and ignored, as for ProperVelocity. With \(w = y - x\),

\[d(x, y) = \frac{1}{\sqrt{c}}\,\operatorname{arsinh}\sqrt{\frac{c\,\big[g_x\lVert w\rVert^2 + c\,\langle x, w\rangle^2\big]}{g_x\, g_y}},\]

whose numerator is a sum of non-negative terms. It never forms \(1 - c\langle x, y\rangle\) and needs no acosh/atanh near 1. logmap and ptransp are built from the same quantity. The derivation and measured errors are in the numerical-stability guide.

Einstein extras

Beyond the protocol, Klein provides:

  • gyro_difference(x, y, c): \((\ominus x) \oplus_E y\), evaluated without the \(1 - c\langle x, y\rangle\) cancellation
  • lorentz_factor(x, c): \(\gamma_x = 1/\sqrt{g_x}\), which is the hyperboloid's \(\sqrt{c}\,X_0\)
  • einstein_midpoint(x_ND, weights_N, c): \(\sum_i w_i \gamma_i x_i / \sum_i w_i \gamma_i\) (weights_N=None for uniform weights), equal to the normalized weighted Lorentz centroid mapped to the Klein ball

Half the Poincaré ball's radius range

proj uses the Poincaré ball's eps**0.75 boundary margin, but a Klein point sits at \(\tanh(a)\) rather than \(\tanh(a/2)\) (\(a = \sqrt{c}\,d_0\), the scaled radius), so the projection ceiling at \(c = 1\) is \(a = \operatorname{atanh}(1 - \varepsilon^{0.75})\) = 6.32 in float32 and 13.86 in float64, half of Poincaré's 12.65 / 27.7. The maps into Klein (poincare_to_klein, hyperboloid_to_klein, pv_to_klein) do not project; call proj after mapping far points in. See the chart ceiling and floor.

hyperbolix.manifolds.klein.Klein

Klein(dtype: dtype = jnp.float32, *, c: float = 1.0)

Bases: ManifoldBase

Beltrami-Klein ball manifold (curvature -c, radius 1/√c) with automatic dtype casting.

Points are Euclidean ball points c‖x‖² < 1 as for :class:~hyperbolix.manifolds.Poincare, but geodesics are straight chords and the metric g_x(u, v) = (u·v)/g_x + c(x·u)(x·v)/g_x² (g_x = 1 - c‖x‖²) is not conformal. The gyrovector structure is Einstein addition; scalar_mul and expmap_0 coincide with Poincaré's formulas.

Precision: the chart shares Poincaré's eps**0.75 boundary margin, but a Klein point at scaled radius a = √c·d has √c‖x‖ = tanh(a) where a Poincaré point has tanh(a/2), so the projection ceiling is half Poincaré's: a ≈ 6.3 in float32 and ≈ 13.9 in float64 (at c = 1). Inside it the pairwise ops (dist, logmap, ptransp, gyro_difference) are cancellation-free; what remains is the storage floor of the gap, 1 - c‖x‖² known to relative eps·cosh²(a).

Args: dtype: Target JAX dtype for computations (default: jnp.float32) c: Curvature value (default: 1.0). Must be positive.

Examples: >>> import jax >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import Klein >>> >>> manifold = Klein(dtype=jnp.float64) >>> x = jnp.array([0.1, 0.2]) >>> y = jnp.array([0.3, 0.4]) >>> d = manifold.dist(x, y, c=1.0) >>> dists = jax.vmap(manifold.dist, in_axes=(0, 0, None))(jnp.stack([x, y]), jnp.stack([y, x]), 1.0)

References: Zhang et al. "Klein Hyperbolic Metric Learning." ICML 2026. Mao et al. "Klein Model for Hyperbolic Neural Networks." arXiv:2410.16813 (2024). Ungar. "A Gyrovector Space Approach to Hyperbolic Geometry." 2009.

Source code in hyperbolix/manifolds/_base.py
def __init__(
    self,
    dtype: jnp.dtype = jnp.float32,
    *,
    c: float = 1.0,
) -> None:
    self.dtype = dtype
    self._c_val = c

proj

proj(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Project a point onto the Klein ball by clipping its norm (same clamp as Poincaré).

Source code in hyperbolix/manifolds/klein.py
def proj(self, x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Project a point onto the Klein ball by clipping its norm (same clamp as Poincaré)."""
    return _proj(self._cast(x), self._cast_c(c))

proj_batch

proj_batch(
    x: Float[Array, "... dim"], c: ScalarCurvature
) -> Float[Array, "... dim"]

Project batched points onto the ball (arbitrary leading dimensions).

Source code in hyperbolix/manifolds/klein.py
def proj_batch(self, x: Float[Array, "... dim"], c: ScalarCurvature) -> Float[Array, "... dim"]:
    """Project batched points onto the ball (arbitrary leading dimensions)."""
    return _proj_batch(self._cast(x), self._cast_c(c))

addition

addition(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Einstein gyrovector addition x ⊕_E y.

Source code in hyperbolix/manifolds/klein.py
def addition(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Einstein gyrovector addition ``x ⊕_E y``."""
    return _addition(self._cast(x), self._cast(y), self._cast_c(c))

gyro_difference

gyro_difference(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Einstein gyro-difference (⊖x) ⊕_E y, evaluated without the 1 - c x·y cancellation.

Mathematically identical to addition(-x, y); use it when the result is expected much closer to the origin than the operands (centering, differences of two close points).

Source code in hyperbolix/manifolds/klein.py
def gyro_difference(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Einstein gyro-difference ``(⊖x) ⊕_E y``, evaluated without the ``1 - c x·y`` cancellation.

    Mathematically identical to ``addition(-x, y)``; use it when the result is expected much
    closer to the origin than the operands (centering, differences of two close points).
    """
    return _gyro_difference(self._cast(x), self._cast(y), self._cast_c(c))

scalar_mul

scalar_mul(
    r: float | Float[Array, ""],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Einstein scalar multiplication r ⊗ x = tanh(r·artanh(√c‖x‖))·x/(√c‖x‖).

The same formula as Möbius scalar multiplication (Ungar 2009): both scale the origin distance by r, and each model's radial coordinate is tanh of its own multiple of that distance.

Source code in hyperbolix/manifolds/klein.py
def scalar_mul(self, r: float | Float[Array, ""], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Einstein scalar multiplication ``r ⊗ x = tanh(r·artanh(√c‖x‖))·x/(√c‖x‖)``.

    The same formula as Möbius scalar multiplication (Ungar 2009): both scale the origin
    distance by ``r``, and each model's radial coordinate is ``tanh`` of its own multiple of
    that distance.
    """
    x = self._cast(x)
    r_cast = jnp.asarray(r, dtype=x.dtype)
    return _poincare_scalar_mul(r_cast, x, self._cast_c(c))  # type: ignore[arg-type]

dist

dist(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance arsinh(S)/√c between Klein points (single implementation).

Source code in hyperbolix/manifolds/klein.py
def dist(
    self,
    x: Float[Array, "dim"],
    y: Float[Array, "dim"],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]:
    """Geodesic distance ``arsinh(S)/√c`` between Klein points (single implementation)."""
    del version_idx  # only one implementation
    return _dist(self._cast(x), self._cast(y), self._cast_c(c))

dist_0

dist_0(
    x: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance from the origin.

Source code in hyperbolix/manifolds/klein.py
def dist_0(self, x: Float[Array, "dim"], c: ScalarCurvature, version_idx: int = VERSION_DEFAULT) -> Float[Array, ""]:
    """Geodesic distance from the origin."""
    del version_idx
    return _dist_0(self._cast(x), self._cast_c(c))

expmap

expmap(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Exponential map: tangent vector v at x to the manifold.

Source code in hyperbolix/manifolds/klein.py
def expmap(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map: tangent vector v at x to the manifold."""
    return _expmap(self._cast(v), self._cast(x), self._cast_c(c))

expmap_0

expmap_0(
    v: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Exponential map from the origin (the Poincaré formula; see :func:_expmap_0).

Source code in hyperbolix/manifolds/klein.py
def expmap_0(self, v: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map from the origin (the Poincaré formula; see :func:`_expmap_0`)."""
    return _expmap_0(self._cast(v), self._cast_c(c))

retraction

retraction(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Retraction proj(x + v).

Source code in hyperbolix/manifolds/klein.py
def retraction(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Retraction ``proj(x + v)``."""
    return _retraction(self._cast(v), self._cast(x), self._cast_c(c))

logmap

logmap(
    y: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Logarithmic map: point y to the tangent space at x.

Source code in hyperbolix/manifolds/klein.py
def logmap(self, y: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map: point y to the tangent space at x."""
    return _logmap(self._cast(y), self._cast(x), self._cast_c(c))

logmap_0

logmap_0(
    y: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Logarithmic map from the origin.

Source code in hyperbolix/manifolds/klein.py
def logmap_0(self, y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map from the origin."""
    return _logmap_0(self._cast(y), self._cast_c(c))

ptransp

ptransp(
    v: Float[Array, dim],
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport of v from x to y.

Source code in hyperbolix/manifolds/klein.py
def ptransp(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Parallel transport of v from x to y."""
    return _ptransp(self._cast(v), self._cast(x), self._cast(y), self._cast_c(c))

ptransp_0

ptransp_0(
    v: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport of v from the origin to y.

Source code in hyperbolix/manifolds/klein.py
def ptransp_0(self, v: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Parallel transport of v from the origin to y."""
    return _ptransp_0(self._cast(v), self._cast(y), self._cast_c(c))

tangent_inner

tangent_inner(
    u: Float[Array, dim],
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Klein metric g_x(u, v).

Source code in hyperbolix/manifolds/klein.py
def tangent_inner(
    self, u: Float[Array, "dim"], v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, ""]:
    """Klein metric ``g_x(u, v)``."""
    return _tangent_inner(self._cast(u), self._cast(v), self._cast(x), self._cast_c(c))

tangent_norm

tangent_norm(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Riemannian norm ‖v‖_x.

Source code in hyperbolix/manifolds/klein.py
def tangent_norm(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Riemannian norm ``‖v‖_x``."""
    return _tangent_norm(self._cast(v), self._cast(x), self._cast_c(c))

egrad2rgrad

egrad2rgrad(
    grad: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Convert a Euclidean gradient to the Riemannian gradient (inverse Klein metric).

Source code in hyperbolix/manifolds/klein.py
def egrad2rgrad(self, grad: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Convert a Euclidean gradient to the Riemannian gradient (inverse Klein metric)."""
    return _egrad2rgrad(self._cast(grad), self._cast(x), self._cast_c(c))

tangent_proj

tangent_proj(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Project v onto the tangent space at x (identity).

Source code in hyperbolix/manifolds/klein.py
def tangent_proj(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Project v onto the tangent space at x (identity)."""
    return _tangent_proj(self._cast(v), self._cast(x), self._cast_c(c))

is_in_manifold

is_in_manifold(
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check c‖x‖² < 1 + atol (atol default: :func:default_atol).

Source code in hyperbolix/manifolds/klein.py
def is_in_manifold(self, x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None) -> Array:
    """Check ``c‖x‖² < 1 + atol`` (``atol`` default: :func:`default_atol`)."""
    return _is_in_manifold(self._cast(x), self._cast_c(c), atol)

is_in_tangent_space

is_in_tangent_space(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check that v has finite entries (T_x K = R^d, so there is no other constraint).

Source code in hyperbolix/manifolds/klein.py
def is_in_tangent_space(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None
) -> Array:
    """Check that v has finite entries (``T_x K = R^d``, so there is no other constraint)."""
    return _is_in_tangent_space(self._cast(v), self._cast(x), self._cast_c(c), atol)

lorentz_factor

lorentz_factor(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, ""]

Einstein Lorentz factor gamma_x = 1/√(1 - c‖x‖²), scalar.

Source code in hyperbolix/manifolds/klein.py
def lorentz_factor(self, x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Einstein Lorentz factor ``gamma_x = 1/√(1 - c‖x‖²)``, scalar."""
    return _lorentz_factor(self._cast(x), self._cast_c(c))

einstein_midpoint

einstein_midpoint(
    x_ND: Float[Array, "N dim"],
    weights_N: Float[Array, N] | None,
    c: ScalarCurvature,
) -> Float[Array, dim]

Weighted Einstein midpoint Σ wᵢ·gammaᵢ·xᵢ / Σ wᵢ·gammaᵢ of N points.

Args: x_ND: Klein points, shape (N, dim) weights_N: Non-negative weights, shape (N,); None for uniform weights c: Curvature (positive)

Returns: Midpoint, shape (dim,) — the normalized weighted Lorentz centroid mapped to Klein.

Source code in hyperbolix/manifolds/klein.py
def einstein_midpoint(
    self, x_ND: Float[Array, "N dim"], weights_N: Float[Array, "N"] | None, c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Weighted Einstein midpoint ``Σ wᵢ·gammaᵢ·xᵢ / Σ wᵢ·gammaᵢ`` of N points.

    Args:
        x_ND: Klein points, shape (N, dim)
        weights_N: Non-negative weights, shape (N,); ``None`` for uniform weights
        c: Curvature (positive)

    Returns:
        Midpoint, shape (dim,) — the normalized weighted Lorentz centroid mapped to Klein.
    """
    weights = None if weights_N is None else self._cast(weights_N)
    return _einstein_midpoint(self._cast(x_ND), weights, self._cast_c(c))

HalfSpace

The Poincaré upper half-space model stores a point as \(x = (x_s, x_n)\) with the height \(x_n > 0\) in the last coordinate. The sectional curvature is \(-c\) and the metric is conformal:

\[g_x(u, v) = \frac{\langle u, v\rangle}{c\,x_n^2}.\]

The origin is \(o = e_n/\sqrt{c}\), not 0, and every _0 method is the general method evaluated at \(o\). Geodesics are vertical lines and half-circles orthogonal to the boundary \(x_n = 0\). In chart coordinates expmap, logmap and ptransp do not depend on \(c\), because a constant factor on the metric leaves the Christoffel symbols unchanged; only the origin, distances, norms and inner products carry \(c\). The convention follows HTorch (github.com/ydtydr/HTorch, manifolds/halfspace.py). HalfSpace conforms to the scalar-c Manifold protocol.

Relation to the Poincaré ball and the hyperboloid

The Cayley transform halfspace_to_poincare maps \(o\) to the ball origin with differential \(\tfrac12 I\), the vertical axis through \(o\) onto the \(e_n\) diameter, \(x_n \to \infty\) to the north pole \(e_n/\sqrt{c}\), and \(x_n \to 0\) to the boundary sphere. The isometries in isometry_mappings, with \(g_k = 1 - c\lVert k\rVert^2\):

  • halfspace_to_poincare(x) \(= \big(2x_s,\ (c\lVert x\rVert^2 - 1)/\sqrt{c}\big)\big/\big(c\lVert x_s\rVert^2 + (1 + \sqrt{c}\,x_n)^2\big)\), poincare_to_halfspace(p) \(= \big(2p_s,\ (1 - c\lVert p\rVert^2)/\sqrt{c}\big)\big/\big(c\lVert p_s\rVert^2 + (\sqrt{c}\,p_n - 1)^2\big)\)
  • halfspace_to_hyperboloid(x) \(= \big(c\lVert x\rVert^2 + 1,\ 2\sqrt{c}\,x_s,\ c\lVert x\rVert^2 - 1\big)/(2c\,x_n)\) (time coordinate first), hyperboloid_to_halfspace(X) \(= \big(X_{\mathrm{mid}},\ 1/\sqrt{c}\big)\big/\big(\sqrt{c}\,(X_0 - X_n)\big)\)
  • halfspace_to_klein(x) \(= \big(2x_s,\ (c\lVert x\rVert^2 - 1)/\sqrt{c}\big)/(1 + c\lVert x\rVert^2)\), klein_to_halfspace(k) \(= \big(k_s,\ \sqrt{g_k}/\sqrt{c}\big)/(1 - \sqrt{c}\,k_n)\)
  • halfspace_to_pv(x) \(= \big(2\sqrt{c}\,x_s,\ c\lVert x\rVert^2 - 1\big)/(2c\,x_n)\), the spatial part of the hyperboloid point; pv_to_halfspace(u) \(= \big(u_s,\ 1/\sqrt{c}\big)\big/\big(\sqrt{c}\,(\sqrt{1/c + \lVert u\rVert^2} - u_n)\big)\)

These are the formulas; the code rearranges the differences that cancel. For example, \(c\lVert x\rVert^2 - 1\) is evaluated as \(c\lVert x_s\rVert^2 + (\sqrt{c}\,x_n - 1)(\sqrt{c}\,x_n + 1)\), and for \(X_n \ge 0\) the gap \(X_0 - X_n\) as \((1/c + \lVert X_{\mathrm{mid}}\rVert^2)/(X_0 + X_n)\). None of the maps projects its output.

Gyrovector structure: Möbius operations through the Cayley transform

  • addition(x, y) \(= x \oplus y = \exp_x\!\big(P_{o\to x}(\log_o y)\big)\)
  • gyro_difference(x, y) \(= (\ominus x) \oplus y = \exp_o\!\big(P_{x\to o}(\log_x y)\big)\), built from \(\log_x y\), so two close points give a point close to \(o\) without cancellation
  • scalar_mul(r, x) \(= r \otimes x = \exp_o(r\,\log_o x)\)
  • the gyro-inverse is \(\ominus x = (-x_s,\ x_n)/(c\lVert x\rVert^2)\)

Each equals the Möbius operation of the Poincaré ball conjugated by halfspace_to_poincare. Unlike Poincare, the identity element is \(o = e_n/\sqrt{c}\), and \(\ominus x \ne -x\).

Pairwise operations: cancellation-free

dist has a single implementation; version_idx is accepted and ignored. With \(r = \big((y - x)/\sqrt{x_n}\big)/\sqrt{y_n}\), divided in sequence so that \(x_n y_n\) is never formed,

\[d(x, y) = \frac{2}{\sqrt{c}}\,\operatorname{arsinh}\!\Big(\tfrac12\lVert r\rVert\Big).\]

This is the same function as the textbook \(\operatorname{arcosh}\!\big(1 + \lVert y - x\rVert^2/(2x_n y_n)\big)/\sqrt{c}\), without its acosh of a number close to 1 for close pairs. logmap builds \(\theta/\sinh\theta\) from the same \(r\). expmap evaluates its denominator in a second, non-cancelling form for near-vertical upward steps. ptransp is a rational formula with no transcendental functions. The derivations and measured errors are in the numerical-stability guide.

Storage floor and the float ceilings

The error that remains is a stored point's own rounding, about \(0.4\,(\varepsilon/2)\cosh(\sqrt{c}\,\delta)/\sqrt{c}\) as a distance, where \(\delta\) is the distance to the vertical geodesic through \(o\) and \(\cosh(\sqrt{c}\,\delta) = \lVert x\rVert/x_n\). On that axis the floor does not grow with the height. Two cases return inf/NaN at a finite radius: the pairwise operations past a scaled distance \(\sqrt{c}\,d = 88.72\) in float32 (709.78 in float64), where \(\lVert r\rVert^2\) overflows, and expmap for an exactly vertical upward step longer than \(\theta = 87.34\) in float32 (708.40 in float64), where \(e^{-\theta}\) underflows. See the half-space numerics.

Projection, retraction and membership

proj floors the height at the dtype's smallest normal number, jnp.finfo(dtype).tiny, so a valid point is returned unchanged. retraction is proj((x_s + v_s, x_n·exp(v_n/x_n))): first order, exact for vertical steps, and never outside the half-space, where the plain x + v leaves it for large downward steps. is_in_manifold checks that x is finite with x_n > 0; atol is accepted and unused, as for ProperVelocity.

hyperbolix.manifolds.halfspace.HalfSpace

HalfSpace(dtype: dtype = jnp.float32, *, c: float = 1.0)

Bases: ManifoldBase

Poincaré upper half-space manifold (curvature -c) with automatic dtype casting.

Points are x = (x_s, x_n) with height x_n > 0 in the last coordinate, metric ‖dx‖²/(c·x_n²) and origin o = e_n/√c. The gyrovector structure is Möbius addition carried over from the Poincaré ball by the Cayley transform.

Precision: the pairwise ops (dist, logmap, ptransp, gyro_difference) are built from w = y - x and are cancellation-free; expmap is cancellation-free for every step direction. What remains is the storage floor, a stored point's own rounding ≈ 0.4·(eps/2)·cosh(√c·δ)/√c as a distance, with cosh(√c·δ) = ‖x‖/x_n and δ the distance to the vertical geodesic through o. Points on that axis are stored exactly across the dtype's normal range of heights; the pairwise ops return inf/NaN past a scaled distance √c·d ≈ 88.7 (float32; float64 709.8), where the squared chord overflows.

Args: dtype: Target JAX dtype for computations (default: jnp.float32) c: Curvature value (default: 1.0). Must be positive.

Examples: >>> import jax >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import HalfSpace >>> >>> manifold = HalfSpace(dtype=jnp.float64) >>> x = jnp.array([0.1, 1.0]) >>> y = jnp.array([0.3, 0.5]) >>> d = manifold.dist(x, y, c=1.0) >>> dists = jax.vmap(manifold.dist, in_axes=(0, 0, None))(jnp.stack([x, y]), jnp.stack([y, x]), 1.0)

References: Cannon, Floyd, Kenyon, Parry. "Hyperbolic Geometry." Flavors of Geometry, MSRI Publ. 31, 1997. Yu & De Sa. HTorch (github.com/ydtydr/HTorch), manifolds/halfspace.py.

Source code in hyperbolix/manifolds/_base.py
def __init__(
    self,
    dtype: jnp.dtype = jnp.float32,
    *,
    c: float = 1.0,
) -> None:
    self.dtype = dtype
    self._c_val = c

proj

proj(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Floor the height at the dtype's smallest normal number; valid points never move.

Source code in hyperbolix/manifolds/halfspace.py
def proj(self, x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Floor the height at the dtype's smallest normal number; valid points never move."""
    del c
    return _proj(self._cast(x))

proj_batch

proj_batch(
    x: Float[Array, "... dim"], c: ScalarCurvature
) -> Float[Array, "... dim"]

Project batched points (arbitrary leading dimensions); the same op as :meth:proj.

Source code in hyperbolix/manifolds/halfspace.py
def proj_batch(self, x: Float[Array, "... dim"], c: ScalarCurvature) -> Float[Array, "... dim"]:
    """Project batched points (arbitrary leading dimensions); the same op as :meth:`proj`."""
    del c
    return _proj(self._cast(x))

addition

addition(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Gyro addition x ⊕ y = exp_x(PT_{o→x}(log_o y)) (Möbius addition via the Cayley map).

Source code in hyperbolix/manifolds/halfspace.py
def addition(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Gyro addition ``x ⊕ y = exp_x(PT_{o→x}(log_o y))`` (Möbius addition via the Cayley map)."""
    return _addition(self._cast(x), self._cast(y), self._cast_c(c))

gyro_difference

gyro_difference(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Gyro difference (⊖x) ⊕ y, evaluated from log_x y without cancellation.

Mathematically identical to addition(⊖x, y) with ⊖x = (-x_s, x_n)/(c‖x‖²); use it when the result is expected much closer to the origin than the operands (centering, differences of two close points).

Source code in hyperbolix/manifolds/halfspace.py
def gyro_difference(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Gyro difference ``(⊖x) ⊕ y``, evaluated from ``log_x y`` without cancellation.

    Mathematically identical to ``addition(⊖x, y)`` with ``⊖x = (-x_s, x_n)/(c‖x‖²)``; use it when
    the result is expected much closer to the origin than the operands (centering, differences
    of two close points).
    """
    return _gyro_difference(self._cast(x), self._cast(y), self._cast_c(c))

scalar_mul

scalar_mul(
    r: float | Float[Array, ""],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Gyro scalar multiplication r ⊗ x = exp_o(r·log_o x) (scales the distance to o by r).

Source code in hyperbolix/manifolds/halfspace.py
def scalar_mul(self, r: float | Float[Array, ""], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Gyro scalar multiplication ``r ⊗ x = exp_o(r·log_o x)`` (scales the distance to ``o`` by ``r``)."""
    x = self._cast(x)
    r_cast = jnp.asarray(r, dtype=x.dtype)
    return _scalar_mul(r_cast, x, self._cast_c(c))

dist

dist(
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance (2/√c)·arsinh(‖r‖/2) (single implementation).

Source code in hyperbolix/manifolds/halfspace.py
def dist(
    self,
    x: Float[Array, "dim"],
    y: Float[Array, "dim"],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]:
    """Geodesic distance ``(2/√c)·arsinh(‖r‖/2)`` (single implementation)."""
    del version_idx  # only one implementation
    return _dist(self._cast(x), self._cast(y), self._cast_c(c))

dist_0

dist_0(
    x: Float[Array, dim],
    c: ScalarCurvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Geodesic distance from the origin o = e_n/√c.

Source code in hyperbolix/manifolds/halfspace.py
def dist_0(self, x: Float[Array, "dim"], c: ScalarCurvature, version_idx: int = VERSION_DEFAULT) -> Float[Array, ""]:
    """Geodesic distance from the origin ``o = e_n/√c``."""
    del version_idx
    return _dist_0(self._cast(x), self._cast_c(c))

expmap

expmap(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Exponential map: tangent vector v at x to the manifold.

Source code in hyperbolix/manifolds/halfspace.py
def expmap(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map: tangent vector v at x to the manifold."""
    return _expmap(self._cast(v), self._cast(x), self._cast_c(c))

expmap_0

expmap_0(
    v: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Exponential map from the origin.

Source code in hyperbolix/manifolds/halfspace.py
def expmap_0(self, v: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Exponential map from the origin."""
    return _expmap_0(self._cast(v), self._cast_c(c))

retraction

retraction(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Retraction proj((x_s + v_s, x_n·exp(v_n/x_n))).

Source code in hyperbolix/manifolds/halfspace.py
def retraction(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Retraction ``proj((x_s + v_s, x_n·exp(v_n/x_n)))``."""
    return _retraction(self._cast(v), self._cast(x), self._cast_c(c))

logmap

logmap(
    y: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Logarithmic map: point y to the tangent space at x.

Source code in hyperbolix/manifolds/halfspace.py
def logmap(self, y: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map: point y to the tangent space at x."""
    return _logmap(self._cast(y), self._cast(x), self._cast_c(c))

logmap_0

logmap_0(
    y: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Logarithmic map at the origin.

Source code in hyperbolix/manifolds/halfspace.py
def logmap_0(self, y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Logarithmic map at the origin."""
    return _logmap_0(self._cast(y), self._cast_c(c))

ptransp

ptransp(
    v: Float[Array, dim],
    x: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport of v from x to y.

Source code in hyperbolix/manifolds/halfspace.py
def ptransp(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, "dim"]:
    """Parallel transport of v from x to y."""
    return _ptransp(self._cast(v), self._cast(x), self._cast(y), self._cast_c(c))

ptransp_0

ptransp_0(
    v: Float[Array, dim],
    y: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Parallel transport of v from the origin to y.

Source code in hyperbolix/manifolds/halfspace.py
def ptransp_0(self, v: Float[Array, "dim"], y: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Parallel transport of v from the origin to y."""
    return _ptransp_0(self._cast(v), self._cast(y), self._cast_c(c))

tangent_inner

tangent_inner(
    u: Float[Array, dim],
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Metric g_x(u, v) = (u·v)/(c·x_n²).

Source code in hyperbolix/manifolds/halfspace.py
def tangent_inner(
    self, u: Float[Array, "dim"], v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature
) -> Float[Array, ""]:
    """Metric ``g_x(u, v) = (u·v)/(c·x_n²)``."""
    return _tangent_inner(self._cast(u), self._cast(v), self._cast(x), self._cast_c(c))

tangent_norm

tangent_norm(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, ""]

Riemannian norm ‖v‖_x = ‖v‖/(√c·x_n).

Source code in hyperbolix/manifolds/halfspace.py
def tangent_norm(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, ""]:
    """Riemannian norm ``‖v‖_x = ‖v‖/(√c·x_n)``."""
    return _tangent_norm(self._cast(v), self._cast(x), self._cast_c(c))

egrad2rgrad

egrad2rgrad(
    grad: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Convert a Euclidean gradient to the Riemannian gradient, c·x_n²·grad.

Source code in hyperbolix/manifolds/halfspace.py
def egrad2rgrad(self, grad: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Convert a Euclidean gradient to the Riemannian gradient, ``c·x_n²·grad``."""
    return _egrad2rgrad(self._cast(grad), self._cast(x), self._cast_c(c))

tangent_proj

tangent_proj(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
) -> Float[Array, dim]

Project v onto the tangent space at x (identity).

Source code in hyperbolix/manifolds/halfspace.py
def tangent_proj(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature) -> Float[Array, "dim"]:
    """Project v onto the tangent space at x (identity)."""
    return _tangent_proj(self._cast(v), self._cast(x), self._cast_c(c))

is_in_manifold

is_in_manifold(
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check that x is finite with x_n > 0 (atol accepted and unused: the constraint is exact).

Source code in hyperbolix/manifolds/halfspace.py
def is_in_manifold(self, x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None) -> Array:
    """Check that x is finite with ``x_n > 0`` (``atol`` accepted and unused: the constraint is exact)."""
    return _is_in_manifold(self._cast(x), self._cast_c(c), atol)

is_in_tangent_space

is_in_tangent_space(
    v: Float[Array, dim],
    x: Float[Array, dim],
    c: ScalarCurvature,
    atol: float | None = None,
) -> Array

Check that v has finite entries (T_x H = R^n, so there is no other constraint).

Source code in hyperbolix/manifolds/halfspace.py
def is_in_tangent_space(
    self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: ScalarCurvature, atol: float | None = None
) -> Array:
    """Check that v has finite entries (``T_x H = R^n``, so there is no other constraint)."""
    return _is_in_tangent_space(self._cast(v), self._cast(x), self._cast_c(c), atol)

Product Manifold

Heterogeneous-curvature product space \(P = M_1 \times M_2 \times \dots \times M_n\) where each factor \(M_i\) can be any single manifold (Poincaré, Hyperboloid, Proper Velocity, Klein, HalfSpace, Stereographic, Euclidean) with its own curvature \(c_i\). Points are represented as flat concatenated arrays of shape (total_dim,).

The geodesic distance on a product Riemannian manifold is Pythagorean over component distances:

\[d_P(x, y) \;=\; \sqrt{\sum_{i=1}^{n} d_{M_i}(x_i, y_i)^2}\]

where \(x_i\), \(y_i\) are the per-factor slices of the flat points.

Per-factor c argument

Every geometry method takes a positional c that must be a sequence of length n_factors: pass product.curvatures for static curvatures, or a tuple of LearnableCurvature calls for trainable ones. isinstance(product, Manifold) is True, but Manifold is typed with a scalar c; annotate code that passes a per-factor sequence as ProductManifold. See the Manifolds User Guide — Curvature in ProductManifold for the full pattern.

hyperbolix.manifolds.product.ProductManifold

ProductManifold(
    *factors: tuple[ManifoldBase, int],
    dtype: dtype = jnp.float32,
)

Product manifold P = M1 x M2 x ... x Mn.

Each factor is specified as (manifold_instance, dim) where dim is the point dimension (array slice width): ambient for Hyperboloid (d+1), spatial for Poincaré/Euclidean/ProperVelocity (d).

Curvature is supplied at call time as a per-factor sequence:

product.dist(x, y, (c0, c1, ...))         # explicit tuple
product.dist(x, y, product.curvatures)    # use factor-stored values

Factor instances may carry an initial curvature value (Hyperboloid(c=1.0)), but that value is not consulted by ProductManifold's methods — it is only useful as a static default to read off via product.curvatures.

ProductManifold satisfies the Manifold protocol with c typed as Curvature (a union of scalar and sequence-of-scalars), so generic code written against Manifold accepts product instances too. The product itself has no c attribute — there is no single scalar curvature.

Args: *factors: Tuples of (manifold_instance, dim). At least one required. dtype: Target JAX dtype for computations (default: jnp.float32). Every factor must have been built with this dtype; a mismatch raises ValueError.

Examples: >>> product = ProductManifold((Hyperboloid(c=1.0), 5), (Poincare(c=0.1), 3)) >>> c = product.curvatures # (1.0, 0.1) >>> x = product.origin(c) >>> parts = product.split(x) >>> d = product.dist(x, y, c)

From a signature (repeated factors):

>>> product = ProductManifold.from_signature(
...     (Hyperboloid, 3, 8, 1.0),  # 8 copies of 3D-ambient Hyperboloid
...     (Poincare, 2, 4, 0.1),      # 4 copies of 2D Poincaré
... )
Source code in hyperbolix/manifolds/product.py
def __init__(
    self,
    *factors: tuple[ManifoldBase, int],
    dtype: jnp.dtype = jnp.float32,
) -> None:
    if len(factors) < 1:
        raise ValueError("ProductManifold requires at least one factor")

    self.dtype = dtype

    manifolds = []
    dims = []
    slices = []
    pos = 0
    for i, (manifold, dim) in enumerate(factors):
        if not isinstance(manifold, ManifoldBase):
            raise TypeError(f"Factor {i}: expected ManifoldBase instance, got {type(manifold).__name__}")
        if dim < 1:
            raise ValueError(f"Factor {i}: dim must be >= 1, got {dim}")
        # Each factor computes in its own dtype, so a factor of another dtype would make every
        # method return that dtype instead of the product's.
        if jnp.dtype(manifold.dtype) != jnp.dtype(dtype):
            raise ValueError(
                f"Factor {i} ({type(manifold).__name__}) has dtype {jnp.dtype(manifold.dtype).name}, but the product "
                f"has dtype {jnp.dtype(dtype).name}. Build every factor with the product's dtype, e.g. "
                f"{type(manifold).__name__}(dtype=jnp.{jnp.dtype(dtype).name}), or pass "
                f"dtype=jnp.{jnp.dtype(manifold.dtype).name} to ProductManifold."
            )
        manifolds.append(manifold)
        dims.append(dim)
        slices.append(slice(pos, pos + dim))
        pos += dim

    self._factors = tuple(manifolds)
    self._dims = tuple(dims)
    self._slices = tuple(slices)
    self._total_dim = pos

curvatures property

curvatures: tuple[ScalarCurvature, ...]

Per-factor curvatures stored on the factor instances.

Useful as the c argument when curvature is static, e.g. product.dist(x, y, product.curvatures). For learnable curvature, build the tuple from LearnableCurvature calls instead.

split

split(x: Float[Array, total_dim]) -> tuple[Array, ...]

Split a product point into per-factor components.

Source code in hyperbolix/manifolds/product.py
def split(self, x: Float[Array, "total_dim"]) -> tuple[Array, ...]:
    """Split a product point into per-factor components."""
    return tuple(x[s] for s in self._slices)

combine

combine(*parts: Array) -> Float[Array, total_dim]

Combine per-factor components into a product point.

Source code in hyperbolix/manifolds/product.py
def combine(self, *parts: Array) -> Float[Array, "total_dim"]:
    """Combine per-factor components into a product point."""
    if len(parts) != len(self._factors):
        raise ValueError(f"Expected {len(self._factors)} parts, got {len(parts)}")
    return jnp.concatenate(list(parts))

origin

origin(c: Curvature) -> Float[Array, total_dim]

Construct the product origin point under per-factor curvatures.

Uses expmap_0(zeros, c[i]) per factor, which returns the manifold origin for all manifold types without isinstance checks.

Source code in hyperbolix/manifolds/product.py
def origin(self, c: Curvature) -> Float[Array, "total_dim"]:
    """Construct the product origin point under per-factor curvatures.

    Uses ``expmap_0(zeros, c[i])`` per factor, which returns the manifold
    origin for all manifold types without isinstance checks.
    """
    cs = self._validate_c(c)
    parts = []
    for m, dim, c_i in zip(self._factors, self._dims, cs, strict=True):
        zero_tangent = jnp.zeros(dim, dtype=self.dtype)
        parts.append(m.expmap_0(zero_tangent, c_i))
    return jnp.concatenate(parts)

proj

proj(
    x: Float[Array, total_dim], c: Curvature
) -> Float[Array, total_dim]

Project point onto product manifold (per-factor projection).

Source code in hyperbolix/manifolds/product.py
def proj(
    self,
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Project point onto product manifold (per-factor projection)."""
    cs = self._validate_c(c)
    x = self._cast(x)
    parts = self.split(x)
    return jnp.concatenate([m.proj(p, c_i) for m, p, c_i in zip(self._factors, parts, cs, strict=True)])

addition

addition(
    x: Float[Array, total_dim],
    y: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Manifold addition (per-factor).

Source code in hyperbolix/manifolds/product.py
def addition(
    self,
    x: Float[Array, "total_dim"],
    y: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Manifold addition (per-factor)."""
    cs = self._validate_c(c)
    x, y = self._cast(x), self._cast(y)
    x_parts, y_parts = self.split(x), self.split(y)
    return jnp.concatenate(
        [m.addition(xp, yp, c_i) for m, xp, yp, c_i in zip(self._factors, x_parts, y_parts, cs, strict=True)]
    )

scalar_mul

scalar_mul(
    r: float | Float[Array, ""],
    x: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Scalar multiplication (same scalar r applied to all factors).

Source code in hyperbolix/manifolds/product.py
def scalar_mul(
    self,
    r: float | Float[Array, ""],
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Scalar multiplication (same scalar r applied to all factors)."""
    cs = self._validate_c(c)
    x = self._cast(x)
    parts = self.split(x)
    return jnp.concatenate([m.scalar_mul(r, p, c_i) for m, p, c_i in zip(self._factors, parts, cs, strict=True)])

expmap

expmap(
    v: Float[Array, total_dim],
    x: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Exponential map (per-factor).

Source code in hyperbolix/manifolds/product.py
def expmap(
    self,
    v: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Exponential map (per-factor)."""
    cs = self._validate_c(c)
    v, x = self._cast(v), self._cast(x)
    v_parts, x_parts = self.split(v), self.split(x)
    return jnp.concatenate(
        [m.expmap(vp, xp, c_i) for m, vp, xp, c_i in zip(self._factors, v_parts, x_parts, cs, strict=True)]
    )

expmap_0

expmap_0(
    v: Float[Array, total_dim], c: Curvature
) -> Float[Array, total_dim]

Exponential map from origin (per-factor).

Source code in hyperbolix/manifolds/product.py
def expmap_0(
    self,
    v: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Exponential map from origin (per-factor)."""
    cs = self._validate_c(c)
    v = self._cast(v)
    parts = self.split(v)
    return jnp.concatenate([m.expmap_0(p, c_i) for m, p, c_i in zip(self._factors, parts, cs, strict=True)])

logmap

logmap(
    y: Float[Array, total_dim],
    x: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Logarithmic map (per-factor).

Source code in hyperbolix/manifolds/product.py
def logmap(
    self,
    y: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Logarithmic map (per-factor)."""
    cs = self._validate_c(c)
    y, x = self._cast(y), self._cast(x)
    y_parts, x_parts = self.split(y), self.split(x)
    return jnp.concatenate(
        [m.logmap(yp, xp, c_i) for m, yp, xp, c_i in zip(self._factors, y_parts, x_parts, cs, strict=True)]
    )

logmap_0

logmap_0(
    y: Float[Array, total_dim], c: Curvature
) -> Float[Array, total_dim]

Logarithmic map to origin (per-factor).

Source code in hyperbolix/manifolds/product.py
def logmap_0(
    self,
    y: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Logarithmic map to origin (per-factor)."""
    cs = self._validate_c(c)
    y = self._cast(y)
    parts = self.split(y)
    return jnp.concatenate([m.logmap_0(p, c_i) for m, p, c_i in zip(self._factors, parts, cs, strict=True)])

retraction

retraction(
    v: Float[Array, total_dim],
    x: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Retraction (per-factor).

Source code in hyperbolix/manifolds/product.py
def retraction(
    self,
    v: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Retraction (per-factor)."""
    cs = self._validate_c(c)
    v, x = self._cast(v), self._cast(x)
    v_parts, x_parts = self.split(v), self.split(x)
    return jnp.concatenate(
        [m.retraction(vp, xp, c_i) for m, vp, xp, c_i in zip(self._factors, v_parts, x_parts, cs, strict=True)]
    )

ptransp

ptransp(
    v: Float[Array, total_dim],
    x: Float[Array, total_dim],
    y: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Parallel transport of v from x to y (per-factor).

Source code in hyperbolix/manifolds/product.py
def ptransp(
    self,
    v: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    y: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Parallel transport of v from x to y (per-factor)."""
    cs = self._validate_c(c)
    v, x, y = self._cast(v), self._cast(x), self._cast(y)
    v_parts, x_parts, y_parts = self.split(v), self.split(x), self.split(y)
    return jnp.concatenate(
        [
            m.ptransp(vp, xp, yp, c_i)
            for m, vp, xp, yp, c_i in zip(self._factors, v_parts, x_parts, y_parts, cs, strict=True)
        ]
    )

ptransp_0

ptransp_0(
    v: Float[Array, total_dim],
    y: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Parallel transport from origin to y (per-factor).

Source code in hyperbolix/manifolds/product.py
def ptransp_0(
    self,
    v: Float[Array, "total_dim"],
    y: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Parallel transport from origin to y (per-factor)."""
    cs = self._validate_c(c)
    v, y = self._cast(v), self._cast(y)
    v_parts, y_parts = self.split(v), self.split(y)
    return jnp.concatenate(
        [m.ptransp_0(vp, yp, c_i) for m, vp, yp, c_i in zip(self._factors, v_parts, y_parts, cs, strict=True)]
    )

tangent_inner

tangent_inner(
    u: Float[Array, total_dim],
    v: Float[Array, total_dim],
    x: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, ""]

Riemannian inner product (sum of per-factor inner products).

Source code in hyperbolix/manifolds/product.py
def tangent_inner(
    self,
    u: Float[Array, "total_dim"],
    v: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, ""]:
    """Riemannian inner product (sum of per-factor inner products)."""
    cs = self._validate_c(c)
    u, v, x = self._cast(u), self._cast(v), self._cast(x)
    u_parts, v_parts, x_parts = self.split(u), self.split(v), self.split(x)
    inners = jnp.stack(
        [
            m.tangent_inner(up, vp, xp, c_i)
            for m, up, vp, xp, c_i in zip(self._factors, u_parts, v_parts, x_parts, cs, strict=True)
        ]
    )
    return jnp.sum(inners)

tangent_norm

tangent_norm(
    v: Float[Array, total_dim],
    x: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, ""]

Riemannian norm (sqrt of tangent inner product with itself).

safe_sqrt, not a bare jnp.sqrt: at v = 0 the inner product is exactly 0, where sqrt' is infinite and reverse-mode AD forms 0 * inf = NaN for the whole row.

Source code in hyperbolix/manifolds/product.py
def tangent_norm(
    self,
    v: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, ""]:
    """Riemannian norm (sqrt of tangent inner product with itself).

    ``safe_sqrt``, not a bare ``jnp.sqrt``: at ``v = 0`` the inner product is exactly 0, where
    ``sqrt'`` is infinite and reverse-mode AD forms ``0 * inf = NaN`` for the whole row.
    """
    return safe_sqrt(floor_at(self.tangent_inner(v, v, x, c), 0.0))

egrad2rgrad

egrad2rgrad(
    grad: Float[Array, total_dim],
    x: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Convert Euclidean gradient to Riemannian gradient (per-factor).

Source code in hyperbolix/manifolds/product.py
def egrad2rgrad(
    self,
    grad: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Convert Euclidean gradient to Riemannian gradient (per-factor)."""
    cs = self._validate_c(c)
    grad, x = self._cast(grad), self._cast(x)
    g_parts, x_parts = self.split(grad), self.split(x)
    return jnp.concatenate(
        [m.egrad2rgrad(gp, xp, c_i) for m, gp, xp, c_i in zip(self._factors, g_parts, x_parts, cs, strict=True)]
    )

tangent_proj

tangent_proj(
    v: Float[Array, total_dim],
    x: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, total_dim]

Project vector onto tangent space (per-factor).

Source code in hyperbolix/manifolds/product.py
def tangent_proj(
    self,
    v: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "total_dim"]:
    """Project vector onto tangent space (per-factor)."""
    cs = self._validate_c(c)
    v, x = self._cast(v), self._cast(x)
    v_parts, x_parts = self.split(v), self.split(x)
    return jnp.concatenate(
        [m.tangent_proj(vp, xp, c_i) for m, vp, xp, c_i in zip(self._factors, v_parts, x_parts, cs, strict=True)]
    )

component_dist

component_dist(
    x: Float[Array, total_dim],
    y: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, n_factors]

Per-factor geodesic distances as a vector.

Source code in hyperbolix/manifolds/product.py
def component_dist(
    self,
    x: Float[Array, "total_dim"],
    y: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, "n_factors"]:
    """Per-factor geodesic distances as a vector."""
    cs = self._validate_c(c)
    x, y = self._cast(x), self._cast(y)
    x_parts, y_parts = self.split(x), self.split(y)
    return jnp.stack([m.dist(xp, yp, c_i) for m, xp, yp, c_i in zip(self._factors, x_parts, y_parts, cs, strict=True)])

dist

dist(
    x: Float[Array, total_dim],
    y: Float[Array, total_dim],
    c: Curvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Product distance (L2/Riemannian): d = sqrt(sum d_i^2).

version_idx is accepted and ignored: it is a per-manifold index (Poincaré's 2 means the metric-tensor form, the Hyperboloid has no such variant), so one value cannot be forwarded to a heterogeneous product. Each factor uses its own default. The argument exists so manifold-generic callers that always forward one (e.g. hyperbolix.utils.helpers.compute_pairwise_distances) work with product manifolds; call component_dist directly if you need per-factor control.

Source code in hyperbolix/manifolds/product.py
def dist(
    self,
    x: Float[Array, "total_dim"],
    y: Float[Array, "total_dim"],
    c: Curvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]:
    """Product distance (L2/Riemannian): d = sqrt(sum d_i^2).

    ``version_idx`` is accepted and **ignored**: it is a per-manifold index (Poincaré's 2
    means the metric-tensor form, the Hyperboloid has no such variant), so one value cannot
    be forwarded to a heterogeneous product. Each factor uses its own default. The argument
    exists so manifold-generic callers that always forward one (e.g.
    ``hyperbolix.utils.helpers.compute_pairwise_distances``) work with product manifolds;
    call ``component_dist`` directly if you need per-factor control.
    """
    del version_idx
    d_per_factor = self.component_dist(x, y, c)
    # `safe_norm` over the per-factor distances: the L2 combination is a Euclidean norm, so
    # the primitive applies directly. Exact 0 with an exactly-zero gradient when every factor
    # distance is 0 (x == y), where the bare `sqrt(sum(d**2))` had an infinite derivative.
    return safe_norm(d_per_factor)

dist_0

dist_0(
    x: Float[Array, total_dim],
    c: Curvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]

Distance from origin (L2/Riemannian). version_idx accepted and ignored (see dist).

Source code in hyperbolix/manifolds/product.py
def dist_0(
    self,
    x: Float[Array, "total_dim"],
    c: Curvature,
    version_idx: int = VERSION_DEFAULT,
) -> Float[Array, ""]:
    """Distance from origin (L2/Riemannian). ``version_idx`` accepted and ignored (see ``dist``)."""
    del version_idx
    cs = self._validate_c(c)
    x = self._cast(x)
    parts = self.split(x)
    # Stack the per-factor distances themselves, not their squares, and let `safe_norm` do the
    # L2 combination: nothing is squared (no overflow at large factor distances) and the
    # gradient at the product origin is exactly 0 instead of NaN.
    d_per_factor = jnp.stack([m.dist_0(p, c_i) for m, p, c_i in zip(self._factors, parts, cs, strict=True)])
    return safe_norm(d_per_factor)

dist_l1

dist_l1(
    x: Float[Array, total_dim],
    y: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, ""]

L1 product distance: d = sum d_i.

Source code in hyperbolix/manifolds/product.py
def dist_l1(
    self,
    x: Float[Array, "total_dim"],
    y: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, ""]:
    """L1 product distance: d = sum d_i."""
    return jnp.sum(self.component_dist(x, y, c))

dist_min

dist_min(
    x: Float[Array, total_dim],
    y: Float[Array, total_dim],
    c: Curvature,
) -> Float[Array, ""]

Min product distance: d = min d_i.

Warning: This is NOT a true metric: positive-definiteness fails. Two distinct points x != y that agree on any single factor (x_i == y_i) yield d = 0. Use only when the "closest-factor" interpretation is semantically intended; for an actual distance use dist (L2) or dist_l1.

Source code in hyperbolix/manifolds/product.py
def dist_min(
    self,
    x: Float[Array, "total_dim"],
    y: Float[Array, "total_dim"],
    c: Curvature,
) -> Float[Array, ""]:
    """Min product distance: d = min d_i.

    Warning:
        This is NOT a true metric: positive-definiteness fails. Two
        distinct points ``x != y`` that agree on any single factor
        (``x_i == y_i``) yield ``d = 0``. Use only when the
        "closest-factor" interpretation is semantically intended;
        for an actual distance use ``dist`` (L2) or ``dist_l1``.
    """
    return jnp.min(self.component_dist(x, y, c))

is_in_manifold

is_in_manifold(
    x: Float[Array, total_dim],
    c: Curvature,
    atol: float | None = None,
) -> Array

Check if point is on product manifold (all factors valid).

atol is forwarded unchanged to every factor, so None lets each factor resolve its own dtype-aware default (:func:~hyperbolix.manifolds._base.default_atol).

Source code in hyperbolix/manifolds/product.py
def is_in_manifold(
    self,
    x: Float[Array, "total_dim"],
    c: Curvature,
    atol: float | None = None,
) -> Array:
    """Check if point is on product manifold (all factors valid).

    ``atol`` is forwarded unchanged to every factor, so ``None`` lets each factor resolve
    its own dtype-aware default (:func:`~hyperbolix.manifolds._base.default_atol`).
    """
    cs = self._validate_c(c)
    x = self._cast(x)
    parts = self.split(x)
    checks = [m.is_in_manifold(p, c_i, atol) for m, p, c_i in zip(self._factors, parts, cs, strict=True)]
    return jnp.all(jnp.stack(checks))

is_in_tangent_space

is_in_tangent_space(
    v: Float[Array, total_dim],
    x: Float[Array, total_dim],
    c: Curvature,
    atol: float | None = None,
) -> Array

Check if vector is in tangent space at x (all factors valid); atol forwarded per factor.

Source code in hyperbolix/manifolds/product.py
def is_in_tangent_space(
    self,
    v: Float[Array, "total_dim"],
    x: Float[Array, "total_dim"],
    c: Curvature,
    atol: float | None = None,
) -> Array:
    """Check if vector is in tangent space at x (all factors valid); ``atol`` forwarded per factor."""
    cs = self._validate_c(c)
    v, x = self._cast(v), self._cast(x)
    v_parts, x_parts = self.split(v), self.split(x)
    checks = [
        m.is_in_tangent_space(vp, xp, c_i, atol)
        for m, vp, xp, c_i in zip(self._factors, v_parts, x_parts, cs, strict=True)
    ]
    return jnp.all(jnp.stack(checks))

from_signature classmethod

from_signature(
    *specs: tuple, dtype: dtype = jnp.float32
) -> ProductManifold

Create product manifold from a signature specification.

Each spec is one of: - (ManifoldClass, dim, count) — uses c=1.0 as factor init. - (ManifoldClass, dim, count, curvature) — sets factor init c.

The curvature here is an initial / default value stored on the factor; it is only consulted via product.curvatures. Geometry methods take c at call time.

Euclidean factors silently ignore the curvature field (Euclidean has fixed c=0; see Euclidean.__init__).

Args: *specs: Signature tuples (3- or 4-tuple as described above). dtype: Target JAX dtype.

Returns: ProductManifold instance.

Examples: >>> pm = ProductManifold.from_signature( ... (Hyperboloid, 3, 8, 1.0), ... (Poincare, 2, 4, 0.1), ... (Euclidean, 8, 1), ... )

Source code in hyperbolix/manifolds/product.py
@classmethod
def from_signature(
    cls,
    *specs: tuple,
    dtype: jnp.dtype = jnp.float32,
) -> "ProductManifold":
    """Create product manifold from a signature specification.

    Each spec is one of:
      - ``(ManifoldClass, dim, count)`` — uses ``c=1.0`` as factor init.
      - ``(ManifoldClass, dim, count, curvature)`` — sets factor init ``c``.

    The ``curvature`` here is an **initial / default** value stored on the
    factor; it is only consulted via ``product.curvatures``. Geometry
    methods take ``c`` at call time.

    Euclidean factors silently ignore the ``curvature`` field
    (Euclidean has fixed ``c=0``; see ``Euclidean.__init__``).

    Args:
        *specs: Signature tuples (3- or 4-tuple as described above).
        dtype: Target JAX dtype.

    Returns:
        ProductManifold instance.

    Examples:
        >>> pm = ProductManifold.from_signature(
        ...     (Hyperboloid, 3, 8, 1.0),
        ...     (Poincare, 2, 4, 0.1),
        ...     (Euclidean, 8, 1),
        ... )
    """
    from .euclidean import Euclidean

    factors: list[tuple[ManifoldBase, int]] = []
    for spec in specs:
        if len(spec) == 3:
            manifold_cls, dim, count = spec
            curvature = 1.0
        elif len(spec) == 4:
            manifold_cls, dim, count, curvature = spec
        else:
            raise ValueError(
                "Expected 3-tuple (ManifoldClass, dim, count) or 4-tuple "
                f"(ManifoldClass, dim, count, curvature); got {len(spec)}-tuple"
            )

        for _ in range(count):
            if issubclass(manifold_cls, Euclidean):
                instance = manifold_cls(dtype=dtype)
            else:
                instance = manifold_cls(dtype=dtype, c=curvature)
            factors.append((instance, dim))

    return cls(*factors, dtype=dtype)

Isometry Mappings

Distance-preserving maps between the Poincaré ball, hyperboloid, Proper Velocity (PV), Klein, and half-space models — all coordinate models of the same hyperbolic space. Provides Poincaré ↔ Hyperboloid, Poincaré ↔ PV (PVNN Eq. 4), the direct Hyperboloid ↔ PV map (PV coordinates are the space-like part of the 4-velocity), Klein ↔ Poincaré / Hyperboloid / PV (klein_to_poincare, poincare_to_klein, klein_to_hyperboloid, hyperboloid_to_klein, klein_to_pv, pv_to_klein; a Klein point is an Einstein velocity, and its proper velocity is k/√g_k), and half-space ↔ Poincaré / Hyperboloid / Klein / PV (halfspace_to_poincare, poincare_to_halfspace, halfspace_to_hyperboloid, hyperboloid_to_halfspace, halfspace_to_klein, klein_to_halfspace, halfspace_to_pv, pv_to_halfspace; the first pair is the Cayley transform, and halfspace_to_pv is the spatial part of halfspace_to_hyperboloid).

None of the half-space maps projects its output. poincare_to_halfspace and klein_to_halfspace floor the ball's gap \(1 - c\lVert\cdot\rVert^2\), as the other maps out of a ball do, so the height they return is positive. klein_to_halfspace maps every point of the closed Klein ball, the north pole included, to a finite point; poincare_to_halfspace returns inf/NaN at the north pole \(e_n/\sqrt{c}\), the half-space's point at infinity, which a Poincare.proj-projected point never reaches. hyperboloid_to_halfspace and pv_to_halfspace do not floor \(x_n\). klein_to_halfspace is limited by the Klein chart's own rounding, relative error \(\varepsilon\cosh^2(a)\) at scaled radius \(a\), in every spelling (see the Klein chart's floor).

hyperbolix.manifolds.isometry_mappings

Isometry mappings between hyperbolic manifold models.

This module implements distance-preserving transformations (isometries) between different models of hyperbolic geometry. All functions operate on single points and use JAX's vmap for batch operations.

Supported Models (curvature c > 0, sectional curvature -c): - Hyperboloid model (Lorentz model): Points in R^(d+1) satisfying ⟨x,x⟩_L = -1/c - Poincaré ball model: Points in R^d with ||y||² < 1/c - Proper Velocity (PV) model: Unconstrained points in R^d (Chen et al. 2026) - Beltrami-Klein model: Points in R^d with ||k||² < 1/c (geodesics are straight chords) - Poincaré half-space model: Points in R^d with last coordinate x_n > 0 (origin e_n/√c)

Provided maps (all exact, distance-preserving, mutually consistent): - Poincaré ↔ Hyperboloid: poincare_to_hyperboloid / hyperboloid_to_poincare (curvature-aware stereographic projection through [-1/√c, 0, ..., 0]). - Poincaré ↔ PV: poincare_to_pv / pv_to_poincare (the gyro-isomorphism of PVNN Eq. 4, an isometry by their Thm 4.2). - Hyperboloid ↔ PV: hyperboloid_to_pv / pv_to_hyperboloid (direct map — PV coordinates are the space-like part of the 4-velocity; the projection Π of Ferreira 2017, Sec. 2, built on the PV gyrogroup of Ungar 2005, Def. 3.40). - Klein ↔ Poincaré: klein_to_poincare / poincare_to_klein (the Einstein half / Möbius double maps, k = 2 ⊗ p). - Klein ↔ Hyperboloid: klein_to_hyperboloid / hyperboloid_to_klein (central projection from the ambient origin onto the plane x₀ = 1/√c). - Klein ↔ PV: klein_to_pv / pv_to_klein (PV = Einstein velocity scaled by its Lorentz factor, x = gamma_k·k). - Half-space ↔ Poincaré: halfspace_to_poincare / poincare_to_halfspace (the Cayley transform, origin e_n/√c ↦ 0 with differential ½·I). - Half-space ↔ Hyperboloid: halfspace_to_hyperboloid / hyperboloid_to_halfspace. - Half-space ↔ Klein: halfspace_to_klein / klein_to_halfspace. - Half-space ↔ PV: halfspace_to_pv / pv_to_halfspace.

Klein chart precision: with scaled radius a = √c·d(0, ·) a Klein point has √c·||k|| = tanh(a) where a Poincaré point has tanh(a/2), so 1 - c·||k||² reaches the _boundary_floor value at half the Poincaré radius — scaled radius ≈ 6.3 in float32 and ≈ 13.9 in float64 at c = 1 (Poincaré: 12.6 / 27.7). The maps into Klein (poincare_to_klein, hyperboloid_to_klein, pv_to_klein) do not project. A point farther out than that lands between the proj margin and the boundary (float32, c = 1: ||k|| = 0.9999983 at a = 7 against the margin 0.99999356), and from a ≈ 10 on ||k|| rounds to exactly 1/√c (at a = 12 for all three maps). Klein operations floor 1 - c·||k||² at half the _boundary_floor value (_boundary_divisor_floor, below the rounding band of a capped point), so such a point reads at its own radius up to a ≈ 6.67 and as a ≈ 6.67 beyond (float32, c = 1; float64: 14.21). Call Klein.proj after mapping far points into Klein.

JIT Compilation & Batching

All functions work with single points and return single points. Use jax.vmap for batch operations:

>>> import jax
>>> import jax.numpy as jnp
>>> from hyperbolix.manifolds import isometry_mappings
>>>
>>> # Single point conversion
>>> x_hyp = jnp.array([1.0, 0.1, 0.2])  # Hyperboloid point
>>> y_poinc = isometry_mappings.hyperboloid_to_poincare(x_hyp, c=1.0)
>>>
>>> # Batch conversion with vmap
>>> x_batch = jnp.array([[1.0, 0.1, 0.2], [1.1, 0.15, 0.25]])
>>> convert_batch = jax.vmap(isometry_mappings.hyperboloid_to_poincare, in_axes=(0, None))
>>> y_batch = convert_batch(x_batch, 1.0)

References: Wikipedia: Hyperboloid model https://en.wikipedia.org/wiki/Hyperboloid_model#Relation_to_other_models Chen et al. "Proper Velocity Neural Networks." ICLR 2026 (PV ↔ Poincaré, Eq. 4). Ferreira. "Harmonic Analysis on the Proper Velocity Gyrogroup." Banach J. Math. Anal. 11(1), 21-49, 2017 (PV ↔ Hyperboloid projection Π, Sec. 2). Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and Applications." World Scientific, 2005 (PV gyrogroup, Def. 3.40; the Einstein ↔ Möbius gyrovector-space isomorphism behind Klein ↔ Poincaré).

hyperboloid_to_poincare

hyperboloid_to_poincare(
    x: Float[Array, dim_plus_1], c: ScalarCurvature
) -> Float[Array, dim]

Convert hyperboloid point to Poincaré ball via stereographic projection.

Projects the hyperboloid point onto the hyperplane t = 0 by intersecting with a line through [-1/√c, 0, ..., 0]. This implements the canonical isometry between the two models (radius-1/√c Poincaré ball).

Formula: y_i = x_i / (√c·t + 1) where x = [t, x_1, ..., x_n] on hyperboloid (t = x₀ ≥ 1/√c)

Args: x: Point on hyperboloid, shape (dim+1,). Should satisfy ⟨x,x⟩_L = -1/c. c: Curvature (positive)

Returns: Point in Poincaré ball, shape (dim,). Satisfies ||y||² < 1/c.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Convert hyperboloid origin to Poincaré origin >>> x_origin = jnp.array([1.0, 0.0, 0.0]) # c=1.0 origin >>> y = isometry_mappings.hyperboloid_to_poincare(x_origin, c=1.0) >>> bool(jnp.allclose(y, jnp.zeros(2))) True

References: Wikipedia: Hyperboloid model - Relation to other models

Source code in hyperbolix/manifolds/isometry_mappings.py
def hyperboloid_to_poincare(
    x: Float[Array, "dim_plus_1"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert hyperboloid point to Poincaré ball via stereographic projection.

    Projects the hyperboloid point onto the hyperplane t = 0 by intersecting
    with a line through [-1/√c, 0, ..., 0]. This implements the canonical
    isometry between the two models (radius-1/√c Poincaré ball).

    Formula:
        y_i = x_i / (√c·t + 1)
        where x = [t, x_1, ..., x_n] on hyperboloid (t = x₀ ≥ 1/√c)

    Args:
        x: Point on hyperboloid, shape (dim+1,). Should satisfy ⟨x,x⟩_L = -1/c.
        c: Curvature (positive)

    Returns:
        Point in Poincaré ball, shape (dim,). Satisfies ||y||² < 1/c.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Convert hyperboloid origin to Poincaré origin
        >>> x_origin = jnp.array([1.0, 0.0, 0.0])  # c=1.0 origin
        >>> y = isometry_mappings.hyperboloid_to_poincare(x_origin, c=1.0)
        >>> bool(jnp.allclose(y, jnp.zeros(2)))
        True

    References:
        Wikipedia: Hyperboloid model - Relation to other models
    """
    c = jnp.asarray(c, dtype=x.dtype)
    sqrt_c = jnp.sqrt(c)
    t = x[0]  # Temporal component
    x_spatial = x[1:]  # Spatial components (x_1, ..., x_n)

    # Curvature-aware stereographic projection: y_i = x_i / (√c·t + 1).
    # Since t ≥ 1/√c on the hyperboloid, √c·t ≥ 1 and the denominator ≥ 2 — stable.
    denominator = floor_at(sqrt_c * t + 1.0, MIN_NORM)
    return x_spatial / denominator

poincare_to_hyperboloid

poincare_to_hyperboloid(
    y: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim_plus_1]

Convert Poincaré ball point to hyperboloid via inverse stereographic projection.

Inverts the stereographic projection to map points from the Poincaré ball back to the hyperboloid. This implements the canonical isometry between the two models (radius-1/√c Poincaré ball).

Formula: t = (1 + c·||y||²) / ((1 - c·||y||²)·√c) x_i = 2·y_i / (1 - c·||y||²) where y = [y_1, ..., y_n] in Poincaré ball (||y||² < 1/c)

Args: y: Point in Poincaré ball, shape (dim,). Should satisfy ||y||² < 1/c. c: Curvature (positive)

Returns: Point on hyperboloid, shape (dim+1,). Satisfies ⟨x,x⟩_L = -1/c.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Convert Poincaré origin to hyperboloid origin >>> y_origin = jnp.array([0.0, 0.0]) >>> x = isometry_mappings.poincare_to_hyperboloid(y_origin, c=1.0) >>> bool(jnp.allclose(x, jnp.array([1.0, 0.0, 0.0]))) True

References: Wikipedia: Hyperboloid model - Relation to other models

Source code in hyperbolix/manifolds/isometry_mappings.py
def poincare_to_hyperboloid(
    y: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim_plus_1"]:
    """Convert Poincaré ball point to hyperboloid via inverse stereographic projection.

    Inverts the stereographic projection to map points from the Poincaré ball
    back to the hyperboloid. This implements the canonical isometry between
    the two models (radius-1/√c Poincaré ball).

    Formula:
        t   = (1 + c·||y||²) / ((1 - c·||y||²)·√c)
        x_i = 2·y_i / (1 - c·||y||²)
        where y = [y_1, ..., y_n] in Poincaré ball (||y||² < 1/c)

    Args:
        y: Point in Poincaré ball, shape (dim,). Should satisfy ||y||² < 1/c.
        c: Curvature (positive)

    Returns:
        Point on hyperboloid, shape (dim+1,). Satisfies ⟨x,x⟩_L = -1/c.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Convert Poincaré origin to hyperboloid origin
        >>> y_origin = jnp.array([0.0, 0.0])
        >>> x = isometry_mappings.poincare_to_hyperboloid(y_origin, c=1.0)
        >>> bool(jnp.allclose(x, jnp.array([1.0, 0.0, 0.0])))
        True

    References:
        Wikipedia: Hyperboloid model - Relation to other models
    """
    c = jnp.asarray(c, dtype=y.dtype)
    y_sqnorm = jnp.dot(y, y, precision=MATMUL_PRECISION)
    sqrt_c = jnp.sqrt(c)

    # Curvature-aware inverse stereographic projection. The spatial part scales
    # by the Poincaré conformal factor 1/(1 - c·||y||²); only the time component
    # carries the extra 1/√c, so the two denominators differ.
    # `_boundary_divisor_floor` is the floor `_conformal_factor` puts on this quantity: half its
    # analytic minimum over projected points. The computed value of a capped point lands from 6.2 eps
    # below that minimum to 6 eps above it (Poincaré expmap at c <= 0.3 also returns points farther
    # inside, up to 17 eps above in float32); floored at the minimum itself, as it was, it bound for
    # 12-76 % of the capped points and zeroed the Jacobian's dominant 4c·y/(1 - c‖y‖²)² terms
    # (relative gradient error 1.0; logs/2026-09-29_cancellation-free/floorfix2/). The half floor
    # still keeps an unprojected point outside the ball finite.
    one_minus = floor_at(1.0 - c * y_sqnorm, _boundary_divisor_floor(y, c))

    t = (1.0 + c * y_sqnorm) / (one_minus * sqrt_c)
    x_spatial = 2.0 * y / one_minus

    # Concatenate temporal and spatial components: [t, x_1, ..., x_n]
    return jnp.concatenate([t[None], x_spatial])

pv_to_poincare

pv_to_poincare(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Proper Velocity point to the Poincaré ball.

Implements the gyro-isomorphism π_{PV→P} of the PVNN paper (Chen et al. 2026, Eq. 4), proven to be a Riemannian isometry (their Thm 4.2). With hyperbolix's c > 0 convention (K = -c):

Formula: y = x / (1 + √(1 + c·||x||²))

This is the numerically stable form of y = β_x/(1 + β_x)·x with the PV beta factor β_x = 1/√(1 + c·||x||²): dividing numerator and denominator by β_x turns it into x / (1 + 1/β_x). The denominator is ≥ 2, so the map never blows up — every finite PV point lands strictly inside the radius-1/√c ball.

Args: x: Point in PV space (unconstrained R^n), shape (dim,). c: Curvature (positive).

Returns: Point in the Poincaré ball, shape (dim,). Satisfies ||y||² < 1/c.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # PV origin (0) maps to Poincaré origin (0) >>> y = isometry_mappings.pv_to_poincare(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(y, jnp.zeros(2))) True

References: Chen et al. "Proper Velocity Neural Networks." ICLR 2026, Eq. 4.

Source code in hyperbolix/manifolds/isometry_mappings.py
def pv_to_poincare(
    x: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Proper Velocity point to the Poincaré ball.

    Implements the gyro-isomorphism π_{PV→P} of the PVNN paper (Chen et al.
    2026, Eq. 4), proven to be a Riemannian isometry (their Thm 4.2). With
    hyperbolix's c > 0 convention (K = -c):

    Formula:
        y = x / (1 + √(1 + c·||x||²))

    This is the numerically stable form of ``y = β_x/(1 + β_x)·x`` with the PV
    beta factor ``β_x = 1/√(1 + c·||x||²)``: dividing numerator and denominator
    by β_x turns it into ``x / (1 + 1/β_x)``. The denominator is ≥ 2, so the map
    never blows up — every finite PV point lands strictly inside the radius-1/√c
    ball.

    Args:
        x: Point in PV space (unconstrained R^n), shape (dim,).
        c: Curvature (positive).

    Returns:
        Point in the Poincaré ball, shape (dim,). Satisfies ||y||² < 1/c.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # PV origin (0) maps to Poincaré origin (0)
        >>> y = isometry_mappings.pv_to_poincare(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(y, jnp.zeros(2)))
        True

    References:
        Chen et al. "Proper Velocity Neural Networks." ICLR 2026, Eq. 4.
    """
    # √(1 + c·||x||²) via `safe_hypot_norm`: `dot(x, x)` overflows float32 once ||x|| passes
    # 1.8e19/√c, and `x / (1 + inf)` then maps a far-out PV point to the *origin* instead of near
    # the ball boundary. `safe_hypot_norm` never materialises the square, and computes
    # `sqrt(1 + c||x||^2)` directly from the scaled input instead of rounding `safe_norm(x)` and
    # squaring it again (kept two-pass, unchanged from 1.2.0). Same form and the same measurement
    # as `ProperVelocity._beta_inv`; see there.
    sqrt_c = jnp.sqrt(jnp.asarray(c, dtype=x.dtype))
    beta_inv = safe_hypot_norm(sqrt_c * x, jnp.asarray(1.0, dtype=x.dtype))  # 1/β_x
    return x / (1.0 + beta_inv)

poincare_to_pv

poincare_to_pv(
    y: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Poincaré ball point to Proper Velocity space.

Inverse of :func:pv_to_poincare — the map π_{P→PV} of the PVNN paper (Chen et al. 2026, Eq. 4). With hyperbolix's c > 0 convention (K = -c):

Formula: x = 2·y / (1 - c·||y||²) = λ(y)·y

where λ(y) = 2/(1 - c·||y||²) is the Poincaré conformal factor. As y approaches the ball boundary (||y||² → 1/c) the image grows without bound — expected, since PV is the unconstrained R^n model. The denominator is floored at _boundary_divisor_floor(y, c) — half the smallest value it can take on a projected ball point, below the rounding band of a capped one (see :func:poincare_to_hyperboloid) — to avoid division by zero at the boundary.

Args: y: Point in the Poincaré ball, shape (dim,). Should satisfy ||y||² < 1/c. c: Curvature (positive).

Returns: Point in PV space (unconstrained R^n), shape (dim,).

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Poincaré origin (0) maps to PV origin (0) >>> x = isometry_mappings.poincare_to_pv(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(x, jnp.zeros(2))) True

References: Chen et al. "Proper Velocity Neural Networks." ICLR 2026, Eq. 4.

Source code in hyperbolix/manifolds/isometry_mappings.py
def poincare_to_pv(
    y: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Poincaré ball point to Proper Velocity space.

    Inverse of :func:`pv_to_poincare` — the map π_{P→PV} of the PVNN paper
    (Chen et al. 2026, Eq. 4). With hyperbolix's c > 0 convention (K = -c):

    Formula:
        x = 2·y / (1 - c·||y||²) = λ(y)·y

    where λ(y) = 2/(1 - c·||y||²) is the Poincaré conformal factor. As y
    approaches the ball boundary (||y||² → 1/c) the image grows without bound —
    expected, since PV is the *unconstrained* R^n model. The denominator is
    floored at ``_boundary_divisor_floor(y, c)`` — half the smallest value it can
    take on a projected ball point, below the rounding band of a capped one (see
    :func:`poincare_to_hyperboloid`) — to avoid division by zero at the boundary.

    Args:
        y: Point in the Poincaré ball, shape (dim,). Should satisfy ||y||² < 1/c.
        c: Curvature (positive).

    Returns:
        Point in PV space (unconstrained R^n), shape (dim,).

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Poincaré origin (0) maps to PV origin (0)
        >>> x = isometry_mappings.poincare_to_pv(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(x, jnp.zeros(2)))
        True

    References:
        Chen et al. "Proper Velocity Neural Networks." ICLR 2026, Eq. 4.
    """
    # `_boundary_divisor_floor`: the floor `_conformal_factor` puts on `1 - c‖y‖²`; see
    # :func:`poincare_to_hyperboloid`.
    c = jnp.asarray(c, dtype=y.dtype)
    denominator = floor_at(1.0 - c * jnp.dot(y, y, precision=MATMUL_PRECISION), _boundary_divisor_floor(y, c))
    return 2.0 * y / denominator

pv_to_hyperboloid

pv_to_hyperboloid(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim_plus_1]

Convert a Proper Velocity point to the hyperboloid model.

Uses the direct relation "proper velocity is the spatial part of the (dimensionless) 4-velocity": the PV coordinates are exactly the space-like hyperboloid components, and the time component is reconstructed from the Lorentz constraint ⟨z,z⟩_L = -1/c.

Formula: z = [√(1/c + ||x||²), x_1, ..., x_n]

This is an exact isometry (it equals poincare_to_hyperboloid(pv_to_poincare(x, c), c)) but avoids the near-boundary 1/(1 - c·||y||²) blow-up of the composed route — it is just a concatenation. The time component is ≥ 1/√c > 0, so the result is always a valid, numerically stable hyperboloid point.

Args: x: Point in PV space (unconstrained R^n), shape (dim,). c: Curvature (positive).

Returns: Point on the hyperboloid, shape (dim+1,). Satisfies ⟨z,z⟩_L = -1/c, z₀ > 0.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # PV origin maps to the hyperboloid origin [1/√c, 0, ...] >>> z = isometry_mappings.pv_to_hyperboloid(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(z, jnp.array([1.0, 0.0, 0.0]))) True

References: Ferreira. "Harmonic Analysis on the Proper Velocity Gyrogroup." Banach J. Math. Anal. 11(1), 21-49, 2017 — Sec. 2, the projection Π(x, √(t²+‖x‖²)) = x between the hyperboloid of radius t = 1/√c and PV space (t → 1/√c here). Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and Applications." World Scientific, 2005 — Def. 3.40, the PV gyrogroup.

Source code in hyperbolix/manifolds/isometry_mappings.py
def pv_to_hyperboloid(
    x: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim_plus_1"]:
    """Convert a Proper Velocity point to the hyperboloid model.

    Uses the direct relation "proper velocity is the spatial part of the
    (dimensionless) 4-velocity": the PV coordinates are exactly the space-like
    hyperboloid components, and the time component is reconstructed from the
    Lorentz constraint ⟨z,z⟩_L = -1/c.

    Formula:
        z = [√(1/c + ||x||²), x_1, ..., x_n]

    This is an exact isometry (it equals
    ``poincare_to_hyperboloid(pv_to_poincare(x, c), c)``) but avoids the
    near-boundary 1/(1 - c·||y||²) blow-up of the composed route — it is just a
    concatenation. The time component is ≥ 1/√c > 0, so the result is always a
    valid, numerically stable hyperboloid point.

    Args:
        x: Point in PV space (unconstrained R^n), shape (dim,).
        c: Curvature (positive).

    Returns:
        Point on the hyperboloid, shape (dim+1,). Satisfies ⟨z,z⟩_L = -1/c, z₀ > 0.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # PV origin maps to the hyperboloid origin [1/√c, 0, ...]
        >>> z = isometry_mappings.pv_to_hyperboloid(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(z, jnp.array([1.0, 0.0, 0.0])))
        True

    References:
        Ferreira. "Harmonic Analysis on the Proper Velocity Gyrogroup." Banach
        J. Math. Anal. 11(1), 21-49, 2017 — Sec. 2, the projection
        Π(x, √(t²+‖x‖²)) = x between the hyperboloid of radius t = 1/√c and
        PV space (t → 1/√c here).
        Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and
        Applications." World Scientific, 2005 — Def. 3.40, the PV gyrogroup.
    """
    # √(1/c + ||x||²) via `safe_hypot_norm` — the same shape as `Hyperboloid._proj`, and the same
    # fix: `dot(x, x)` overflows float32 past ||x|| = 1.8e19, returning an infinite time slot for
    # a point whose time slot is perfectly representable. `safe_hypot_norm`, not
    # `safe_hypot(safe_norm(x), .)`: it keeps `sum(x**2)` intact instead of rounding the norm and
    # squaring it again, which is what the hyperboloid constraint check cancels against.
    time = safe_hypot_norm(x, jnp.asarray(1.0, dtype=x.dtype) / jnp.sqrt(jnp.asarray(c, dtype=x.dtype)))
    return jnp.concatenate([time[None], x])

hyperboloid_to_pv

hyperboloid_to_pv(
    x: Float[Array, dim_plus_1], c: ScalarCurvature
) -> Float[Array, dim]

Convert a hyperboloid point to Proper Velocity space.

Inverse of :func:pv_to_hyperboloid: the PV coordinates are exactly the space-like components of the hyperboloid point, so the map simply drops the time component.

Formula: x = [z_1, ..., z_n] (drop the time component z₀)

The curvature c is unused (the relation is curvature-independent) but is kept in the signature for API symmetry with the other mappings.

Args: x: Point on the hyperboloid, shape (dim+1,). Should satisfy ⟨x,x⟩_L = -1/c. c: Curvature (positive). Unused.

Returns: Point in PV space (unconstrained R^n), shape (dim,).

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Hyperboloid origin [1/√c, 0, ...] maps to the PV origin (0) >>> x = isometry_mappings.hyperboloid_to_pv(jnp.array([1.0, 0.0, 0.0]), c=1.0) >>> bool(jnp.allclose(x, jnp.zeros(2))) True

References: Ferreira. "Harmonic Analysis on the Proper Velocity Gyrogroup." Banach J. Math. Anal. 11(1), 21-49, 2017 — Sec. 2, the projection Π(x, √(t²+‖x‖²)) = x between the hyperboloid of radius t = 1/√c and PV space (t → 1/√c here). Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and Applications." World Scientific, 2005 — Def. 3.40, the PV gyrogroup.

Source code in hyperbolix/manifolds/isometry_mappings.py
def hyperboloid_to_pv(
    x: Float[Array, "dim_plus_1"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a hyperboloid point to Proper Velocity space.

    Inverse of :func:`pv_to_hyperboloid`: the PV coordinates are exactly the
    space-like components of the hyperboloid point, so the map simply drops the
    time component.

    Formula:
        x = [z_1, ..., z_n]   (drop the time component z₀)

    The curvature ``c`` is unused (the relation is curvature-independent) but is
    kept in the signature for API symmetry with the other mappings.

    Args:
        x: Point on the hyperboloid, shape (dim+1,). Should satisfy ⟨x,x⟩_L = -1/c.
        c: Curvature (positive). Unused.

    Returns:
        Point in PV space (unconstrained R^n), shape (dim,).

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Hyperboloid origin [1/√c, 0, ...] maps to the PV origin (0)
        >>> x = isometry_mappings.hyperboloid_to_pv(jnp.array([1.0, 0.0, 0.0]), c=1.0)
        >>> bool(jnp.allclose(x, jnp.zeros(2)))
        True

    References:
        Ferreira. "Harmonic Analysis on the Proper Velocity Gyrogroup." Banach
        J. Math. Anal. 11(1), 21-49, 2017 — Sec. 2, the projection
        Π(x, √(t²+‖x‖²)) = x between the hyperboloid of radius t = 1/√c and
        PV space (t → 1/√c here).
        Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and
        Applications." World Scientific, 2005 — Def. 3.40, the PV gyrogroup.
    """
    del c  # curvature-independent: PV coords are the hyperboloid spatial part
    return x[1:]

klein_to_poincare

klein_to_poincare(
    k: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Beltrami-Klein point to the Poincaré ball.

The Einstein half map p = (1/2) ⊗_E k: with the Einstein Lorentz factor gamma_k = 1/√(1 - c·||k||²),

Formula: p = gamma_k/(1 + gamma_k)·k = k / (1 + √(1 - c·||k||²))

Both models use the radius-1/√c ball (curvature -c). The denominator is in [1, 2], so the map is well-conditioned; 1 - c·||k||² is floored at _boundary_divisor_floor(k, c) (see :func:_klein_gap). A Klein point has √c·||k|| = tanh(a) at scaled radius a = √c·d(0, k) where a Poincaré point has tanh(a/2), so the Klein chart runs out of float precision at half the Poincaré radius (a ≈ 6.3 float32, 13.9 float64 at c = 1).

Args: k: Point in the Klein ball, shape (dim,). Should satisfy ||k||² < 1/c. c: Curvature (positive).

Returns: Point in the Poincaré ball, shape (dim,). Satisfies ||p||² < 1/c.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Klein origin maps to Poincaré origin >>> p = isometry_mappings.klein_to_poincare(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(p, jnp.zeros(2))) True

References: Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and Applications." World Scientific, 2005 — Einstein ↔ Möbius isomorphism.

Source code in hyperbolix/manifolds/isometry_mappings.py
def klein_to_poincare(
    k: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Beltrami-Klein point to the Poincaré ball.

    The Einstein half map ``p = (1/2) ⊗_E k``: with the Einstein Lorentz factor
    ``gamma_k = 1/√(1 - c·||k||²)``,

    Formula:
        p = gamma_k/(1 + gamma_k)·k = k / (1 + √(1 - c·||k||²))

    Both models use the radius-1/√c ball (curvature -c). The denominator is in
    [1, 2], so the map is well-conditioned; ``1 - c·||k||²`` is floored at
    ``_boundary_divisor_floor(k, c)`` (see :func:`_klein_gap`). A Klein point has
    ``√c·||k|| = tanh(a)`` at scaled radius ``a = √c·d(0, k)`` where a Poincaré
    point has ``tanh(a/2)``, so the Klein chart runs out of float precision at
    half the Poincaré radius (``a ≈ 6.3`` float32, ``13.9`` float64 at c = 1).

    Args:
        k: Point in the Klein ball, shape (dim,). Should satisfy ||k||² < 1/c.
        c: Curvature (positive).

    Returns:
        Point in the Poincaré ball, shape (dim,). Satisfies ||p||² < 1/c.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Klein origin maps to Poincaré origin
        >>> p = isometry_mappings.klein_to_poincare(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(p, jnp.zeros(2)))
        True

    References:
        Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and
        Applications." World Scientific, 2005 — Einstein ↔ Möbius isomorphism.
    """
    c = jnp.asarray(c, dtype=k.dtype)
    # The gap is floored strictly positive, so the plain square root is safe and its derivative finite.
    return k / (1.0 + jnp.sqrt(_klein_gap(k, c)))

poincare_to_klein

poincare_to_klein(
    p: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Poincaré ball point to the Beltrami-Klein model.

Inverse of :func:klein_to_poincare: the Möbius doubling k = 2 ⊗_M p.

Formula: k = 2·p / (1 + c·||p||²)

The denominator is in [1, 2], so no floor is needed. The result is not projected. Since √c·||k|| = tanh(a) with a = √c·d(0, p), a Poincaré point beyond scaled radius ≈ 6.3 (float32) / 13.9 (float64) at c = 1 lands past the Klein.proj margin, and Klein operations read it at radius ≤ 6.67 / 14.21 (see the module docstring). Call Klein.proj on the result for such points.

Args: p: Point in the Poincaré ball, shape (dim,). Should satisfy ||p||² < 1/c. c: Curvature (positive).

Returns: Point in the closed Klein ball, shape (dim,). In float32, ||k|| can round to 1/√c beyond a ≈ 10; call Klein.proj before using such points.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Poincaré origin maps to Klein origin >>> k = isometry_mappings.poincare_to_klein(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(k, jnp.zeros(2))) True

References: Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and Applications." World Scientific, 2005 — Einstein ↔ Möbius isomorphism.

Source code in hyperbolix/manifolds/isometry_mappings.py
def poincare_to_klein(
    p: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Poincaré ball point to the Beltrami-Klein model.

    Inverse of :func:`klein_to_poincare`: the Möbius doubling ``k = 2 ⊗_M p``.

    Formula:
        k = 2·p / (1 + c·||p||²)

    The denominator is in [1, 2], so no floor is needed. The result is not
    projected. Since ``√c·||k|| = tanh(a)`` with ``a = √c·d(0, p)``, a Poincaré point
    beyond scaled radius ≈ 6.3 (float32) / 13.9 (float64) at c = 1 lands past the
    ``Klein.proj`` margin, and Klein operations read it at radius ≤ 6.67 / 14.21 (see
    the module docstring). Call ``Klein.proj`` on the result for such points.

    Args:
        p: Point in the Poincaré ball, shape (dim,). Should satisfy ||p||² < 1/c.
        c: Curvature (positive).

    Returns:
        Point in the closed Klein ball, shape (dim,). In float32, ``||k||`` can round
        to ``1/√c`` beyond a ≈ 10; call ``Klein.proj`` before using such points.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Poincaré origin maps to Klein origin
        >>> k = isometry_mappings.poincare_to_klein(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(k, jnp.zeros(2)))
        True

    References:
        Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and
        Applications." World Scientific, 2005 — Einstein ↔ Möbius isomorphism.
    """
    c = jnp.asarray(c, dtype=p.dtype)
    return 2.0 * p / (1.0 + c * jnp.dot(p, p, precision=MATMUL_PRECISION))

klein_to_hyperboloid

klein_to_hyperboloid(
    k: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim_plus_1]

Convert a Beltrami-Klein point to the hyperboloid model.

Inverse of the central projection from the ambient origin onto the plane x₀ = 1/√c (scaled by √c so the Klein ball has radius 1/√c).

Formula: x_s = k / √(1 - c·||k||²) = gamma_k·k x₀ = 1 / (√c·√(1 - c·||k||²)) = √(1/c + ||x_s||²)

The spatial part is :func:klein_to_pv; the time component is rebuilt from it with safe_hypot_norm exactly as :func:pv_to_hyperboloid does, so the result satisfies ⟨x,x⟩_L = -1/c to rounding even where 1 - c·||k||² is floored. The two time formulas agree in exact arithmetic.

Args: k: Point in the Klein ball, shape (dim,). Should satisfy ||k||² < 1/c. c: Curvature (positive).

Returns: Point on the hyperboloid, shape (dim+1,). Satisfies ⟨x,x⟩_L = -1/c, x₀ > 0.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Klein origin maps to the hyperboloid origin [1/√c, 0, ...] >>> x = isometry_mappings.klein_to_hyperboloid(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(x, jnp.array([1.0, 0.0, 0.0]))) True

References: Wikipedia: Hyperboloid model - Relation to other models

Source code in hyperbolix/manifolds/isometry_mappings.py
def klein_to_hyperboloid(
    k: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim_plus_1"]:
    """Convert a Beltrami-Klein point to the hyperboloid model.

    Inverse of the central projection from the ambient origin onto the plane
    ``x₀ = 1/√c`` (scaled by √c so the Klein ball has radius 1/√c).

    Formula:
        x_s = k / √(1 - c·||k||²) = gamma_k·k
        x₀  = 1 / (√c·√(1 - c·||k||²)) = √(1/c + ||x_s||²)

    The spatial part is :func:`klein_to_pv`; the time component is rebuilt from it
    with ``safe_hypot_norm`` exactly as :func:`pv_to_hyperboloid` does, so the
    result satisfies ``⟨x,x⟩_L = -1/c`` to rounding even where ``1 - c·||k||²`` is
    floored. The two time formulas agree in exact arithmetic.

    Args:
        k: Point in the Klein ball, shape (dim,). Should satisfy ||k||² < 1/c.
        c: Curvature (positive).

    Returns:
        Point on the hyperboloid, shape (dim+1,). Satisfies ⟨x,x⟩_L = -1/c, x₀ > 0.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Klein origin maps to the hyperboloid origin [1/√c, 0, ...]
        >>> x = isometry_mappings.klein_to_hyperboloid(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(x, jnp.array([1.0, 0.0, 0.0])))
        True

    References:
        Wikipedia: Hyperboloid model - Relation to other models
    """
    return pv_to_hyperboloid(klein_to_pv(k, c), c)

hyperboloid_to_klein

hyperboloid_to_klein(
    x: Float[Array, dim_plus_1], c: ScalarCurvature
) -> Float[Array, dim]

Convert a hyperboloid point to the Beltrami-Klein model.

Central projection from the ambient origin onto the plane x₀ = 1/√c.

Formula: k = x_s / (√c·x₀) where x = [x₀, x_s] on the hyperboloid (x₀ ≥ 1/√c)

hyperboloid_core.lorentz_scale writes the same map as φ_K(x) = x_s/x₀: that is the unit-ball Klein coordinate √c·k. Since √c·||k|| = ||x_s||/x₀ = tanh(a) at scaled radius a = √c·d(0, x), points beyond a ≈ 6.3 (float32) / 13.9 (float64) at c = 1 land past the Klein.proj margin (the result is not projected), and Klein operations read them at radius ≤ 6.67 / 14.21 (see the module docstring). Call Klein.proj on the result for such points.

Args: x: Point on the hyperboloid, shape (dim+1,). Should satisfy ⟨x,x⟩_L = -1/c. c: Curvature (positive).

Returns: Point in the closed Klein ball, shape (dim,). In float32, ||k|| can round to 1/√c beyond a ≈ 10; call Klein.proj before using such points.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Hyperboloid origin maps to the Klein origin >>> k = isometry_mappings.hyperboloid_to_klein(jnp.array([1.0, 0.0, 0.0]), c=1.0) >>> bool(jnp.allclose(k, jnp.zeros(2))) True

References: Wikipedia: Hyperboloid model - Relation to other models

Source code in hyperbolix/manifolds/isometry_mappings.py
def hyperboloid_to_klein(
    x: Float[Array, "dim_plus_1"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a hyperboloid point to the Beltrami-Klein model.

    Central projection from the ambient origin onto the plane ``x₀ = 1/√c``.

    Formula:
        k = x_s / (√c·x₀)
        where x = [x₀, x_s] on the hyperboloid (x₀ ≥ 1/√c)

    ``hyperboloid_core.lorentz_scale`` writes the same map as ``φ_K(x) = x_s/x₀``:
    that is the unit-ball Klein coordinate ``√c·k``. Since ``√c·||k|| =
    ||x_s||/x₀ = tanh(a)`` at scaled radius ``a = √c·d(0, x)``, points beyond
    ``a ≈ 6.3`` (float32) / ``13.9`` (float64) at c = 1 land past the ``Klein.proj``
    margin (the result is not projected), and Klein operations read them at radius
    ≤ 6.67 / 14.21 (see the module docstring). Call ``Klein.proj`` on the result for
    such points.

    Args:
        x: Point on the hyperboloid, shape (dim+1,). Should satisfy ⟨x,x⟩_L = -1/c.
        c: Curvature (positive).

    Returns:
        Point in the closed Klein ball, shape (dim,). In float32, ``||k||`` can round
        to ``1/√c`` beyond a ≈ 10; call ``Klein.proj`` before using such points.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Hyperboloid origin maps to the Klein origin
        >>> k = isometry_mappings.hyperboloid_to_klein(jnp.array([1.0, 0.0, 0.0]), c=1.0)
        >>> bool(jnp.allclose(k, jnp.zeros(2)))
        True

    References:
        Wikipedia: Hyperboloid model - Relation to other models
    """
    sqrt_c = jnp.sqrt(jnp.asarray(c, dtype=x.dtype))
    # √c·x₀ ≥ 1 on the hyperboloid; the floor only guards an off-manifold input, as in
    # :func:`hyperboloid_to_poincare`.
    return x[1:] / floor_at(sqrt_c * x[0], MIN_NORM)

klein_to_pv

klein_to_pv(
    k: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Beltrami-Klein point to Proper Velocity space.

A Klein point is an Einstein (coordinate) velocity; its proper velocity is the velocity times its Lorentz factor.

Formula: x = gamma_k·k = k / √(1 - c·||k||²)

The image grows without bound as k approaches the boundary (PV is the unconstrained model); 1 - c·||k||² is floored at _boundary_divisor_floor(k, c) (see :func:_klein_gap), reached at scaled radius a ≈ 6.7 (float32) / 14.2 (float64) at c = 1.

Args: k: Point in the Klein ball, shape (dim,). Should satisfy ||k||² < 1/c. c: Curvature (positive).

Returns: Point in PV space (unconstrained R^n), shape (dim,).

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Klein origin maps to the PV origin >>> x = isometry_mappings.klein_to_pv(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(x, jnp.zeros(2))) True

References: Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and Applications." World Scientific, 2005 — Einstein and PV gyrogroups.

Source code in hyperbolix/manifolds/isometry_mappings.py
def klein_to_pv(
    k: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Beltrami-Klein point to Proper Velocity space.

    A Klein point is an Einstein (coordinate) velocity; its proper velocity is
    the velocity times its Lorentz factor.

    Formula:
        x = gamma_k·k = k / √(1 - c·||k||²)

    The image grows without bound as k approaches the boundary (PV is the
    unconstrained model); ``1 - c·||k||²`` is floored at ``_boundary_divisor_floor(k, c)``
    (see :func:`_klein_gap`), reached at scaled radius ``a ≈ 6.7`` (float32) /
    ``14.2`` (float64) at c = 1.

    Args:
        k: Point in the Klein ball, shape (dim,). Should satisfy ||k||² < 1/c.
        c: Curvature (positive).

    Returns:
        Point in PV space (unconstrained R^n), shape (dim,).

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Klein origin maps to the PV origin
        >>> x = isometry_mappings.klein_to_pv(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(x, jnp.zeros(2)))
        True

    References:
        Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and
        Applications." World Scientific, 2005 — Einstein and PV gyrogroups.
    """
    c = jnp.asarray(c, dtype=k.dtype)
    # The gap is floored strictly positive, so the plain square root is safe and its derivative finite.
    return k / jnp.sqrt(_klein_gap(k, c))

pv_to_klein

pv_to_klein(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Proper Velocity point to the Beltrami-Klein model.

Inverse of :func:klein_to_pv: the Einstein velocity is the proper velocity times the PV beta factor β_x = 1/√(1 + c·||x||²).

Formula: k = β_x·x = x / √(1 + c·||x||²)

Every finite PV point lands inside the Klein ball in exact arithmetic. The result is not projected: in floating point a point beyond scaled radius ≈ 6.3 (float32) / 13.9 (float64) at c = 1 lands past the Klein.proj margin, and Klein operations read it at radius ≤ 6.67 / 14.21 (see the module docstring). Call Klein.proj on the result for such points.

Args: x: Point in PV space (unconstrained R^n), shape (dim,). c: Curvature (positive).

Returns: Point in the closed Klein ball, shape (dim,). In float32, ||k|| can round to 1/√c beyond a ≈ 10; call Klein.proj before using such points.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # PV origin maps to the Klein origin >>> k = isometry_mappings.pv_to_klein(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(k, jnp.zeros(2))) True

References: Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and Applications." World Scientific, 2005 — Einstein and PV gyrogroups.

Source code in hyperbolix/manifolds/isometry_mappings.py
def pv_to_klein(
    x: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Proper Velocity point to the Beltrami-Klein model.

    Inverse of :func:`klein_to_pv`: the Einstein velocity is the proper velocity
    times the PV beta factor ``β_x = 1/√(1 + c·||x||²)``.

    Formula:
        k = β_x·x = x / √(1 + c·||x||²)

    Every finite PV point lands inside the Klein ball in exact arithmetic. The
    result is not projected: in floating point a point beyond scaled radius ≈ 6.3
    (float32) / 13.9 (float64) at c = 1 lands past the ``Klein.proj`` margin, and
    Klein operations read it at radius ≤ 6.67 / 14.21 (see the module docstring).
    Call ``Klein.proj`` on the result for such points.

    Args:
        x: Point in PV space (unconstrained R^n), shape (dim,).
        c: Curvature (positive).

    Returns:
        Point in the closed Klein ball, shape (dim,). In float32, ``||k||`` can round
        to ``1/√c`` beyond a ≈ 10; call ``Klein.proj`` before using such points.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # PV origin maps to the Klein origin
        >>> k = isometry_mappings.pv_to_klein(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(k, jnp.zeros(2)))
        True

    References:
        Ungar. "Analytic Hyperbolic Geometry: Mathematical Foundations and
        Applications." World Scientific, 2005 — Einstein and PV gyrogroups.
    """
    # √(1 + c·||x||²) via `safe_hypot_norm`, overflow-free past ||x|| = 1.8e19/√c; same form as
    # :func:`pv_to_poincare`.
    sqrt_c = jnp.sqrt(jnp.asarray(c, dtype=x.dtype))
    beta_inv = safe_hypot_norm(sqrt_c * x, jnp.asarray(1.0, dtype=x.dtype))  # 1/β_x
    return x / beta_inv

halfspace_to_poincare

halfspace_to_poincare(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Poincaré half-space point to the Poincaré ball (the Cayley transform).

With x = (x_s, x_n), x_n > 0 (last coordinate), scaled coordinates s = √c·x and

Formula: q = c·||x_s||² + (√c·x_n - 1)(√c·x_n + 1) (= c·||x||² - 1) den = ||s_s||² + (1 + s_n)² p = (2·s_s, q) / (√c·den)

The half-space origin e_n/√c maps to the ball origin with differential exactly ½·I (no reflection); the positive x_n axis maps onto the e_n diameter, x_n → ∞ to the north pole e_n/√c and x_n → 0 to the boundary sphere.

Numerics: den is a sum of non-negative terms, at least 1 on the half-space, so no floor is needed. q is written as a product so it does not cancel near the sphere c·||x||² = 1 (the ball's equatorial plane p_n = 0). The result is not projected: past the ball chart's ceiling (scaled radius a ≈ 12.6 float32 / 27.7 float64 at c = 1) ||p|| lands beyond the proj margin, and in float32 from a ≈ 18 on at 1/√c up to rounding, as for every map into the ball — call Poincare.proj for such points. Past float32 |s| ≈ 1.8e19 the squares overflow and the output is NaN, not a saturated point.

Args: x: Point in the half-space, shape (dim,). Should satisfy x_n > 0. c: Curvature (positive).

Returns: Point in the Poincaré ball, shape (dim,). Satisfies ||p||² < 1/c.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Half-space origin e_n/√c maps to the Poincaré origin >>> p = isometry_mappings.halfspace_to_poincare(jnp.array([0.0, 0.0, 2.0]), c=0.25) >>> bool(jnp.allclose(p, jnp.zeros(3))) True

References: HTorch (github.com/ydtydr/HTorch), manifolds/halfspace.py — HalfSpace.to_poincare.

Source code in hyperbolix/manifolds/isometry_mappings.py
def halfspace_to_poincare(
    x: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Poincaré half-space point to the Poincaré ball (the Cayley transform).

    With ``x = (x_s, x_n)``, ``x_n > 0`` (last coordinate), scaled coordinates
    ``s = √c·x`` and

    Formula:
        q   = c·||x_s||² + (√c·x_n - 1)(√c·x_n + 1)       (= c·||x||² - 1)
        den = ||s_s||² + (1 + s_n)²
        p   = (2·s_s, q) / (√c·den)

    The half-space origin ``e_n/√c`` maps to the ball origin with differential
    exactly ``½·I`` (no reflection); the positive ``x_n`` axis maps onto the
    ``e_n`` diameter, ``x_n → ∞`` to the north pole ``e_n/√c`` and ``x_n → 0`` to
    the boundary sphere.

    Numerics: ``den`` is a sum of non-negative terms, at least 1 on the half-space,
    so no floor is needed. ``q`` is written as a product so it does not cancel
    near the sphere ``c·||x||² = 1`` (the ball's equatorial plane ``p_n = 0``). The
    result is not projected: past the ball chart's ceiling (scaled radius
    ``a ≈ 12.6`` float32 / ``27.7`` float64 at c = 1) ``||p||`` lands beyond the
    ``proj`` margin, and in float32 from ``a ≈ 18`` on at ``1/√c`` up to rounding,
    as for every map into the ball — call ``Poincare.proj`` for such points. Past
    float32 ``|s| ≈ 1.8e19`` the squares overflow and the output is NaN, not a
    saturated point.

    Args:
        x: Point in the half-space, shape (dim,). Should satisfy x_n > 0.
        c: Curvature (positive).

    Returns:
        Point in the Poincaré ball, shape (dim,). Satisfies ||p||² < 1/c.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Half-space origin e_n/√c maps to the Poincaré origin
        >>> p = isometry_mappings.halfspace_to_poincare(jnp.array([0.0, 0.0, 2.0]), c=0.25)
        >>> bool(jnp.allclose(p, jnp.zeros(3)))
        True

    References:
        HTorch (github.com/ydtydr/HTorch), ``manifolds/halfspace.py`` — ``HalfSpace.to_poincare``.
    """
    c = jnp.asarray(c, dtype=x.dtype)
    sqrt_c = jnp.sqrt(c)
    s_s = sqrt_c * x[:-1]
    s_n = sqrt_c * x[-1]
    s_s_sqnorm = jnp.dot(s_s, s_s, precision=MATMUL_PRECISION)

    # q = ||s||² - 1 as a product: the difference (s_n - 1) is exact near s_n = 1, so q keeps
    # its relative precision on the sphere ||s|| = 1 that maps to the equatorial plane p_n = 0.
    q = s_s_sqnorm + (s_n - 1.0) * (s_n + 1.0)
    den = s_s_sqnorm + (1.0 + s_n) ** 2  # ≥ 1 for s_n > 0: no floor
    return jnp.concatenate([2.0 * s_s, q[None]]) / (sqrt_c * den)

poincare_to_halfspace

poincare_to_halfspace(
    p: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Poincaré ball point to the Poincaré half-space (inverse Cayley transform).

Inverse of :func:halfspace_to_poincare. With scaled coordinates s = √c·p,

Formula: g = 1 - ||s||² (= 1 - c·||p||²) den = ||s_s||² + (s_n - 1)² (= ||s - e_n||²) x = (2·s_s, g) / (√c·den)

The ball origin maps to the half-space origin e_n/√c; the north pole e_n/√c is the half-space's point at infinity and every other boundary point lands on x_n = 0.

Numerics: g is floored at _boundary_divisor_floor(p, c) exactly as :func:poincare_to_hyperboloid floors 1 - c·||y||² — half the analytic minimum on a Poincare.proj-projected point, below the rounding band of a capped one — which keeps x_n > 0 for an unprojected point outside the ball. At the minimum itself the floor bound for 12-76 % of the capped points and zeroed ∂x_n/∂p = -2c·p/(√c·den) + … there (relative error 1.0). The ball chart ends at the proj margin, scaled radius a ≈ 12.6 (float32) / 27.7 (float64) at c = 1; a point past it is wherever Poincare.proj put it, and its image is the half-space point at that capped radius. den is not floored: it vanishes only at the north pole, a point the half-space cannot hold, so the output there is inf/NaN — loud, not a clamped finite point. On a projected point den ≥ (1 - ||s||)², about c·eps**1.5 at the margin (√c·eps**0.75 in the scaled s, squared), so the division is finite everywhere the ball is.

Args: p: Point in the Poincaré ball, shape (dim,). Should satisfy ||p||² < 1/c. c: Curvature (positive).

Returns: Point in the half-space, shape (dim,). Satisfies x_n > 0.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Poincaré origin maps to the half-space origin e_n/√c >>> x = isometry_mappings.poincare_to_halfspace(jnp.zeros(3), c=0.25) >>> bool(jnp.allclose(x, jnp.array([0.0, 0.0, 2.0]))) True

References: HTorch (github.com/ydtydr/HTorch), manifolds/halfspace.py — the inverse of HalfSpace.to_poincare.

Source code in hyperbolix/manifolds/isometry_mappings.py
def poincare_to_halfspace(
    p: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Poincaré ball point to the Poincaré half-space (inverse Cayley transform).

    Inverse of :func:`halfspace_to_poincare`. With scaled coordinates ``s = √c·p``,

    Formula:
        g   = 1 - ||s||²                                  (= 1 - c·||p||²)
        den = ||s_s||² + (s_n - 1)²                       (= ||s - e_n||²)
        x   = (2·s_s, g) / (√c·den)

    The ball origin maps to the half-space origin ``e_n/√c``; the north pole
    ``e_n/√c`` is the half-space's point at infinity and every other boundary
    point lands on ``x_n = 0``.

    Numerics: ``g`` is floored at ``_boundary_divisor_floor(p, c)`` exactly as
    :func:`poincare_to_hyperboloid` floors ``1 - c·||y||²`` — half the analytic
    minimum on a ``Poincare.proj``-projected point, below the rounding band of a
    capped one — which keeps ``x_n > 0`` for an unprojected point outside the ball.
    At the minimum itself the floor bound for 12-76 % of the capped points and
    zeroed ``∂x_n/∂p = -2c·p/(√c·den) + …`` there (relative error 1.0).
    The ball chart ends at the ``proj`` margin, scaled radius ``a ≈ 12.6``
    (float32) / ``27.7`` (float64) at c = 1; a point past it is wherever
    ``Poincare.proj`` put it, and its image is the half-space point at that
    capped radius. ``den`` is not floored: it vanishes only at the north pole,
    a point the half-space cannot hold, so the output there is ``inf``/NaN —
    loud, not a clamped finite point. On a projected point
    ``den ≥ (1 - ||s||)²``, about ``c·eps**1.5`` at the margin (``√c·eps**0.75``
    in the scaled ``s``, squared), so the division is finite everywhere the
    ball is.

    Args:
        p: Point in the Poincaré ball, shape (dim,). Should satisfy ||p||² < 1/c.
        c: Curvature (positive).

    Returns:
        Point in the half-space, shape (dim,). Satisfies x_n > 0.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Poincaré origin maps to the half-space origin e_n/√c
        >>> x = isometry_mappings.poincare_to_halfspace(jnp.zeros(3), c=0.25)
        >>> bool(jnp.allclose(x, jnp.array([0.0, 0.0, 2.0])))
        True

    References:
        HTorch (github.com/ydtydr/HTorch), ``manifolds/halfspace.py`` — the inverse of
        ``HalfSpace.to_poincare``.
    """
    c = jnp.asarray(c, dtype=p.dtype)
    sqrt_c = jnp.sqrt(c)
    s_s = sqrt_c * p[:-1]
    s_n = sqrt_c * p[-1]
    s_s_sqnorm = jnp.dot(s_s, s_s, precision=MATMUL_PRECISION)

    # `_boundary_divisor_floor`: the floor `_conformal_factor` puts on `1 - c‖p‖²`; see
    # `poincare_to_hyperboloid`. Here the gap is a numerator: the floor keeps `x_n > 0`.
    gap = floor_at(1.0 - c * jnp.dot(p, p, precision=MATMUL_PRECISION), _boundary_divisor_floor(p, c))
    den = s_s_sqnorm + (s_n - 1.0) ** 2  # zero only at the north pole (x_n = ∞): no floor
    return jnp.concatenate([2.0 * s_s, gap[None]]) / (sqrt_c * den)

halfspace_to_hyperboloid

halfspace_to_hyperboloid(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim_plus_1]

Convert a Poincaré half-space point to the hyperboloid model.

With x = (x_s, x_n), x_n > 0 (last coordinate), metric ||dx||²/(c·x_n²) and origin e_n/√c, the map sends the origin to the hyperboloid origin [1/√c, 0, ..., 0] and the vertical axis to the (X₀, X_n) plane. Let u_n = √c·x_n.

Formula: X_mid = x_s / (√c·x_n) (n-1 entries) X_n = (c·||x||² - 1) / (2c·x_n) = ||x_s||²/(2·x_n) + (u_n - 1)(u_n + 1)/(2c·x_n) X₀ = (c·||x||² + 1) / (2c·x_n) = √(1/c + ||X_mid||² + X_n²) X = [X₀, X_mid, X_n]

Numerics: the spatial part X_s = (X_mid, X_n) carries the point, and X₀ is rebuilt from it with safe_hypot_norm exactly as :func:pv_to_hyperboloid and :func:klein_to_hyperboloid do, so ⟨X,X⟩_L = -1/c holds to one rounding of X₀. X_n keeps c·x_n² - 1 in the factored form (u_n - 1)(u_n + 1): the literal c·||x||² - 1 rounds c·x_n² before subtracting and loses the relative accuracy of X_n near the origin (float32, 1e-3/√c around it, c ∈ {1, 4}: median relative error 3.5e-8 against 1.6e-5 for the literal; at other c the rounding of √c bounds both). Where c·||x||² ≈ 1 away from the axis (the hemisphere that maps to X_n = 0) the subtraction cancels in every spelling; the absolute error there is ~eps·X₀, the hyperboloid's own storage floor. ||x_s||²/(2·x_n) carries no factor of c, and it overflows float32 only once ||x_s|| passes 1.8e19, where X_n ≥ ||x_s|| is already past the hyperboloid's float32 coordinate ceiling, so the overflow is where the hyperboloid itself returns inf. x_n is not floored: every x_n > 0 is a valid point, and x_n ≤ 0 is off the model and returns inf/NaN. The result is not projected.

Args: x: Point in the half-space, shape (dim,). Should satisfy x_n = x[-1] > 0. c: Curvature (positive).

Returns: Point on the hyperboloid, shape (dim+1,). Satisfies ⟨X,X⟩_L = -1/c, X₀ > 0.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Half-space origin e_n/√c maps to the hyperboloid origin [1/√c, 0, ...] >>> X = isometry_mappings.halfspace_to_hyperboloid(jnp.array([0.0, 2.0]), c=0.25) >>> bool(jnp.allclose(X, jnp.array([2.0, 0.0, 0.0]))) True

References: HTorch (github.com/ydtydr/HTorch), manifolds/halfspace.py — HalfSpace.to_lorentz (time coordinate last there; first here).

Source code in hyperbolix/manifolds/isometry_mappings.py
def halfspace_to_hyperboloid(
    x: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim_plus_1"]:
    """Convert a Poincaré half-space point to the hyperboloid model.

    With ``x = (x_s, x_n)``, ``x_n > 0`` (last coordinate), metric ``||dx||²/(c·x_n²)`` and
    origin ``e_n/√c``, the map sends the origin to the hyperboloid origin ``[1/√c, 0, ..., 0]``
    and the vertical axis to the ``(X₀, X_n)`` plane. Let ``u_n = √c·x_n``.

    Formula:
        X_mid = x_s / (√c·x_n)                                    (n-1 entries)
        X_n   = (c·||x||² - 1) / (2c·x_n)
              = ||x_s||²/(2·x_n) + (u_n - 1)(u_n + 1)/(2c·x_n)
        X₀    = (c·||x||² + 1) / (2c·x_n) = √(1/c + ||X_mid||² + X_n²)
        X = [X₀, X_mid, X_n]

    Numerics: the spatial part ``X_s = (X_mid, X_n)`` carries the point, and ``X₀`` is rebuilt
    from it with ``safe_hypot_norm`` exactly as :func:`pv_to_hyperboloid` and
    :func:`klein_to_hyperboloid` do, so ``⟨X,X⟩_L = -1/c`` holds to one rounding of ``X₀``.
    ``X_n`` keeps ``c·x_n² - 1`` in the factored form ``(u_n - 1)(u_n + 1)``: the literal
    ``c·||x||² - 1`` rounds ``c·x_n²`` before subtracting and loses the relative accuracy of
    ``X_n`` near the origin (float32, 1e-3/√c around it, c ∈ {1, 4}: median relative error 3.5e-8
    against 1.6e-5 for the literal; at other ``c`` the rounding of ``√c`` bounds both). Where
    ``c·||x||² ≈ 1`` away from the axis (the hemisphere that maps to ``X_n = 0``) the subtraction
    cancels in every spelling; the absolute error there is ``~eps·X₀``, the hyperboloid's own
    storage floor. ``||x_s||²/(2·x_n)`` carries no factor of
    ``c``, and it overflows float32 only once ``||x_s||`` passes 1.8e19, where ``X_n ≥ ||x_s||``
    is already past the hyperboloid's float32 coordinate ceiling, so the overflow is where the
    hyperboloid itself returns ``inf``. ``x_n`` is not floored: every ``x_n > 0`` is a valid point,
    and ``x_n ≤ 0`` is off the model and returns ``inf``/NaN. The result is not projected.

    Args:
        x: Point in the half-space, shape (dim,). Should satisfy x_n = x[-1] > 0.
        c: Curvature (positive).

    Returns:
        Point on the hyperboloid, shape (dim+1,). Satisfies ⟨X,X⟩_L = -1/c, X₀ > 0.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Half-space origin e_n/√c maps to the hyperboloid origin [1/√c, 0, ...]
        >>> X = isometry_mappings.halfspace_to_hyperboloid(jnp.array([0.0, 2.0]), c=0.25)
        >>> bool(jnp.allclose(X, jnp.array([2.0, 0.0, 0.0])))
        True

    References:
        HTorch (github.com/ydtydr/HTorch), ``manifolds/halfspace.py`` — ``HalfSpace.to_lorentz``
        (time coordinate last there; first here).
    """
    c = jnp.asarray(c, dtype=x.dtype)
    sqrt_c = jnp.sqrt(c)
    x_s, x_n = x[:-1], x[-1]
    u_n = sqrt_c * x_n
    x_mid = x_s / u_n
    x_last = jnp.dot(x_s, x_s, precision=MATMUL_PRECISION) / (2.0 * x_n) + (u_n - 1.0) * ((u_n + 1.0) / (2.0 * c * x_n))
    x_spatial = jnp.concatenate([x_mid, x_last[None]])
    # √(1/c + ||X_s||²) in one overflow-free reduction; see :func:`pv_to_hyperboloid`.
    time = safe_hypot_norm(x_spatial, jnp.asarray(1.0, dtype=x.dtype) / sqrt_c)
    return jnp.concatenate([time[None], x_spatial])

hyperboloid_to_halfspace

hyperboloid_to_halfspace(
    x: Float[Array, dim_plus_1], c: ScalarCurvature
) -> Float[Array, dim]

Convert a hyperboloid point to the Poincaré half-space model.

Inverse of :func:halfspace_to_hyperboloid. With X = [X₀, X_mid, X_n] and Δ = X₀ - X_n > 0:

Formula: x_s = X_mid / (√c·Δ) x_n = 1 / (c·Δ)

Numerics: written literally, Δ is a difference of two O(sinh a) numbers whose result is O(e^{-a}) for points far up the vertical axis or out along the horosphere through the origin (X_n ≈ X₀). For X_n ≥ 0 the sheet constraint gives the cancellation-free form

Δ = (1/c + ||X_mid||²) / (X₀ + X_n),

and for X_n < 0 the literal X₀ - X_n is a sum of positive values. This is the spelling of hyperboloid._busemann_arg with v = e_n: the numerator is built from the spatial part, and the stored X₀ enters only the denominator (and the X_n < 0 branch). The unused denominator is X₀ + where(X_n ≥ 0, X_n, 0), positive in both branches, so neither branch produces a NaN cotangent under reverse mode. Δ is positive on the sheet, so no floor is needed. The result is not projected. Measured in float32 against a 60-digit oracle, c ∈ {0.3, 1, 4, 10}: median relative error 5e-8 far up the axis (√c·x_n up to 1e6) and ≤ 7e-8 in every other family. The literal X₀ - X_n gives 0.2 far up the axis, first returns inf at √c·x_n ≈ 6e3, and returns it for almost every point past 1e4.

Args: x: Point on the hyperboloid, shape (dim+1,). Should satisfy ⟨x,x⟩_L = -1/c. c: Curvature (positive).

Returns: Point in the half-space, shape (dim,). Satisfies x_n > 0.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Hyperboloid origin [1/√c, 0, ...] maps to the half-space origin e_n/√c >>> x = isometry_mappings.hyperboloid_to_halfspace(jnp.array([2.0, 0.0, 0.0]), c=0.25) >>> bool(jnp.allclose(x, jnp.array([0.0, 2.0]))) True

References: HTorch (github.com/ydtydr/HTorch), manifolds/halfspace.py — the inverse of HalfSpace.to_lorentz.

Source code in hyperbolix/manifolds/isometry_mappings.py
def hyperboloid_to_halfspace(
    x: Float[Array, "dim_plus_1"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a hyperboloid point to the Poincaré half-space model.

    Inverse of :func:`halfspace_to_hyperboloid`. With ``X = [X₀, X_mid, X_n]`` and
    ``Δ = X₀ - X_n > 0``:

    Formula:
        x_s = X_mid / (√c·Δ)
        x_n = 1 / (c·Δ)

    Numerics: written literally, ``Δ`` is a difference of two ``O(sinh a)`` numbers whose result
    is ``O(e^{-a})`` for points far up the vertical axis or out along the horosphere through the
    origin (``X_n ≈ X₀``). For ``X_n ≥ 0`` the sheet constraint gives the cancellation-free form

        Δ = (1/c + ||X_mid||²) / (X₀ + X_n),

    and for ``X_n < 0`` the literal ``X₀ - X_n`` is a sum of positive values. This is the spelling
    of ``hyperboloid._busemann_arg`` with ``v = e_n``: the numerator is built from the spatial
    part, and the stored ``X₀`` enters only the denominator (and the ``X_n < 0`` branch). The unused
    denominator is ``X₀ + where(X_n ≥ 0, X_n, 0)``, positive in both branches, so neither branch
    produces a NaN cotangent under reverse mode. ``Δ`` is positive on the sheet, so no floor is
    needed. The result is not projected. Measured in float32 against a 60-digit oracle, c ∈ {0.3,
    1, 4, 10}: median relative error 5e-8 far up the axis (``√c·x_n`` up to 1e6) and ≤ 7e-8 in
    every other family. The literal ``X₀ - X_n`` gives 0.2 far up the axis, first returns ``inf``
    at ``√c·x_n ≈ 6e3``, and returns it for almost every point past 1e4.

    Args:
        x: Point on the hyperboloid, shape (dim+1,). Should satisfy ⟨x,x⟩_L = -1/c.
        c: Curvature (positive).

    Returns:
        Point in the half-space, shape (dim,). Satisfies x_n > 0.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Hyperboloid origin [1/√c, 0, ...] maps to the half-space origin e_n/√c
        >>> x = isometry_mappings.hyperboloid_to_halfspace(jnp.array([2.0, 0.0, 0.0]), c=0.25)
        >>> bool(jnp.allclose(x, jnp.array([0.0, 2.0])))
        True

    References:
        HTorch (github.com/ydtydr/HTorch), ``manifolds/halfspace.py`` — the inverse of
        ``HalfSpace.to_lorentz``.
    """
    c = jnp.asarray(c, dtype=x.dtype)
    sqrt_c = jnp.sqrt(c)
    x0, x_mid, x_last = x[0], x[1:-1], x[-1]
    nonnegative = x_last >= 0
    denominator = x0 + jnp.where(nonnegative, x_last, jnp.zeros_like(x_last))
    rationalized = (1.0 / c + jnp.dot(x_mid, x_mid, precision=MATMUL_PRECISION)) / denominator
    gap = jnp.where(nonnegative, rationalized, x0 - x_last)  # Δ = X₀ - X_n
    return jnp.concatenate([x_mid / (sqrt_c * gap), (1.0 / (c * gap))[None]])

halfspace_to_klein

halfspace_to_klein(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Poincaré half-space point to the Beltrami-Klein model.

The hyperboloid lift X = ((||x||² + 1/c)/(2·x_n), x_s/(√c·x_n), (||x||² - 1/c)/(2·x_n)) followed by the central projection k = X_s/(√c·X₀) of :func:hyperboloid_to_klein, collapsed into one rational map. With x = (x_s, x_n), x_n > 0:

Formula: k = (2·x_s, (c·||x||² - 1)/√c) / (1 + c·||x||²)

The half-space origin e_n/√c maps to the Klein origin, and the axis x_s = 0 to the Klein diameter along e_n: x_n → ∞ reaches the north pole e_n/√c, x_n → 0 the south pole. The numerator c·||x||² - 1 vanishes at the origin; it is evaluated as c·||x_s||² + (√c·x_n - 1)(√c·x_n + 1), exact near the origin whenever √c·x_n is (c a power of 4, c = 1 included: float32 relative error of k_n at √c·x_n = 1 + 1e-4 is 0.2 eps against 840 eps for the literal c·||x||² - 1). At other c the rounding of √c limits both spellings alike, to a sub-eps absolute error on √c·k_n.

The result is not projected. Since √c·||k|| = tanh(a) with a = √c·d(o, x), a point beyond scaled radius ≈ 6.3 (float32) / 13.9 (float64) at c = 1 lands past the Klein.proj margin, and Klein operations read it at radius ≤ 6.67 / 14.21 (see the module docstring). Call Klein.proj on the result for such points. Past √c·||x|| ≈ 1.8e19 (float32, scaled radius ≈ 44) c·||x||² overflows and k_n is NaN.

Args: x: Point in the half-space, shape (dim,). Should satisfy x_n = x[-1] > 0. c: Curvature (positive).

Returns: Point in the closed Klein ball, shape (dim,). In float32, ||k|| can round to 1/√c beyond a ≈ 10; call Klein.proj before using such points.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Half-space origin e_n/√c maps to the Klein origin >>> k = isometry_mappings.halfspace_to_klein(jnp.array([0.0, 1.0]), c=1.0) >>> bool(jnp.allclose(k, jnp.zeros(2))) True

References: Wikipedia: Poincaré half-plane model / Beltrami-Klein model - Relation to other models

Source code in hyperbolix/manifolds/isometry_mappings.py
def halfspace_to_klein(
    x: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Poincaré half-space point to the Beltrami-Klein model.

    The hyperboloid lift ``X = ((||x||² + 1/c)/(2·x_n), x_s/(√c·x_n), (||x||² - 1/c)/(2·x_n))``
    followed by the central projection ``k = X_s/(√c·X₀)`` of :func:`hyperboloid_to_klein`,
    collapsed into one rational map. With ``x = (x_s, x_n)``, ``x_n > 0``:

    Formula:
        k = (2·x_s, (c·||x||² - 1)/√c) / (1 + c·||x||²)

    The half-space origin ``e_n/√c`` maps to the Klein origin, and the axis ``x_s = 0`` to the
    Klein diameter along ``e_n``: ``x_n → ∞`` reaches the north pole ``e_n/√c``, ``x_n → 0`` the
    south pole. The numerator ``c·||x||² - 1`` vanishes at the origin; it is evaluated as
    ``c·||x_s||² + (√c·x_n - 1)(√c·x_n + 1)``, exact near the origin whenever ``√c·x_n`` is (c a
    power of 4, c = 1 included: float32 relative error of ``k_n`` at ``√c·x_n = 1 + 1e-4`` is
    0.2 eps against 840 eps for the literal ``c·||x||² - 1``). At other c the rounding of √c
    limits both spellings alike, to a sub-eps absolute error on ``√c·k_n``.

    The result is not projected. Since ``√c·||k|| = tanh(a)`` with ``a = √c·d(o, x)``, a point
    beyond scaled radius ≈ 6.3 (float32) / 13.9 (float64) at c = 1 lands past the ``Klein.proj``
    margin, and Klein operations read it at radius ≤ 6.67 / 14.21 (see the module docstring). Call
    ``Klein.proj`` on the result for such points. Past ``√c·||x|| ≈ 1.8e19`` (float32, scaled
    radius ≈ 44) ``c·||x||²`` overflows and ``k_n`` is NaN.

    Args:
        x: Point in the half-space, shape (dim,). Should satisfy x_n = x[-1] > 0.
        c: Curvature (positive).

    Returns:
        Point in the closed Klein ball, shape (dim,). In float32, ``||k||`` can round
        to ``1/√c`` beyond a ≈ 10; call ``Klein.proj`` before using such points.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Half-space origin e_n/√c maps to the Klein origin
        >>> k = isometry_mappings.halfspace_to_klein(jnp.array([0.0, 1.0]), c=1.0)
        >>> bool(jnp.allclose(k, jnp.zeros(2)))
        True

    References:
        Wikipedia: Poincaré half-plane model / Beltrami-Klein model - Relation to other models
    """
    c = jnp.asarray(c, dtype=x.dtype)
    sqrt_c = jnp.sqrt(c)
    x_s, x_n = x[:-1], x[-1]
    c_xs_sqnorm = c * jnp.dot(x_s, x_s, precision=MATMUL_PRECISION)
    c_x_sqnorm = c_xs_sqnorm + c * x_n * x_n
    q = c_xs_sqnorm + (sqrt_c * x_n - 1.0) * (sqrt_c * x_n + 1.0)  # c·||x||² - 1 without cancellation
    # 1 + c·||x||² ≥ 1, so no floor is needed.
    return jnp.concatenate([2.0 * x_s, (q / sqrt_c)[None]]) / (1.0 + c_x_sqnorm)

klein_to_halfspace

klein_to_halfspace(
    k: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Beltrami-Klein point to the Poincaré half-space model.

Inverse of :func:halfspace_to_klein. With k = (k_s, k_n) and the Klein gap g_k = 1 - c·||k||²:

Formula: Δ = 1 - √c·k_n x = (k_s/Δ, √g_k/(√c·Δ))

Δ vanishes at the north pole e_n/√c (far up the half-space axis). For k_n > 0 it is evaluated as Δ = (1 - c·k_n²)/(1 + √c·k_n) with 1 - c·k_n² = g_k + c·||k_s||², so the only cancellation left is that of g_k (:func:_klein_gap), the Klein chart's own floor eps·cosh²(a) at scaled radius a = √c·d(0, k), and the rounded √c never enters a difference. Every spelling of Δ is limited by that same eps·cosh²(a) floor; the gap-based form above only removes the extra rounding that the literal 1 - √c·k_n adds on top of it.

g_k is floored at _boundary_divisor_floor(k, c), so every point of the closed ball maps to a finite half-space point with x_n > 0: a Klein point past the floor's radius, the north pole itself included, lands at the scaled radius ≈ 6.67 (float32) / 14.21 (float64) at c = 1 that the Klein operations read it at.

Args: k: Point in the Klein ball, shape (dim,). Should satisfy ||k||² < 1/c. c: Curvature (positive).

Returns: Point in the half-space, shape (dim,). Satisfies x_n = x[-1] > 0.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Klein origin maps to the half-space origin e_n/√c >>> x = isometry_mappings.klein_to_halfspace(jnp.zeros(2), c=1.0) >>> bool(jnp.allclose(x, jnp.array([0.0, 1.0]))) True

References: Wikipedia: Poincaré half-plane model / Beltrami-Klein model - Relation to other models

Source code in hyperbolix/manifolds/isometry_mappings.py
def klein_to_halfspace(
    k: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Beltrami-Klein point to the Poincaré half-space model.

    Inverse of :func:`halfspace_to_klein`. With ``k = (k_s, k_n)`` and the Klein gap
    ``g_k = 1 - c·||k||²``:

    Formula:
        Δ = 1 - √c·k_n
        x = (k_s/Δ, √g_k/(√c·Δ))

    ``Δ`` vanishes at the north pole ``e_n/√c`` (far up the half-space axis). For ``k_n > 0`` it is
    evaluated as ``Δ = (1 - c·k_n²)/(1 + √c·k_n)`` with ``1 - c·k_n² = g_k + c·||k_s||²``, so
    the only cancellation left is that of ``g_k`` (:func:`_klein_gap`), the Klein chart's own
    floor ``eps·cosh²(a)`` at scaled radius ``a = √c·d(0, k)``, and the rounded √c never enters a
    difference. Every spelling of ``Δ`` is limited by that same ``eps·cosh²(a)`` floor; the
    gap-based form above only removes the extra rounding that the literal ``1 - √c·k_n`` adds on
    top of it.

    ``g_k`` is floored at ``_boundary_divisor_floor(k, c)``, so every point of the closed ball maps
    to a finite half-space point with ``x_n > 0``: a Klein point past the floor's radius, the north
    pole itself included, lands at the scaled radius ≈ 6.67 (float32) / 14.21 (float64) at c = 1
    that the Klein operations read it at.

    Args:
        k: Point in the Klein ball, shape (dim,). Should satisfy ||k||² < 1/c.
        c: Curvature (positive).

    Returns:
        Point in the half-space, shape (dim,). Satisfies x_n = x[-1] > 0.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Klein origin maps to the half-space origin e_n/√c
        >>> x = isometry_mappings.klein_to_halfspace(jnp.zeros(2), c=1.0)
        >>> bool(jnp.allclose(x, jnp.array([0.0, 1.0])))
        True

    References:
        Wikipedia: Poincaré half-plane model / Beltrami-Klein model - Relation to other models
    """
    c = jnp.asarray(c, dtype=k.dtype)
    sqrt_c = jnp.sqrt(c)
    k_s, k_n = k[:-1], k[-1]
    gap = _klein_gap(k, c)
    # Double where: the unselected branch divides by 1 + √c·k_n, which is 0 at the south pole.
    k_n_pos = jnp.where(k_n > 0, k_n, 0.0)
    delta_north = (gap + c * jnp.dot(k_s, k_s, precision=MATMUL_PRECISION)) / (1.0 + sqrt_c * k_n_pos)
    delta = jnp.where(k_n > 0, delta_north, 1.0 - sqrt_c * k_n)
    # The gap is floored strictly positive, so the plain square root is safe and its derivative finite.
    return jnp.concatenate([k_s / delta, (jnp.sqrt(gap) / (sqrt_c * delta))[None]])

halfspace_to_pv

halfspace_to_pv(
    x: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Poincaré half-space point to Proper Velocity space.

PV coordinates are the space-like part of the hyperboloid point, so this is the spatial part of the half-space → hyperboloid lift. With x = (x_s, x_n), x_n > 0 the last coordinate:

Formula: u_s = x_s / (√c·x_n) u_n = (c·||x||² - 1) / (2c·x_n) = ½·(||x_s||²/x_n + (x_n - 1/√c)·(x_n + 1/√c)/x_n)

The second spelling of u_n is the one evaluated. The factor (x_n - 1/√c)(x_n + 1/√c) is x_n² - 1/c without cancellation near the origin x_n = 1/√c (u_n keeps its relative accuracy as it passes through 0), and ||x_s||²/x_n is formed as (x_s/x_n)·x_s, a sum of non-negative terms. Nothing is squared before a division by x_n, so no intermediate overflows where u itself is representable: float32 c·||x||² would overflow at x_n = 1.8e19/√c (scaled radius ≈ 44), where u_n ≈ x_n/2 is still finite. The input is not floored: x_n = 0 is off the model and returns inf.

Args: x: Point in the half-space, shape (dim,). Should satisfy x_n > 0. c: Curvature (positive).

Returns: Point in PV space (unconstrained R^n), shape (dim,).

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # Half-space origin e_n/√c maps to the PV origin (0) >>> u = isometry_mappings.halfspace_to_pv(jnp.array([0.0, 2.0]), c=0.25) >>> bool(jnp.allclose(u, jnp.zeros(2))) True

References: Wikipedia: Poincaré half-plane model / Hyperboloid model — the half-space ↔ hyperboloid relation (unit curvature, rescaled by 1/√c here).

Source code in hyperbolix/manifolds/isometry_mappings.py
def halfspace_to_pv(
    x: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Poincaré half-space point to Proper Velocity space.

    PV coordinates are the space-like part of the hyperboloid point, so this is the
    spatial part of the half-space → hyperboloid lift. With ``x = (x_s, x_n)``,
    ``x_n > 0`` the last coordinate:

    Formula:
        u_s = x_s / (√c·x_n)
        u_n = (c·||x||² - 1) / (2c·x_n)
            = ½·(||x_s||²/x_n + (x_n - 1/√c)·(x_n + 1/√c)/x_n)

    The second spelling of ``u_n`` is the one evaluated. The factor
    ``(x_n - 1/√c)(x_n + 1/√c)`` is ``x_n² - 1/c`` without cancellation near the
    origin ``x_n = 1/√c`` (``u_n`` keeps its relative accuracy as it passes through
    0), and ``||x_s||²/x_n`` is formed as ``(x_s/x_n)·x_s``, a sum of non-negative
    terms. Nothing is squared before a division by ``x_n``, so no intermediate
    overflows where ``u`` itself is representable: float32 ``c·||x||²`` would overflow
    at ``x_n = 1.8e19/√c`` (scaled radius ≈ 44), where ``u_n ≈ x_n/2`` is still
    finite. The input is not floored: ``x_n = 0`` is off the model and returns
    ``inf``.

    Args:
        x: Point in the half-space, shape (dim,). Should satisfy x_n > 0.
        c: Curvature (positive).

    Returns:
        Point in PV space (unconstrained R^n), shape (dim,).

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # Half-space origin e_n/√c maps to the PV origin (0)
        >>> u = isometry_mappings.halfspace_to_pv(jnp.array([0.0, 2.0]), c=0.25)
        >>> bool(jnp.allclose(u, jnp.zeros(2)))
        True

    References:
        Wikipedia: Poincaré half-plane model / Hyperboloid model — the
        half-space ↔ hyperboloid relation (unit curvature, rescaled by 1/√c here).
    """
    c = jnp.asarray(c, dtype=x.dtype)
    inv_sqrt_c = 1.0 / jnp.sqrt(c)
    x_s, x_n = x[:-1], x[-1]
    w_s = x_s / x_n  # √c·u_s
    # `dot` of an empty `x_s` (dim = 1) is exactly 0, so no dimension special case is needed.
    sq_s_over_n = jnp.dot(w_s, x_s, precision=MATMUL_PRECISION)  # ||x_s||²/x_n
    u_n = 0.5 * (sq_s_over_n + (x_n - inv_sqrt_c) * ((x_n + inv_sqrt_c) / x_n))
    return jnp.concatenate([w_s * inv_sqrt_c, u_n[None]])

pv_to_halfspace

pv_to_halfspace(
    u: Float[Array, dim], c: ScalarCurvature
) -> Float[Array, dim]

Convert a Proper Velocity point to the Poincaré half-space.

Inverse of :func:halfspace_to_pv. With u = (u_s, u_n) and the hyperboloid time slot X₀ = √(1/c + ||u||²):

Formula: Δ = X₀ - u_n (> 0) x = (u_s / (√c·Δ), 1 / (c·Δ))

Δ is evaluated without cancellation: for u_n > 0 (the upper half of the model, towards x_n → ∞) the literal X₀ - u_n subtracts two nearly equal numbers, so it is rewritten as

Δ = (1/c + ||u_s||²)/(X₀ + u_n) = (1/c)/s + (u_s/s)·u_s,   s = X₀ + u_n,

while for u_n ≤ 0 the literal form is a sum and is used as is. Each factor u_s/s is at most 1 in magnitude and every term is non-negative, so the ||u_s||² that would overflow float32 past ||u_s|| = 1.8e19 is never formed; X₀ comes from safe_hypot_norm for the same reason. The result is finite wherever it is representable. Measured in float32 far up the axis (u = (0.3, 0, u_n), c = 1, against a 150-digit reference): the literal X₀ - u_n gives x_n with relative error 7.9e-3 at u_n = 1e3, 0.26 at 3e3, and inf from u_n ≈ 4.1e3 (scaled radius ≈ 9) on; this form stays below 7e-8 out to u_n = 1e30, and at ||u_s|| = 3e19 (where the literal form returns x = 0) within 5e-8.

Args: u: Point in PV space (unconstrained R^n), shape (dim,). c: Curvature (positive).

Returns: Point in the half-space, shape (dim,). Satisfies x_n > 0.

Examples: >>> import jax.numpy as jnp >>> from hyperbolix.manifolds import isometry_mappings >>> >>> # PV origin maps to the half-space origin e_n/√c >>> x = isometry_mappings.pv_to_halfspace(jnp.zeros(2), c=0.25) >>> bool(jnp.allclose(x, jnp.array([0.0, 2.0]))) True

References: Wikipedia: Poincaré half-plane model / Hyperboloid model — the half-space ↔ hyperboloid relation (unit curvature, rescaled by 1/√c here).

Source code in hyperbolix/manifolds/isometry_mappings.py
def pv_to_halfspace(
    u: Float[Array, "dim"],
    c: ScalarCurvature,
) -> Float[Array, "dim"]:
    """Convert a Proper Velocity point to the Poincaré half-space.

    Inverse of :func:`halfspace_to_pv`. With ``u = (u_s, u_n)`` and the hyperboloid
    time slot ``X₀ = √(1/c + ||u||²)``:

    Formula:
        Δ = X₀ - u_n   (> 0)
        x = (u_s / (√c·Δ), 1 / (c·Δ))

    ``Δ`` is evaluated without cancellation: for ``u_n > 0`` (the upper half of the
    model, towards ``x_n → ∞``) the literal ``X₀ - u_n`` subtracts two nearly equal
    numbers, so it is rewritten as

        Δ = (1/c + ||u_s||²)/(X₀ + u_n) = (1/c)/s + (u_s/s)·u_s,   s = X₀ + u_n,

    while for ``u_n ≤ 0`` the literal form is a sum and is used as is. Each factor
    ``u_s/s`` is at most 1 in magnitude and every term is non-negative, so the
    ``||u_s||²`` that would overflow float32 past ``||u_s|| = 1.8e19`` is never formed;
    ``X₀`` comes from ``safe_hypot_norm`` for the same reason. The result is finite
    wherever it is representable. Measured in float32 far up the axis
    (``u = (0.3, 0, u_n)``, ``c = 1``, against a 150-digit reference): the literal
    ``X₀ - u_n`` gives ``x_n`` with relative error 7.9e-3 at ``u_n = 1e3``, 0.26 at
    ``3e3``, and ``inf`` from ``u_n ≈ 4.1e3`` (scaled radius ≈ 9) on; this form stays
    below 7e-8 out to ``u_n = 1e30``, and at ``||u_s|| = 3e19`` (where the literal form
    returns ``x = 0``) within 5e-8.

    Args:
        u: Point in PV space (unconstrained R^n), shape (dim,).
        c: Curvature (positive).

    Returns:
        Point in the half-space, shape (dim,). Satisfies x_n > 0.

    Examples:
        >>> import jax.numpy as jnp
        >>> from hyperbolix.manifolds import isometry_mappings
        >>>
        >>> # PV origin maps to the half-space origin e_n/√c
        >>> x = isometry_mappings.pv_to_halfspace(jnp.zeros(2), c=0.25)
        >>> bool(jnp.allclose(x, jnp.array([0.0, 2.0])))
        True

    References:
        Wikipedia: Poincaré half-plane model / Hyperboloid model — the
        half-space ↔ hyperboloid relation (unit curvature, rescaled by 1/√c here).
    """
    c = jnp.asarray(c, dtype=u.dtype)
    inv_c = 1.0 / c
    u_s, u_n = u[:-1], u[-1]
    # √(1/c + ||u||²) via `safe_hypot_norm`, overflow-free; same form as :func:`pv_to_hyperboloid`.
    time = safe_hypot_norm(u, jnp.sqrt(inv_c))
    upper = u_n > 0.0
    # Double `where`: on the `u_n ≤ 0` side `time + u_n` can round to 0 (u_n ≪ 0, u_s ≈ 0), and the
    # unselected branch's infinite derivative would still meet a zero cotangent as NaN.
    s = jnp.where(upper, time + u_n, time)
    delta_upper = inv_c / s + jnp.dot(u_s / s, u_s, precision=MATMUL_PRECISION)
    delta = jnp.where(upper, delta_upper, time - u_n)
    return jnp.concatenate([u_s / (jnp.sqrt(c) * delta), (1.0 / (c * delta))[None]])

Usage Examples

Basic Distance Computation

import jax.numpy as jnp
from hyperbolix.manifolds import Poincare

poincare = Poincare()

x = jnp.array([0.1, 0.2])
y = jnp.array([0.3, -0.1])
c = 1.0

# Compute distance (default: VERSION_MOBIUS_DIRECT)
distance = poincare.dist(x, y, c)

Float64 Precision

import jax

jax.config.update("jax_enable_x64", True)  # float64 needs x64 enabled

from hyperbolix.manifolds import Poincare
import jax.numpy as jnp

# High-precision manifold
poincare_f64 = Poincare(dtype=jnp.float64)

x = jnp.array([0.1, 0.2], dtype=jnp.float32)  # float32 input
y = jnp.array([0.3, -0.1], dtype=jnp.float32)
distance = poincare_f64.dist(x, y, c=1.0)  # automatically cast to float64
print(distance.dtype)  # float64

Batched Operations with vmap

import jax
from hyperbolix.manifolds import Hyperboloid

hyperboloid = Hyperboloid()
c = 1.0

# Batch of ambient points (d+1 dimensions)
x_batch = jax.random.normal(jax.random.PRNGKey(0), (100, 4))
y_batch = jax.random.normal(jax.random.PRNGKey(1), (100, 4))

# Project to hyperboloid
x_proj = jax.vmap(hyperboloid.proj, in_axes=(0, None))(x_batch, c)
y_proj = jax.vmap(hyperboloid.proj, in_axes=(0, None))(y_batch, c)

# Compute distances
distances = jax.vmap(hyperboloid.dist, in_axes=(0, 0, None))(x_proj, y_proj, c)

Exponential and Logarithmic Maps

from hyperbolix.manifolds import Poincare
import jax.numpy as jnp

poincare = Poincare()

# Point on manifold
x = poincare.proj(jnp.array([0.2, 0.3]), c=1.0)

# Tangent vector
v = jnp.array([0.1, -0.05])

# Exponential map (move along geodesic)
y = poincare.expmap(v, x, c=1.0)

# Logarithmic map (inverse operation)
v_recovered = poincare.logmap(y, x, c=1.0)

Proper Velocity Operations

import jax
import jax.numpy as jnp
from hyperbolix.manifolds import ProperVelocity

pv = ProperVelocity()
c = 1.0

# Points live in unconstrained R^n — no projection step needed
x = jnp.array([0.3, 0.5])
y = jnp.array([-0.2, 0.4])

# Geodesic distance (asinh form — stable over all of R^n)
d = pv.dist(x, y, c)

# Exp/log maps at the origin
v = jnp.array([0.1, -0.2])
y_moved = pv.expmap_0(v, c)
v_recovered = pv.logmap_0(y_moved, c)

# Euclidean gradient -> Riemannian gradient under the PV metric
grad_euc = jnp.array([1.0, 0.0])
grad_riem = pv.egrad2rgrad(grad_euc, x, c)

# Retraction is exact Euclidean addition (PV is unconstrained)
x_next = pv.retraction(v, x, c)
assert jnp.allclose(x_next, x + v)

Klein Operations

import jax.numpy as jnp
from hyperbolix.manifolds import Klein, isometry_mappings

klein = Klein()
c = 1.0

x = jnp.array([0.3, 0.5])   # points in the ball c‖x‖² < 1
y = jnp.array([-0.2, 0.4])

d = klein.dist(x, y, c)          # cancellation-free arsinh form
v = klein.logmap(y, x, c)        # parallel to the chord y - x
y_rec = klein.expmap(v, x, c)    # back to y

gamma = klein.lorentz_factor(x, c)                         # 1/√(1 - c‖x‖²)
m = klein.einstein_midpoint(jnp.stack([x, y]), None, c)    # = Lorentz centroid

# Einstein addition in Klein = Möbius addition in Poincaré, through the isometry
p = isometry_mappings.klein_to_poincare(x, c)
x_back = isometry_mappings.poincare_to_klein(p, c)

HalfSpace Operations

import jax.numpy as jnp
from hyperbolix.manifolds import HalfSpace, Poincare, isometry_mappings

halfspace = HalfSpace()
c = 1.0

x = jnp.array([0.1, 1.0])   # (x_s, x_n): the height x_n > 0 is the last coordinate
y = jnp.array([0.3, 0.5])

d = halfspace.dist(x, y, c)                # (2/√c)·asinh(‖r‖/2), cancellation-free
v = halfspace.logmap(y, x, c)              # tangent_norm(v, x, c) equals d
y_rec = halfspace.expmap(v, x, c)          # back to y
o = halfspace.expmap_0(jnp.zeros(2), c)    # the origin e_n/√c = [0, 1]

# The Cayley transform to the Poincaré ball preserves the distance
p_x = isometry_mappings.halfspace_to_poincare(x, c)
p_y = isometry_mappings.halfspace_to_poincare(y, c)
d_ball = Poincare().dist(p_x, p_y, c)                     # equals d
x_back = isometry_mappings.poincare_to_halfspace(p_x, c)  # round trip to x

Product Manifolds (Mixed Curvature)

import jax
import jax.numpy as jnp
from hyperbolix.manifolds import (
    ProductManifold, Hyperboloid, Poincare, Euclidean,
)

# Build P = H^5(c=1.0) x P^3(c=0.1) x E^4
product = ProductManifold(
    (Hyperboloid(c=1.0), 5),  # 5 = ambient dim (d+1) for hyperboloid
    (Poincare(c=0.1), 3),     # 3 = spatial dim for poincaré
    (Euclidean(), 4),         # 4 = standard euclidean dim
)

# Per-factor curvatures must be passed at call time as a sequence.
c = product.curvatures             # (1.0, 0.1, 0.0) — static default
o = product.origin(c)              # shape (12,)

# Pythagorean product distance: d_P = sqrt(sum d_i^2)
x = product.origin(c)
y = product.origin(c)  # generated elsewhere; here we use o for illustration
d_l2 = product.dist(x, y, c)               # scalar
d_per_factor = product.component_dist(x, y, c)  # shape (3,) per-factor distances

# Batch with vmap: broadcast c with None across the batch.
dist_batch = jax.vmap(product.dist, in_axes=(0, 0, None))
# distances = dist_batch(xs, ys, c)

# Repeated-factor construction via from_signature
mixed = ProductManifold.from_signature(
    (Hyperboloid, 5, 4, 1.0),   # 4 copies of H^4(c=1.0)
    (Poincare,    3, 2, 0.1),   # 2 copies of P^3(c=0.1)
    (Euclidean,   4, 1),         # 1 copy of E^4
)
# For learnable curvature, build the sequence from LearnableCurvature calls on
# your nnx.Module:
#   c = (self.curv_h(), self.curv_p(), 0.0)
#   d = product.dist(x, y, c)

Isometry Mappings

from hyperbolix.manifolds import isometry_mappings
import jax.numpy as jnp

# Hyperboloid point (ambient coordinates, d+1 dims)
x_hyperboloid = isometry_mappings.pv_to_hyperboloid(jnp.array([0.5, 0.3]), c=1.0)  # on the hyperboloid

# Map to Poincaré ball (intrinsic coordinates, d dims)
x_poincare = isometry_mappings.hyperboloid_to_poincare(x_hyperboloid, c=1.0)

# Map back (round-trip)
x_hyperboloid_recovered = isometry_mappings.poincare_to_hyperboloid(x_poincare, c=1.0)

Numerical Considerations

Float32 Precision

The Poincaré and Klein charts hold pairwise ops to a fixed scaled radius \(\sqrt{c}\,d\) in float32 (Poincaré 12.6, Klein 6.32 at \(c = 1\)). The hyperboloid has no fixed radius: its float32 error grows as \(\varepsilon\sinh(\sqrt{c}\,d)\) and loses its last digit between about 16.6 and 18. Past these, use float64 (jax_enable_x64 plus dtype=jnp.float64).

See the Numerical Stability guide for details.