pub struct SubspaceEmbedding { /* private fields */ }Expand description
A random subspace embedding S: R^n → R^k (k × n projection matrix).
Implementations§
Source§impl SubspaceEmbedding
impl SubspaceEmbedding
Sourcepub fn new(config: SubspaceEmbeddingConfig) -> OptimizeResult<Self>
pub fn new(config: SubspaceEmbeddingConfig) -> OptimizeResult<Self>
Construct a new embedding according to config.
§Errors
Returns OptimizeError::InvalidInput if either dimension is zero.
Sourcepub fn project(&self, x: &Array1<f64>) -> OptimizeResult<Array1<f64>>
pub fn project(&self, x: &Array1<f64>) -> OptimizeResult<Array1<f64>>
Project a vector x ∈ R^n → y = Sx ∈ R^k.
§Errors
Returns OptimizeError::ValueError if x.len() != original_dim.
Sourcepub fn reconstruct(&self, y: &Array1<f64>) -> OptimizeResult<Array1<f64>>
pub fn reconstruct(&self, y: &Array1<f64>) -> OptimizeResult<Array1<f64>>
Approximate reconstruction x ≈ S^T y (pseudo-inverse via transpose).
§Errors
Returns OptimizeError::ValueError if y.len() != embedding_dim.
Sourcepub fn project_matrix(&self, a: &Array2<f64>) -> OptimizeResult<Array2<f64>>
pub fn project_matrix(&self, a: &Array2<f64>) -> OptimizeResult<Array2<f64>>
Project a matrix A ∈ R^{n×p} → SA ∈ R^{k×p}.
The embedding matrix S is k × n, so A must have n rows
(i.e., a.nrows() == original_dim).
§Errors
Returns OptimizeError::ValueError if a.nrows() != original_dim.
Sourcepub fn embedding_dim(&self) -> usize
pub fn embedding_dim(&self) -> usize
Embedding (sketch) dimension k.
Sourcepub fn original_dim(&self) -> usize
pub fn original_dim(&self) -> usize
Original dimension n.
Sourcepub fn jl_epsilon(&self, n_points: usize, delta: f64) -> f64
pub fn jl_epsilon(&self, n_points: usize, delta: f64) -> f64
Johnson-Lindenstrauss ε-distortion bound.
For n_points points and failure probability delta,
the embedding preserves all pairwise distances within factor (1 ± ε)
with probability at least 1 − delta.
Formula: ε = sqrt(2 * ln(n / δ) / k).
Auto Trait Implementations§
impl Freeze for SubspaceEmbedding
impl RefUnwindSafe for SubspaceEmbedding
impl Send for SubspaceEmbedding
impl Sync for SubspaceEmbedding
impl Unpin for SubspaceEmbedding
impl UnsafeUnpin for SubspaceEmbedding
impl UnwindSafe for SubspaceEmbedding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.