diff --git a/src/linalg/decompositions.rs b/src/linalg/decompositions.rs index 6c28b30f..6cb50153 100644 --- a/src/linalg/decompositions.rs +++ b/src/linalg/decompositions.rs @@ -11,11 +11,11 @@ use std::cmp::min; /// * `dim` - the dimension of the space the resulting matrix operates in /// * `start` - the starting dimension of the subspace of the reflexion /// * `vec` - the vector defining the reflection. -fn householder_matrix, +pub fn householder_matrix, V: Indexable> - (dim: uint, start: uint, vec: V) -> Mat { - let mut qk : Mat = Eye::new_identity(dim); + (dim: uint, start: uint, vec: V) -> M { + let mut qk : M = Eye::new_identity(dim); let stop = start + vec.shape(); assert!(stop <= dim); for j in range(start, stop) { @@ -35,12 +35,12 @@ fn householder_matrix + Norm, - Mat: Clone + Eye + ColSlice + Transpose - + Indexable<(uint, uint), N> + Mul> - (m: &Mat) -> (Mat, Mat) { + M: Clone + Eye + ColSlice + Transpose + + Indexable<(uint, uint), N> + Mul> + (m: &M) -> (M, M) { let (rows, cols) = m.shape(); assert!(rows >= cols); - let mut q : Mat = Eye::new_identity(rows); + let mut q : M = Eye::new_identity(rows); let mut r = m.clone(); let iterations = min(rows - 1, cols); @@ -59,7 +59,7 @@ pub fn decomp_qr>(observations: &M) -> N { // // +/// Construct the identity matrix for a given dimension +#[inline(always)] +pub fn new_identity(dim: uint) -> M { Eye::new_identity(dim) } + /* * Basis */