hyperbolix 0.7.0__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/PKG-INFO +33 -10
  2. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/README.md +32 -9
  3. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/__init__.py +2 -0
  4. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/manifolds/__init__.py +2 -3
  5. hyperbolix-0.7.2/hyperbolix/manifolds/_base.py +34 -0
  6. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/manifolds/euclidean.py +38 -37
  7. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/manifolds/hyperboloid.py +59 -61
  8. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/manifolds/isometry_mappings.py +4 -2
  9. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/manifolds/poincare.py +59 -59
  10. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/manifolds/product.py +244 -134
  11. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/manifolds/proper_velocity.py +47 -49
  12. hyperbolix-0.7.2/hyperbolix/manifolds/protocol.py +91 -0
  13. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/_helpers.py +11 -1
  14. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/utils/__init__.py +2 -0
  15. hyperbolix-0.7.2/hyperbolix/utils/curvature.py +123 -0
  16. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/pyproject.toml +2 -1
  17. hyperbolix-0.7.0/hyperbolix/manifolds/_base.py +0 -57
  18. hyperbolix-0.7.0/hyperbolix/manifolds/protocol.py +0 -77
  19. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/distributions/__init__.py +0 -0
  20. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/distributions/_common.py +0 -0
  21. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/distributions/_wrapped_normal_base.py +0 -0
  22. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/distributions/uniform_poincare.py +0 -0
  23. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/distributions/wrapped_normal_hyperboloid.py +0 -0
  24. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/distributions/wrapped_normal_poincare.py +0 -0
  25. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/__init__.py +0 -0
  26. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hybrid_regularization.py +0 -0
  27. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hyperboloid_activations.py +0 -0
  28. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hyperboloid_attention.py +0 -0
  29. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hyperboloid_conv.py +0 -0
  30. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hyperboloid_core.py +0 -0
  31. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hyperboloid_linear.py +0 -0
  32. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hyperboloid_positional.py +0 -0
  33. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hyperboloid_regression.py +0 -0
  34. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/hyperboloid_regularization.py +0 -0
  35. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/poincare_activations.py +0 -0
  36. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/poincare_batchnorm.py +0 -0
  37. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/poincare_conv.py +0 -0
  38. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/poincare_linear.py +0 -0
  39. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/poincare_regression.py +0 -0
  40. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/pv_conv.py +0 -0
  41. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/pv_linear.py +0 -0
  42. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/nn_layers/pv_regression.py +0 -0
  43. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/optim/__init__.py +0 -0
  44. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/optim/_riemannian_base.py +0 -0
  45. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/optim/manifold_metadata.py +0 -0
  46. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/optim/riemannian_adam.py +0 -0
  47. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/optim/riemannian_sgd.py +0 -0
  48. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/utils/helpers.py +0 -0
  49. {hyperbolix-0.7.0 → hyperbolix-0.7.2}/hyperbolix/utils/math_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hyperbolix
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: Hyperbolic Deep Learning in JAX
5
5
  Keywords: hyperbolic,deep-learning,jax,flax,machine-learning,riemannian,poincare,hyperboloid,neural-networks,geometric-deep-learning
6
6
  Author: Timo Klein, Thomas Lang
@@ -42,7 +42,7 @@ Pure JAX implementation of hyperbolic deep learning with manifold operations, ne
42
42
  ## Features
43
43
 
44
44
  - 🌐 **5 Manifolds**: Euclidean, Poincaré Ball, Hyperboloid, Proper Velocity, and Product Manifold (mixed-curvature composition)
45
- - 🎛️ **Learnable Curvature**: Optional softplus-reparametrized `nnx.Param` curvature per manifold; with per-factor control in product spaces
45
+ - 🎛️ **Learnable Curvature**: `LearnableCurvature` module bundles parameter + reparameterization (softplus or log/exp) + optional clamp. Works with any `nnx.Optimizer` — no Riemannian optimizer needed
46
46
  - 🧠 **20+ Neural Network Layers**: Linear, convolutional, regression, attention, positional encoding, PV
47
47
  - ⚡ **5 Hyperbolic Activations**: ReLU, Leaky ReLU, Tanh, Swish, GELU
48
48
  - 📈 **Riemannian Optimizers**: RAdam and RSGD with automatic manifold detection
