SphericalSpace

Struct SphericalSpace 

Source
pub struct SphericalSpace { /* private fields */ }
Expand description

Spherical space operations

Implementations§

Source§

impl SphericalSpace

Source

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
Source

pub fn with_config(self, config: SphericalConfig) -> Self

Set configuration

Source

pub fn ambient_dim(&self) -> usize

Get ambient dimension

Source

pub fn intrinsic_dim(&self) -> usize

Get intrinsic dimension (ambient_dim - 1)

Source

pub fn project(&self, point: &[f64]) -> Result<Vec<f64>>

Project a point onto the sphere

Source

pub fn is_on_sphere(&self, point: &[f64]) -> bool

Check if point is on the sphere

Source

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.

Source

pub fn squared_distance(&self, x: &[f64], y: &[f64]) -> Result<f64>

Squared geodesic distance (useful for optimization)

Source

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||)

Source

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⟩)

Source

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

Source

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ᵢ)²

Source

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

Source

pub fn sample_uniform(&self, rng: &mut impl Rng) -> Vec<f64>

Sample uniformly from the sphere

Source

pub fn mean_direction(&self, points: &[Vec<f64>]) -> Result<Vec<f64>>

Von Mises-Fisher mean direction MLE

Computes the mean direction (mode of vMF distribution)

Trait Implementations§

Source§

impl Clone for SphericalSpace

Source§

fn clone(&self) -> SphericalSpace

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SphericalSpace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V