added template for remove_column

This commit is contained in:
Nestor Demeure 2019-11-03 13:26:18 +01:00 committed by Sébastien Crozet
parent e583e37d1c
commit 498c6ef60b

View File

@ -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<N, DimDiff<D, U1>>
where
D: DimSub<U1>,
DefaultAllocator: Reallocator<N, D, D, D, DimDiff<D, U1>> + Reallocator<N, D, DimDiff<D, U1>, DimDiff<D, U1>, DimDiff<D, U1>>,
{
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<N: ComplexField, D: DimSub<Dynamic>, S: Storage<N, D, D>> SquareMatrix<N, D, S>