pub struct TruncatedSvd<A: NdFloat, R: Rng> { /* private fields */ }
Expand description

Truncated singular value decomposition

Wraps the LOBPCG algorithm and provides convenient builder-pattern access to parameter like maximal iteration, precision and constrain matrix.

Implementations

Create a new truncated SVD problem

Parameters
  • problem: rectangular matrix which is decomposed
  • order: whether to return large or small (close to zero) singular values
  • rng: random number generator

Set the required precision of the solution

The precision is, in the context of SVD, the square-root precision of the underlying eigenproblem solution. The eigenproblem-precision is used to check the L2 error of each eigenvector and stops its optimization when the required precision is reached.

Set the maximal number of iterations

The LOBPCG is an iterative approach to eigenproblems and stops when this maximum number of iterations are reached

Calculate the singular value decomposition

Parameters
  • num: number of singular-value/vector pairs, ordered by magnitude
Example
use ndarray::{arr1, Array2};
use linfa_linalg::{Order, lobpcg::TruncatedSvd};
use rand::SeedableRng;
use rand_xoshiro::Xoshiro256Plus;

let diag = arr1(&[1., 2., 3., 4., 5.]);
let a = Array2::from_diag(&diag);

let eig = TruncatedSvd::new_with_rng(a, Order::Largest, Xoshiro256Plus::seed_from_u64(42))
   .precision(1e-4)
   .maxiter(500);

let res = eig.decompose(3);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.