@@ -57,8 +57,8 @@ from flax import nnx
57
57
  from hyperbolix.manifolds import Poincare
58
58
  from hyperbolix.nn_layers import HypLinearPoincare
59
59
 
60
- # Class-based manifold instance (optionally float64 or learnable curvature)
61
- poincare = Poincare() # add dtype=jnp.float64 / learnable=True as needed
60
+ # Plain Python manifold class (optionally float64; pass `c=` for fixed curvature)
61
+ poincare = Poincare() # add dtype=jnp.float64 as needed
62
62
 
63
63
  # Manifold operations (single-point; use jax.vmap for batches)
64
64
  x = jnp.array([0.1, 0.2])
@@ -80,15 +80,20 @@ output = layer(x_batch, c=1.0)
80
80
  ```python
81
81
  from hyperbolix.manifolds import ProductManifold, Hyperboloid, Poincare, Euclidean
82
82
 
83
- # H^5 (learnable c) × P^3 (fixed c=0.1) × E^4 — points live in R^12
83
+ # H^5 × P^3 × E^4 — points live in R^12, each factor keeps its own curvature
84
84
  product = ProductManifold(
85
- (Hyperboloid(c=1.0, learnable=True), 5),
85
+ (Hyperboloid(c=1.0), 5),
86
86
  (Poincare(c=0.1), 3),
87
87
  (Euclidean(), 4),
88
88
  )
89
- d = product.dist(x, y) # sqrt(sum d_i^2) over factors
89
+ cs = product.curvatures # (1.0, 0.1, 0.0) — pass per-factor at call time
90
+ d = product.dist(x, y, cs) # sqrt(sum d_i^2) over factors
90
91
  ```
91
92
 
93
+ To make any factor's curvature trainable, store one `LearnableCurvature`
94
+ instance per factor on your model and call it to obtain `c` for per-factor
95
+ operations (see "Learnable curvature" below).
96
+
92
97
  ## Installation
93
98
 
94
99
  ```bash
@@ -112,11 +117,11 @@ Build docs locally: `uv run mkdocs serve`
112
117
 
113
118
  ## Key Concepts
114
119
 
115
- **Class-based manifolds, curvature passed at call time:** Each manifold is a `Manifold`-protocol-conformant class with automatic dtype casting; the curvature `c` is supplied per call so it can be static, dynamic, or even a learnable `nnx.Param`.
120
+ **Plain-class manifolds, curvature passed at call time:** Each manifold is a plain Python class (not an `nnx.Module`) with automatic dtype casting; the curvature `c` is supplied per call so it can be static, dynamic, or a traced `jax.Array` driven by a learnable parameter on your model.
116
121
 
117
122
  ```python
118
123
  from hyperbolix.manifolds import Poincare
119
- poincare = Poincare() # add dtype=jnp.float64 / learnable=True as needed
124
+ poincare = Poincare() # add dtype=jnp.float64 as needed
120
125
  dist = poincare.dist(x, y, c=1.0) # (dim,) → scalar
121
126
  ```
122
127
 
@@ -128,7 +133,25 @@ distances = jax.vmap(poincare.dist, in_axes=(0, 0, None))(
128
133
  )
129
134
  ```
130
135
 
131
- **Learnable curvature:** Pass `learnable=True` to any base manifold to expose `c` as a trainable `nnx.Param` via softplus reparameterization. In a `ProductManifold`, use the 5-tuple form of `from_signature` to learn some factors' curvatures while freezing others.
136
+ **Learnable curvature:** Use the `LearnableCurvature` module — assign one instance per distinct curvature in your model and call it to obtain a positive (optionally clamped) value. The manifold itself stays a fixed plain Python class, which keeps it out of the NNX state pytree (safe to share the same instance across layers and inside `nnx.scan` / `nnx.fori_loop`). The default clamp `[0.1, 10.0]` matches published reference ranges; pass `c_min=None, c_max=None` to disable. Use `parameterization="log"` (MERU-style) when `c` may span orders of magnitude or for long compiled training loops; the default `"softplus"` matches van Spengler 2023.
137
+
138
+ ```python
139
+ from hyperbolix import LearnableCurvature
140
+ from hyperbolix.manifolds import Hyperboloid
141
+
142
+ class Model(nnx.Module):
143
+ def __init__(self, rngs):
144
+ self.manifold = Hyperboloid(c=1.0) # static, shared
145
+ self.curvature = LearnableCurvature(init_c=1.0) # one per distinct c
146
+ self.fc = HypLinearHyperboloidPP(self.manifold, 33, 65, rngs=rngs)
147
+
148
+ def __call__(self, x):
149
+ c = self.curvature() # positive, clamped
150
+ return self.fc(x, c=c)
151
+
152
+ # Updated by any standard Euclidean optimizer — no Riemannian optimizer needed.
153
+ optimizer = nnx.Optimizer(model, optax.adam(1e-3), wrt=nnx.Param)
154
+ ```
132
155
 
