[][src]Trait gramschmidt::GramSchmidt

pub trait GramSchmidt: Sized {
    fn from_shape<T>(shape: T) -> Result<Self>
    where
        T: ShapeBuilder<Dim = Dim<[Ix; 2]>>
;
fn compute<S>(&mut self, a: &ArrayBase<S, Ix2>) -> Result<()>
    where
        S: Data<Elem = f64>
;
fn q(&self) -> &Array2<f64>;
fn r(&self) -> &Array2<f64>; fn compute_once<S>(
        a: &ArrayBase<S, Ix2>
    ) -> Result<(Array2<f64>, Array2<f64>)>
    where
        S: Data<Elem = f64>
, { ... }
fn from_matrix<S>(a: &ArrayBase<S, Ix2>) -> Result<Self>
    where
        S: Data<Elem = f64>
, { ... } }

Required methods

fn from_shape<T>(shape: T) -> Result<Self> where
    T: ShapeBuilder<Dim = Dim<[Ix; 2]>>, 

Reserves the memory for a QR decomposition via a classical Gram Schmidt orthogonalization using a shape.

The resulting object can be used to orthogonalize matrices of the same dimensions.

Example

use gramschmidt::{
    Classical,
    GramSchmidt,
    Result,
};


let mut cgs = Classical::from_shape((10,10))?;

fn compute<S>(&mut self, a: &ArrayBase<S, Ix2>) -> Result<()> where
    S: Data<Elem = f64>, 

Computes a QR decomposition using a Gram Schmidt orthonormalization of the matrix a.

The input matrix a has to have exactly the same dimension and memory layout as was previously configured. Returns an error otherwise.

extern crate openblas_src;

use gramschmidt::{GramSchmidt, Classical};
use ndarray::Array2;
use ndarray_rand::RandomExt;
use rand::distributions::Normal;


let matrix = Array2::random((10,10), Normal::new(0.0, 1.0));
let mut cgs = Classical::from_matrix(&matrix).unwrap();
cgs.compute(&matrix);

fn q(&self) -> &Array2<f64>

Return a reference to the matrix q.

fn r(&self) -> &Array2<f64>

Return a reference to the matrix q.

Loading content...

Provided methods

fn compute_once<S>(a: &ArrayBase<S, Ix2>) -> Result<(Array2<f64>, Array2<f64>)> where
    S: Data<Elem = f64>, 

One-off version of compute. Takes the matrix a to be factorized, allocates a type implementing the GramSchmidt trait, computes the QR decomposition, and returns clones of the Q and R matrices.

fn from_matrix<S>(a: &ArrayBase<S, Ix2>) -> Result<Self> where
    S: Data<Elem = f64>, 

Uses a matrix to reserve memory for a QR decomposition via a classical Gram Schmidt.

The resulting object can be used to orthogonalize matrices of the same dimensions.

Example

use ndarray::Array;
use gramschmidt::{
    Classical,
    GramSchmidt,
    Result,
};


let a = Array::zeros((10, 10));
let mut cgs = Classical::from_matrix(&a)?;
Loading content...

Implementors

impl GramSchmidt for Classical[src]

impl GramSchmidt for Modified[src]

impl GramSchmidt for Reorthogonalized[src]

Loading content...