Skip to main content

LowRankApproximation

Struct LowRankApproximation 

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

High-level API for low-rank matrix approximation.

Implementations§

Source§

impl LowRankApproximation

Source

pub fn new(config: LowRankConfig) -> Self

Create a new approximation engine with the given configuration.

Source

pub fn approximate_matrix( &self, data: &[f64], rows: usize, cols: usize, ) -> Result<SvdResult, LowRankError>

Approximate a 2-D matrix stored in row-major order.

Source

pub fn approximate_matmul( &self, a: &[f64], a_rows: usize, a_cols: usize, b: &[f64], b_rows: usize, b_cols: usize, ) -> Result<Vec<f64>, LowRankError>

Approximate the matrix product A @ B using low-rank factors of A.

Rather than computing the full product C = A B (which is O(a_rows · a_cols · b_cols)), we approximate A ≈ U Σ Vᵀ (rank-k) and then compute C ≈ (U Σ) (Vᵀ B). This can be cheaper when rank << min(a_rows, a_cols).

Source

pub fn is_candidate(&self, rows: usize, cols: usize) -> bool

Return true if this matrix is large enough to be a candidate for low-rank approximation (based on min_dimension in the config).

Source

pub fn optimal_rank(singular_values: &[f64], energy_threshold: f64) -> usize

Compute the smallest rank k such that the top-k singular values capture at least energy_threshold fraction of the total singular energy.

energy_threshold should be in [0, 1]. If the slice is empty the function returns 0.

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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