133
156
  ## Citation
134
157
 
@@ -12,7 +12,7 @@ Pure JAX implementation of hyperbolic deep learning with manifold operations, ne
12
12
  ## Features
13
13
 
14
14
  - 🌐 **5 Manifolds**: Euclidean, Poincaré Ball, Hyperboloid, Proper Velocity, and Product Manifold (mixed-curvature composition)
15
- - 🎛️ **Learnable Curvature**: Optional softplus-reparametrized `nnx.Param` curvature per manifold; with per-factor control in product spaces
15
+ - 🎛️ **Learnable Curvature**: `LearnableCurvature` module bundles parameter + reparameterization (softplus or log/exp) + optional clamp. Works with any `nnx.Optimizer` — no Riemannian optimizer needed
16
16
  - 🧠 **20+ Neural Network Layers**: Linear, convolutional, regression, attention, positional encoding, PV
17
17
  - ⚡ **5 Hyperbolic Activations**: ReLU, Leaky ReLU, Tanh, Swish, GELU
18
18
  - 📈 **Riemannian Optimizers**: RAdam and RSGD with automatic manifold detection
@@ -27,8 +27,8 @@ from flax import nnx
27
27
  from hyperbolix.manifolds import Poincare
28
28
  from hyperbolix.nn_layers import HypLinearPoincare
29
29
 
30
- # Class-based manifold instance (optionally float64 or learnable curvature)
31
- poincare = Poincare() # add dtype=jnp.float64 / learnable=True as needed
30
+ # Plain Python manifold class (optionally float64; pass `c=` for fixed curvature)
31
+ poincare = Poincare() # add dtype=jnp.float64 as needed
32
32
 
33
33
  # Manifold operations (single-point; use jax.vmap for batches)
34
34
  x = jnp.array([0.1, 0.2])
@@ -50,15 +50,20 @@ output = layer(x_batch, c=1.0)
50
50
  ```python
51
51
  from hyperbolix.manifolds import ProductManifold, Hyperboloid, Poincare, Euclidean
52
52
 
53
- # H^5 (learnable c) × P^3 (fixed c=0.1) × E^4 — points live in R^12
53
+ # H^5 × P^3 × E^4 — points live in R^12, each factor keeps its own curvature
54
54
  product = ProductManifold(
55
- (Hyperboloid(c=1.0, learnable=True), 5),
55
+ (Hyperboloid(c=1.0), 5),
56
56
  (Poincare(c=0.1), 3),
57
57
  (Euclidean(), 4),
58
58
  )
59
- d = product.dist(x, y) # sqrt(sum d_i^2) over factors
59
+ cs = product.curvatures # (1.0, 0.1, 0.0) — pass per-factor at call time
60
+ d = product.dist(x, y, cs) # sqrt(sum d_i^2) over factors
60
61
  ```
61
62
 
63
+ To make any factor's curvature trainable, store one `LearnableCurvature`
64
+ instance per factor on your model and call it to obtain `c` for per-factor
65
+ operations (see "Learnable curvature" below).
66
+
62
67
  ## Installation
63
68
 
64
69
  ```bash
@@ -82,11 +87,11 @@ Build docs locally: `uv run mkdocs serve`
82
87
 
83
88
  ## Key Concepts
84
89
 
85
- **Class-based manifolds, curvature passed at call time:** Each manifold is a `Manifold`-protocol-conformant class with automatic dtype casting; the curvature `c` is supplied per call so it can be static, dynamic, or even a learnable `nnx.Param`.
90
+ **Plain-class manifolds, curvature passed at call time:** Each manifold is a plain Python class (not an `nnx.Module`) with automatic dtype casting; the curvature `c` is supplied per call so it can be static, dynamic, or a traced `jax.Array` driven by a learnable parameter on your model.
86
91
 
87
92
  ```python
