pub struct TruncatedEig<A: NdFloat, R: Rng> {
    pub constraints: Option<Array2<A>>,
    /* private fields */
}
Expand description

Truncated eigenproblem solver

This struct wraps the LOBPCG algorithm and provides convenient builder-pattern access to parameter like maximal iteration, precision and constraint matrix. Furthermore it allows conversion into a iterative solver where each iteration step yields a new eigenvalue/vector pair.

Example

use ndarray::{arr1, Array2};
use linfa_linalg::{Order, lobpcg::TruncatedEig};
use rand::SeedableRng;
use rand_xoshiro::Xoshiro256Plus;

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

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

let res = eig.decompose(3);

Fields

constraints: Option<Array2<A>>

Implementations

Create a new truncated eigenproblem solver

Properties
  • problem: problem matrix
  • order: ordering of the eigenvalues with Order
  • rng: random number generator

Set desired precision

This argument specifies the desired precision, which is passed to the LOBPCG solver. It controls at which point the opimization of each eigenvalue is stopped. The precision is global and applied to all eigenvalues with respect to their L2 norm.

If the precision can’t be reached and the maximum number of iteration is reached, then an error is returned in LobpcgResult.

Set the maximal number of iterations

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

Construct a solution, which is orthogonal to this

If a number of eigenvectors are already known, then this function can be used to construct a orthogonal subspace. Also used with an iterative approach.

Apply a preconditioner

A preconditioning matrix can speed up the solving process by improving the spectral distribution of the eigenvalues. It requires prior knowledge of the problem.

Calculate the eigenvalue decomposition

Parameters
  • num: number of eigenvalues ordered by magnitude
Example
use ndarray::{arr1, Array2};
use linfa_linalg::{Order, lobpcg::TruncatedEig};
use rand::SeedableRng;
use rand_xoshiro::Xoshiro256Plus;

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

let mut eig = TruncatedEig::new_with_rng(a, Order::Largest, Xoshiro256Plus::seed_from_u64(42))
   .precision(1e-5)
   .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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. 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.