Continuous Spaces

Continuous topological spaces and their properties.

spaces

Continuous measurable spaces for the hybrid architecture.

Continuous space objects serve as domains and codomains for continuous morphisms. They complement quivers.core.objects (FinSet etc.) used by discrete morphisms.

The space family is a sum type:

  • Euclidean — :math:\mathbb{R}^d with optional bounds
  • Simplex — probability simplex over d components
  • PositiveReals — :math:(0, \infty)^d
  • ProductSpace — cartesian product of continuous spaces

UnitInterval is a convenience factory for [0, 1]^d.

ContinuousSpace

Bases: TaggedUnion

Continuous measurable space (Euclidean, Simplex, PositiveReals, Product).

Variants expose name: str and dim: int either as fields (the atomic variants) or as derived properties (ProductSpace), plus a contains predicate over the support.

event_shape property

event_shape: tuple[int, ...]

Shape of a single sample.

contains

contains(x: Tensor) -> Tensor

Check whether points lie in the support.

Source code in src/quivers/continuous/spaces.py
43
44
45
def contains(self, x: torch.Tensor) -> torch.Tensor:
    """Check whether points lie in the support."""
    raise NotImplementedError(f"{type(self).__name__}.contains")

sample_uniform

sample_uniform(n: int) -> Tensor

Sample n points uniformly from the space.

Source code in src/quivers/continuous/spaces.py
47
48
49
50
51
def sample_uniform(self, n: int) -> torch.Tensor:
    """Sample n points uniformly from the space."""
    raise NotImplementedError(
        f"{type(self).__name__} does not support uniform sampling"
    )

Euclidean

Bases: ContinuousSpace

Euclidean space :math:\mathbb{R}^d, optionally bounded.

is_bounded property

is_bounded: bool

Whether the space has finite bounds on all sides.

Simplex

Bases: ContinuousSpace

The probability simplex :math:\{x \in \mathbb{R}^d : x_i \geq 0, \sum x_i = 1\}.

PositiveReals

Bases: ContinuousSpace

The positive reals :math:(0, \infty)^d.

CholeskyFactor

Bases: ContinuousSpace

The manifold of :math:K \times K lower-triangular Cholesky factors.

Each element is a lower-triangular matrix :math:L whose rows have unit norm: :math:L_{ii}^2 + \sum_{j<i} L_{ij}^2 = 1 for every :math:i. The product :math:L L^T is then a correlation matrix. The standard parameterization places :math:L on a :math:K(K-1)/2-dimensional manifold.

Carrier represented as a flat :math:K \times K array (row-major); the on-manifold constraint is enforced by the sampling family (quivers.continuous.families.LKJCorrelationFactor) and not by the type itself.

ProductSpace

Bases: ContinuousSpace

Cartesian product of continuous spaces (and discrete objects).

Components may be a mix of ContinuousSpace variants and quivers.core.objects.SetObject variants — programs whose domain or codomain combines discrete and continuous variables produce such a ProductSpace at compile time. Nested products are flattened on construction; name and dim are derived from components (for SetObject components, dim falls back to len(component.shape)).

Sphere

Bases: ContinuousSpace

The unit sphere :math:S^{N-1} = \{x \in \mathbb{R}^N : \|x\|_2 = 1\}.

Ambient dimension is dim = N; the manifold dimension is N - 1. Carrier represented as an (N,) tensor; the unit-norm constraint is enforced by the sampling family (e.g. von Mises-Fisher), not by the type itself.

Ball

Bases: ContinuousSpace

The closed ball :math:\{x \in \mathbb{R}^N : \|x\|_2 \le r\}.

Carrier represented as an (N,) tensor. The radius field fixes r; the default r = 1 produces the unit ball.

Covariance

Bases: ContinuousSpace

The cone of :math:D \times D symmetric positive-definite matrices.

Used as the codomain of Wishart-shaped families. Carrier represented as a flat (D*D,) tensor (row-major); the positivity constraint is enforced by the sampling family.

Correlation

Bases: ContinuousSpace

The manifold of :math:D \times D correlation matrices.

A correlation matrix is symmetric positive-definite with unit diagonal: :math:R_{ii} = 1 and :math:R \succ 0. Used as the codomain of LKJ correlation priors. Carrier represented as a flat (D*D,) tensor.

Orthogonal

Bases: ContinuousSpace

The orthogonal group :math:O(D) = \{Q \in \mathbb{R}^{D \times D} : Q^T Q = I\}.

Carrier represented as a flat (D*D,) tensor. The orthogonality constraint is enforced by the sampling family; sample_uniform produces Haar-distributed elements via QR decomposition of a standard Gaussian (the Mezzadri construction).

Stiefel

Bases: ContinuousSpace

The Stiefel manifold :math:V_K(\mathbb{R}^N) = \{X \in \mathbb{R}^{N \times K} : X^T X = I_K\}.

Generalises Orthogonal to rectangular orthonormal-column matrices. rows is :math:N, cols is :math:K; require :math:K \le N. The base dim field is :math:N, kept for the standard event_shape = (dim,) contract; the actual carrier is flat with shape (N*K,).

LowerTriangular

Bases: ContinuousSpace

The space of :math:D \times D lower-triangular matrices.

The carrier holds a flat (D*D,) tensor; the structural zero constraint on the strictly upper-triangular entries is enforced by the sampling family / parameterization. Used as a parameterization carrier for Cholesky-style decompositions when no diagonal-sign constraint is required.

Diagonal

Bases: ContinuousSpace

The space of :math:D \times D diagonal matrices.

Identified with :math:\mathbb{R}^D via the natural diagonal embedding; the carrier holds a flat (D,) tensor of diagonal entries. Used as the codomain of independent-variance parameterizations where each component carries its own scalar variance.

UnitInterval

UnitInterval(name: str, dim: int = 1) -> Euclidean

Create a :math:[0, 1]^d bounded Euclidean space.

Source code in src/quivers/continuous/spaces.py
 99
100
101
def UnitInterval(name: str, dim: int = 1) -> Euclidean:
    """Create a :math:`[0, 1]^d` bounded Euclidean space."""
    return Euclidean(name=name, dim=dim, low=0.0, high=1.0)