88
93
  from hyperbolix.manifolds import Poincare
89
- poincare = Poincare() # add dtype=jnp.float64 / learnable=True as needed
94
+ poincare = Poincare() # add dtype=jnp.float64 as needed
90
95
  dist = poincare.dist(x, y, c=1.0) # (dim,) → scalar
91
96
  ```
92
97
 
@@ -98,7 +103,25 @@ distances = jax.vmap(poincare.dist, in_axes=(0, 0, None))(
98
103
  )
99
104
  ```
100
105
 
101
- **Learnable curvature:** Pass `learnable=True` to any base manifold to expose `c` as a trainable `nnx.Param` via softplus reparameterization. In a `ProductManifold`, use the 5-tuple form of `from_signature` to learn some factors' curvatures while freezing others.
106
+ **Learnable curvature:** Use the `LearnableCurvature` module — assign one instance per distinct curvature in your model and call it to obtain a positive (optionally clamped) value. The manifold itself stays a fixed plain Python class, which keeps it out of the NNX state pytree (safe to share the same instance across layers and inside `nnx.scan` / `nnx.fori_loop`). The default clamp `[0.1, 10.0]` matches published reference ranges; pass `c_min=None, c_max=None` to disable. Use `parameterization="log"` (MERU-style) when `c` may span orders of magnitude or for long compiled training loops; the default `"softplus"` matches van Spengler 2023.
107
+
108
+ ```python
109
+ from hyperbolix import LearnableCurvature
110
+ from hyperbolix.manifolds import Hyperboloid
111
+
112
+ class Model(nnx.Module):
113
+ def __init__(self, rngs):
114
+ self.manifold = Hyperboloid(c=1.0) # static, shared
115
+ self.curvature = LearnableCurvature(init_c=1.0) # one per distinct c
116
+ self.fc = HypLinearHyperboloidPP(self.manifold, 33, 65, rngs=rngs)
117
+
118
+ def __call__(self, x):
119
+ c = self.curvature() # positive, clamped
120
+ return self.fc(x, c=c)
121
+
122
+ # Updated by any standard Euclidean optimizer — no Riemannian optimizer needed.
123
+ optimizer = nnx.Optimizer(model, optax.adam(1e-3), wrt=nnx.Param)
124
+ ```
102
125
 
103
126
  ## Citation
104
127
 
@@ -1,8 +1,10 @@
1
1
  """Hyperbolix JAX backend - pure functional implementation."""
2
2
 
3
3
  from . import manifolds, utils
4
+ from .utils.curvature import LearnableCurvature
4
5
 
5
6
  __all__ = [
7
+ "LearnableCurvature",
6
8
  "manifolds",
7
9
  "utils",
8
10
  ]
@@ -1,16 +1,15 @@
1
1
  """JAX manifold implementations - class-based approach with dtype control."""
2
2
 
3
- # Import manifold classes
4
- # Import manifold modules for backwards compatibility
5
3
  from . import isometry_mappings
6
4
  from .euclidean import Euclidean
7
5
  from .hyperboloid import Hyperboloid
8
6
  from .poincare import Poincare
9
7
  from .product import ProductManifold
10
8
  from .proper_velocity import ProperVelocity
11
- from .protocol import Manifold
9
+ from .protocol import Curvature, Manifold
12
10
 
