pub struct SphericalSpace { /* private fields */ }Expand description
Spherical space operations
Implementations§
Source§impl SphericalSpace
impl SphericalSpace
Sourcepub fn new(ambient_dim: usize) -> Self
pub fn new(ambient_dim: usize) -> Self
Create a new spherical space S^{n-1} embedded in R^n
§Arguments
ambient_dim- Dimension of ambient Euclidean space
Sourcepub fn with_config(self, config: SphericalConfig) -> Self
pub fn with_config(self, config: SphericalConfig) -> Self
Set configuration
Sourcepub fn ambient_dim(&self) -> usize
pub fn ambient_dim(&self) -> usize
Get ambient dimension
Sourcepub fn intrinsic_dim(&self) -> usize
pub fn intrinsic_dim(&self) -> usize
Get intrinsic dimension (ambient_dim - 1)
Sourcepub fn is_on_sphere(&self, point: &[f64]) -> bool
pub fn is_on_sphere(&self, point: &[f64]) -> bool
Check if point is on the sphere
Sourcepub fn distance(&self, x: &[f64], y: &[f64]) -> Result<f64>
pub fn distance(&self, x: &[f64], y: &[f64]) -> Result<f64>
Geodesic distance on the sphere: d(x, y) = arccos(⟨x, y⟩)
This is the great-circle distance.
Sourcepub fn squared_distance(&self, x: &[f64], y: &[f64]) -> Result<f64>
pub fn squared_distance(&self, x: &[f64], y: &[f64]) -> Result<f64>
Squared geodesic distance (useful for optimization)
Sourcepub fn exp_map(&self, x: &[f64], v: &[f64]) -> Result<Vec<f64>>
pub fn exp_map(&self, x: &[f64], v: &[f64]) -> Result<Vec<f64>>
Exponential map: exp_x(v) - move from x in direction v
exp_x(v) = cos(||v||) x + sin(||v||) (v / ||v||)
Sourcepub fn log_map(&self, x: &[f64], y: &[f64]) -> Result<Vec<f64>>
pub fn log_map(&self, x: &[f64], y: &[f64]) -> Result<Vec<f64>>
Logarithmic map: log_x(y) - tangent vector at x pointing toward y
log_x(y) = (θ / sin(θ)) (y - cos(θ) x) where θ = d(x, y) = arccos(⟨x, y⟩)
Sourcepub fn parallel_transport(
&self,
x: &[f64],
y: &[f64],
v: &[f64],
) -> Result<Vec<f64>>
pub fn parallel_transport( &self, x: &[f64], y: &[f64], v: &[f64], ) -> Result<Vec<f64>>
Parallel transport vector v from x to y
Transports tangent vector at x along geodesic to y
Sourcepub fn frechet_mean(
&self,
points: &[Vec<f64>],
weights: Option<&[f64]>,
) -> Result<Vec<f64>>
pub fn frechet_mean( &self, points: &[Vec<f64>], weights: Option<&[f64]>, ) -> Result<Vec<f64>>
Fréchet mean on the sphere (spherical centroid)
Minimizes: Σᵢ wᵢ d(m, xᵢ)²
Sourcepub fn geodesic(&self, x: &[f64], y: &[f64], t: f64) -> Result<Vec<f64>>
pub fn geodesic(&self, x: &[f64], y: &[f64], t: f64) -> Result<Vec<f64>>
Geodesic interpolation: point at fraction t along geodesic from x to y
γ(t) = sin((1-t)θ)/sin(θ) x + sin(tθ)/sin(θ) y
Sourcepub fn sample_uniform(&self, rng: &mut impl Rng) -> Vec<f64>
pub fn sample_uniform(&self, rng: &mut impl Rng) -> Vec<f64>
Sample uniformly from the sphere
Trait Implementations§
Source§impl Clone for SphericalSpace
impl Clone for SphericalSpace
Source§fn clone(&self) -> SphericalSpace
fn clone(&self) -> SphericalSpace
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more