From 498c6ef60b2a526cf719dc3a84f130edf8270ca5 Mon Sep 17 00:00:00 2001 From: Nestor Demeure Date: Sun, 3 Nov 2019 13:26:18 +0100 Subject: [PATCH] added template for remove_column --- src/linalg/cholesky.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/linalg/cholesky.rs b/src/linalg/cholesky.rs index 7623e247..f63ab826 100644 --- a/src/linalg/cholesky.rs +++ b/src/linalg/cholesky.rs @@ -6,7 +6,7 @@ use alga::general::ComplexField; use crate::allocator::Allocator; use crate::base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, SquareMatrix}; use crate::constraint::{SameNumberOfRows, ShapeConstraint}; -use crate::dimension::{Dim, DimAdd, DimSum, DimSub, Dynamic, U1}; +use crate::dimension::{Dim, DimAdd, DimSum, DimDiff, DimSub, Dynamic, U1}; use crate::storage::{Storage, StorageMut}; use crate::base::allocator::Reallocator; @@ -217,6 +217,26 @@ where unimplemented!(); Cholesky { chol } } + + /// Updates the decomposition such that we get the decomposition of the factored matrix with its `j`th column removed. + /// Since the matrix is square, the `j`th row will also be removed. + pub fn remove_column( + self, + j: usize, + ) -> Cholesky> + where + D: DimSub, + DefaultAllocator: Reallocator> + Reallocator, DimDiff, DimDiff>, + { + let n = self.chol.nrows(); + assert!(j < n, "j needs to be within the bound of the matrix."); + // TODO what is the fastest way to produce the new matrix ? + let chol= self.chol.remove_column(j).remove_row(j); + + // TODO see https://en.wikipedia.org/wiki/Cholesky_decomposition#Updating_the_decomposition + unimplemented!(); + Cholesky { chol } + } } impl, S: Storage> SquareMatrix