13
11
  __all__ = [
12
+ "Curvature",
14
13
  "Euclidean",
15
14
  "Hyperboloid",
16
15
  "Manifold",
@@ -0,0 +1,34 @@
1
+ """Shared base class for manifold implementations."""
2
+
3
+ import jax
4
+ import jax.numpy as jnp
5
+ from jaxtyping import Array
6
+
7
+
8
+ class ManifoldBase:
9
+ """Base class providing shared __init__, _cast, and static curvature.
10
+
11
+ Args:
12
+ dtype: Target JAX dtype for computations (default: jnp.float32)
13
+ c: Curvature value (default: 1.0).
14
+ """
15
+
16
+ def __init__(
17
+ self,
18
+ dtype: jnp.dtype = jnp.float32,
19
+ *,
20
+ c: float = 1.0,
21
+ ) -> None:
22
+ self.dtype = dtype
23
+ self._c_val = c
24
+
25
+ @property
26
+ def c(self) -> float:
27
+ """Current curvature value."""
28
+ return self._c_val
29
+
30
+ def _cast(self, x: Array) -> Array:
31
+ """Cast array to target dtype if it's a floating-point array."""
32
+ if isinstance(x, jax.Array) and jnp.issubdtype(x.dtype, jnp.inexact):
33
+ return x.astype(self.dtype)
34
+ return x
@@ -31,9 +31,10 @@ import jax.numpy as jnp
31
31
  from jaxtyping import Array, Float
32
32
 
33
33
  from ._base import ManifoldBase
34
+ from .protocol import Curvature
34
35
 
35
36
 
36
- def _proj(x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
37
+ def _proj(x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
37
38
  """Project point onto Euclidean space (identity operation).
38
39
 
39
40
  Args:
@@ -46,7 +47,7 @@ def _proj(x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
46
47
  return x
47
48
 
48
49
 
49
- def _addition(x: Float[Array, "dim"], y: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
50
+ def _addition(x: Float[Array, "dim"], y: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
50
51
  """Add Euclidean points x and y.
51
52
 
52
53
  Args:
@@ -60,7 +61,7 @@ def _addition(x: Float[Array, "dim"], y: Float[Array, "dim"], c: float = 0.0) ->
60
61
  return x + y
61
62
 
62
63
 
63
- def _scalar_mul(r: float, x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
64
+ def _scalar_mul(r: float, x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
64
65
  """Multiply Euclidean point x with scalar r.
65
66
 
66
67
  Args:
@@ -77,7 +78,7 @@ def _scalar_mul(r: float, x: Float[Array, "dim"], c: float = 0.0) -> Float[Array
77
78
  def _dist(
78
79
  x: Float[Array, "dim"],
79
80
  y: Float[Array, "dim"],
80
- c: float = 0.0,
81
+ c: Curvature = 0.0,
81
82
  ) -> Float[Array, ""]:
82
83
  """Compute geodesic distance between Euclidean points x and y.
83
84
 
@@ -92,7 +93,7 @@ def _dist(
92
93
  return jnp.linalg.norm(x - y)
93
94
 
94
95
 
95
- def _dist_0(x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, ""]:
96
+ def _dist_0(x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, ""]:
96
97
  """Compute geodesic distance from Euclidean origin to x.
97
98
 
98
99
  Args:
@@ -105,7 +106,7 @@ def _dist_0(x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, ""]:
105
106
  return jnp.linalg.norm(x)
106
107
 
107
108
 
108
- def _expmap(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
109
+ def _expmap(v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
109
110
  """Exponential map: map tangent vector v at point x to manifold.
110
111
 
111
112
  In Euclidean space, this is simply addition.
@@ -121,7 +122,7 @@ def _expmap(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> F
121
122
  return x + v
122
123
 
123
124
 
124
- def _expmap_0(v: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
125
+ def _expmap_0(v: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
125
126
  """Exponential map from origin: map tangent vector v at origin to manifold.
126
127
 
127
128
  In Euclidean space, this is identity.
@@ -136,7 +137,7 @@ def _expmap_0(v: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
136
137
  return v
137
138
 
138
139
 
139
- def _retraction(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
140
+ def _retraction(v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
140
141
  """Retraction: first-order approximation of exponential map.
141
142
 
142
143
  In Euclidean space, retraction equals exponential map (addition).
@@ -152,7 +153,7 @@ def _retraction(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0)
152
153
  return x + v
153
154
 
154
155
 
155
- def _logmap(y: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
156
+ def _logmap(y: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
156
157
  """Logarithmic map: map point y to tangent space at point x.
157
158
 
158
159
  In Euclidean space, this is subtraction.
@@ -168,7 +169,7 @@ def _logmap(y: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> F
168
169
  return y - x
169
170
 
170
171
 
171
- def _logmap_0(y: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
172
+ def _logmap_0(y: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
172
173
  """Logarithmic map from origin: map point y to tangent space at origin.
173
174
 
174
175
  In Euclidean space, this is identity.
@@ -187,7 +188,7 @@ def _ptransp(
187
188
  v: Float[Array, "dim"],
188
189
  x: Float[Array, "dim"],
189
190
  y: Float[Array, "dim"],
190
- c: float = 0.0,
191
+ c: Curvature = 0.0,
191
192
  ) -> Float[Array, "dim"]:
192
193
  """Parallel transport tangent vector v from point x to point y.
193
194
 
@@ -205,7 +206,7 @@ def _ptransp(
205
206
  return v
206
207
 
207
208
 
208
- def _ptransp_0(v: Float[Array, "dim"], y: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
209
+ def _ptransp_0(v: Float[Array, "dim"], y: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
209
210
  """Parallel transport tangent vector v from origin to point y.
210
211
 
211
212
  In Euclidean space, tangent spaces are identical everywhere (identity).
@@ -225,7 +226,7 @@ def _tangent_inner(
225
226
  u: Float[Array, "dim"],
226
227
  v: Float[Array, "dim"],
227
228
  x: Float[Array, "dim"],
228
- c: float = 0.0,
229
+ c: Curvature = 0.0,
229
230
  ) -> Float[Array, ""]:
230
231
  """Compute inner product of tangent vectors u and v at point x.
231
232
 
@@ -243,7 +244,7 @@ def _tangent_inner(
243
244
  return jnp.dot(u, v)
244
245
 
245
246
 
246
- def _tangent_norm(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, ""]:
247
+ def _tangent_norm(v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, ""]:
247
248
  """Compute norm of tangent vector v at point x.
248
249
 
249
250
  In Euclidean space, this is the standard L2 norm.
@@ -259,7 +260,7 @@ def _tangent_norm(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0
259
260
  return jnp.linalg.norm(v)
260
261
 
261
262
 
262
- def _egrad2rgrad(grad: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
263
+ def _egrad2rgrad(grad: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
263
264
  """Convert Euclidean gradient to Riemannian gradient.
264
265
 
265
266
  In Euclidean space, these are identical.
@@ -275,7 +276,7 @@ def _egrad2rgrad(grad: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0
275
276
  return grad
276
277
 
277
278
 
278
- def _tangent_proj(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
279
+ def _tangent_proj(v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
279
280
  """Project vector v onto tangent space at point x.
280
281
 
281
282
  In Euclidean space, tangent space is the entire space (identity).
@@ -291,7 +292,7 @@ def _tangent_proj(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0
291
292
  return v
292
293
 
293
294
 
294
- def _is_in_manifold(x: Float[Array, "dim"], c: float = 0.0) -> Array:
295
+ def _is_in_manifold(x: Float[Array, "dim"], c: Curvature = 0.0) -> Array:
295
296
  """Check if point x lies in Euclidean manifold.
296
297
 
297
298
  In Euclidean space, all points are valid.
@@ -306,7 +307,7 @@ def _is_in_manifold(x: Float[Array, "dim"], c: float = 0.0) -> Array:
306
307
  return jnp.array(True, dtype=bool)
307
308
 
308
309
 
309
- def _is_in_tangent_space(v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Array:
310
+ def _is_in_tangent_space(v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Array:
310
311
  """Check if vector v lies in tangent space at point x.
311
312
 
312
313
  In Euclidean space, all vectors are valid tangent vectors.
@@ -347,82 +348,82 @@ class Euclidean(ManifoldBase):
347
348
  """
348
349
 
349
350
  def __init__(self, dtype: jnp.dtype = jnp.float32) -> None:
350
- super().__init__(dtype, c=0.0, learnable=False)
351
+ super().__init__(dtype, c=0.0)
351
352
 
352
- def proj(self, x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
353
+ def proj(self, x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
353
354
  """Project point onto Euclidean space (identity)."""
354
355
  return _proj(self._cast(x), c)
355
356
 
356
- def addition(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
357
+ def addition(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
357
358
  """Add Euclidean points."""
358
359
  return _addition(self._cast(x), self._cast(y), c)
359
360
 
360
- def scalar_mul(self, r: float, x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
361
+ def scalar_mul(self, r: float, x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
361
362
  """Scalar multiplication."""
362
363
  x = self._cast(x)
363
364
  r_cast = jnp.asarray(r, dtype=x.dtype)
364
365
  return _scalar_mul(r_cast, x, c) # type: ignore[arg-type]
365
366
 
366
- def dist(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: float = 0.0) -> Float[Array, ""]:
367
+ def dist(self, x: Float[Array, "dim"], y: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, ""]:
367
368
  """Compute distance."""
368
369
  return _dist(self._cast(x), self._cast(y), c)
369
370
 
370
- def dist_0(self, x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, ""]:
371
+ def dist_0(self, x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, ""]:
371
372
  """Distance from origin."""
372
373
  return _dist_0(self._cast(x), c)
373
374
 
374
- def expmap(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
375
+ def expmap(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
375
376
  """Exponential map."""
376
377
  return _expmap(self._cast(v), self._cast(x), c)
377
378
 
378
- def expmap_0(self, v: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
379
+ def expmap_0(self, v: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
379
380
  """Exponential map from origin."""
380
381
  return _expmap_0(self._cast(v), c)
381
382
 
382
- def retraction(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
383
+ def retraction(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
383
384
  """Retraction."""
384
385
  return _retraction(self._cast(v), self._cast(x), c)
385
386
 
386
- def logmap(self, y: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
387
+ def logmap(self, y: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
387
388
  """Logarithmic map."""
388
389
  return _logmap(self._cast(y), self._cast(x), c)
389
390
 
390
- def logmap_0(self, y: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
391
+ def logmap_0(self, y: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
391
392
  """Logarithmic map from origin."""
392
393
  return _logmap_0(self._cast(y), c)
393
394
 
394
395
  def ptransp(
395
- self, v: Float[Array, "dim"], x: Float[Array, "dim"], y: Float[Array, "dim"], c: float = 0.0
396
+ self, v: Float[Array, "dim"], x: Float[Array, "dim"], y: Float[Array, "dim"], c: Curvature = 0.0
396
397
  ) -> Float[Array, "dim"]:
397
398
  """Parallel transport."""
398
399
  return _ptransp(self._cast(v), self._cast(x), self._cast(y), c)
399
400
 
400
- def ptransp_0(self, v: Float[Array, "dim"], y: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
401
+ def ptransp_0(self, v: Float[Array, "dim"], y: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
401
402
  """Parallel transport from origin."""
402
403
  return _ptransp_0(self._cast(v), self._cast(y), c)
403
404
 
404
405
  def tangent_inner(
405
- self, u: Float[Array, "dim"], v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0
406
+ self, u: Float[Array, "dim"], v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0
406
407
  ) -> Float[Array, ""]:
407
408
  """Tangent inner product."""
408
409
  return _tangent_inner(self._cast(u), self._cast(v), self._cast(x), c)
409
410
 
410
- def tangent_norm(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, ""]:
411
+ def tangent_norm(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, ""]:
411
412
  """Tangent norm."""
412
413
  return _tangent_norm(self._cast(v), self._cast(x), c)
413
414
 
414
- def egrad2rgrad(self, grad: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
415
+ def egrad2rgrad(self, grad: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
415
416
  """Euclidean to Riemannian gradient."""
416
417
  return _egrad2rgrad(self._cast(grad), self._cast(x), c)
417
418
 
418
- def tangent_proj(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Float[Array, "dim"]:
419
+ def tangent_proj(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Float[Array, "dim"]:
419
420
  """Project onto tangent space."""
420
421
  return _tangent_proj(self._cast(v), self._cast(x), c)
421
422
 
422
- def is_in_manifold(self, x: Float[Array, "dim"], c: float = 0.0) -> Array:
423
+ def is_in_manifold(self, x: Float[Array, "dim"], c: Curvature = 0.0) -> Array:
423
424
  """Check if on manifold."""
424
425
  return _is_in_manifold(self._cast(x), c)
425
426
 
426
- def is_in_tangent_space(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: float = 0.0) -> Array:
427
+ def is_in_tangent_space(self, v: Float[Array, "dim"], x: Float[Array, "dim"], c: Curvature = 0.0) -> Array:
427
428
  """Check if in tangent space."""
428
429
  return _is_in_tangent_space(self._cast(v), self._cast(x), c)