Trait ndarray_linalg::krylov::Orthogonalizer

source ·
pub trait Orthogonalizer {
    type Elem: Scalar;

    // Required methods
    fn dim(&self) -> usize;
    fn len(&self) -> usize;
    fn tolerance(&self) -> <Self::Elem as Scalar>::Real;
    fn decompose<S>(
        &self,
        a: &mut ArrayBase<S, Ix1>,
    ) -> Coefficients<Self::Elem>
       where S: DataMut<Elem = Self::Elem>;
    fn coeff<S>(&self, a: ArrayBase<S, Ix1>) -> Coefficients<Self::Elem>
       where S: Data<Elem = Self::Elem>;
    fn append<S>(&mut self, a: ArrayBase<S, Ix1>) -> AppendResult<Self::Elem>
       where S: Data<Elem = Self::Elem>;
    fn div_append<S>(
        &mut self,
        a: &mut ArrayBase<S, Ix1>,
    ) -> AppendResult<Self::Elem>
       where S: DataMut<Elem = Self::Elem>;
    fn get_q(&self) -> Q<Self::Elem>;

    // Provided methods
    fn is_full(&self) -> bool { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

Trait for creating orthogonal basis from iterator of arrays

§Panic

  • if the size of the input array mismatches to the dimension

§Example

let mut mgs = MGS::new(3, 1e-9);
let coef = mgs.append(array![0.0, 1.0, 0.0]).into_coeff();
close_l2(&coef, &array![1.0], 1e-9);

let coef = mgs.append(array![1.0, 1.0, 0.0]).into_coeff();
close_l2(&coef, &array![1.0, 1.0], 1e-9);

// Fail if the vector is linearly dependent
assert!(mgs.append(array![1.0, 2.0, 0.0]).is_dependent());

// You can get coefficients of dependent vector
if let AppendResult::Dependent(coef) = mgs.append(array![1.0, 2.0, 0.0]) {
    close_l2(&coef, &array![2.0, 1.0, 0.0], 1e-9);
}

Required Associated Types§

Required Methods§

source

fn dim(&self) -> usize

Dimension of input array

source

fn len(&self) -> usize

Number of cached basis

source

fn tolerance(&self) -> <Self::Elem as Scalar>::Real

source

fn decompose<S>(&self, a: &mut ArrayBase<S, Ix1>) -> Coefficients<Self::Elem>
where S: DataMut<Elem = Self::Elem>,

Decompose given vector into the span of current basis and its tangent space

  • a becomes the tangent vector
  • The Coefficients to the current basis is returned.
source

fn coeff<S>(&self, a: ArrayBase<S, Ix1>) -> Coefficients<Self::Elem>
where S: Data<Elem = Self::Elem>,

Calculate the coefficient to the current basis basis

  • This will be faster than decompose because the construction of the residual vector may requires more Calculation
source

fn append<S>(&mut self, a: ArrayBase<S, Ix1>) -> AppendResult<Self::Elem>
where S: Data<Elem = Self::Elem>,

Add new vector if the residual is larger than relative tolerance

source

fn div_append<S>( &mut self, a: &mut ArrayBase<S, Ix1>, ) -> AppendResult<Self::Elem>
where S: DataMut<Elem = Self::Elem>,

Add new vector if the residual is larger than relative tolerance, and return the residual vector

source

fn get_q(&self) -> Q<Self::Elem>

Get Q-matrix of generated basis

Provided Methods§

source

fn is_full(&self) -> bool

check if the basis spans entire space

source

fn is_empty(&self) -> bool

Object Safety§

This trait is not object safe.

Implementors§