| Crates.io | hyp |
| lib.rs | hyp |
| version | 0.1.0 |
| created_at | 2026-01-18 16:32:23.187454+00 |
| updated_at | 2026-01-18 16:32:23.187454+00 |
| description | Hyperbolic geometry: Poincare ball, Lorentz model, Mobius operations |
| homepage | |
| repository | https://github.com/arclabs561/hyp |
| max_upload_size | |
| id | 2052625 |
| size | 290,404 |
Hyperbolic geometry primitives for representation learning in non-Euclidean spaces. Implements the Poincare ball and Lorentz (hyperboloid) models for embedding hierarchical data.
Dual-licensed under MIT or Apache-2.0.
This crate is split into:
hyp::core: backend-agnostic implementations that operate on slices (&[T]) and return Vec<T>.
This is the “math substrate” layer.hyp’s ndarray API: kept behind the ndarray feature (enabled by default) for a convenient
concrete backend.use hyp::PoincareBall;
use ndarray::array;
let ball = PoincareBall::new(1.0); // curvature c=1
let x = array![0.1, 0.2];
let y = array![0.3, -0.1];
// Hyperbolic distance
let dist = ball.distance(&x.view(), &y.view());
// Mobius addition (hyperbolic translation)
let sum = ball.mobius_add(&x.view(), &y.view());
| Operation | Poincare | Lorentz |
|---|---|---|
| Distance | distance() |
distance() |
| Addition | mobius_add() |
- |
| Exp map | exp_map_zero() |
exp_map() |
| Log map | log_map_zero() |
log_map() |
| Project | project() |
project() |
cargo run --example graph_diagnostics: build small graphs, compute all-pairs shortest-path
distances, then measure:
testdata/karate_club.edgelistHYP_DATASET=lesmis or HYP_DATASET=florentine for other bundled graphsHYP_EDGELIST=/path/to/edges.txt to run on your own graphHyperbolic space has exponentially growing volume with radius, matching how trees have exponentially growing nodes with depth. A 10-dim hyperbolic space embeds trees that would need thousands of Euclidean dimensions.
c = 1.0 — Standard hyperbolic spacec > 1.0 — Stronger curvature (distances grow faster)c → 0 — Approaches Euclidean