use crate::storage::Storage;
use crate::{
Allocator, Bidiagonal, Cholesky, ColPivQR, ComplexField, DefaultAllocator, Dim, DimDiff,
DimMin, DimMinimum, DimSub, FullPivLU, Hessenberg, Matrix, RealField, Schur, SymmetricEigen,
SymmetricTridiagonal, LU, QR, SVD, U1, UDU,
};
impl<T: ComplexField, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
pub fn bidiagonalize(self) -> Bidiagonal<T, R, C>
where
R: DimMin<C>,
DimMinimum<R, C>: DimSub<U1>,
DefaultAllocator: Allocator<T, R, C>
+ Allocator<T, C>
+ Allocator<T, R>
+ Allocator<T, DimMinimum<R, C>>
+ Allocator<T, DimDiff<DimMinimum<R, C>, U1>>,
{
Bidiagonal::new(self.into_owned())
}
pub fn full_piv_lu(self) -> FullPivLU<T, R, C>
where
R: DimMin<C>,
DefaultAllocator: Allocator<T, R, C> + Allocator<(usize, usize), DimMinimum<R, C>>,
{
FullPivLU::new(self.into_owned())
}
pub fn lu(self) -> LU<T, R, C>
where
R: DimMin<C>,
DefaultAllocator: Allocator<T, R, C> + Allocator<(usize, usize), DimMinimum<R, C>>,
{
LU::new(self.into_owned())
}
pub fn qr(self) -> QR<T, R, C>
where
R: DimMin<C>,
DefaultAllocator: Allocator<T, R, C> + Allocator<T, R> + Allocator<T, DimMinimum<R, C>>,
{
QR::new(self.into_owned())
}
pub fn col_piv_qr(self) -> ColPivQR<T, R, C>
where
R: DimMin<C>,
DefaultAllocator: Allocator<T, R, C>
+ Allocator<T, R>
+ Allocator<T, DimMinimum<R, C>>
+ Allocator<(usize, usize), DimMinimum<R, C>>,
{
ColPivQR::new(self.into_owned())
}
pub fn svd(self, compute_u: bool, compute_v: bool) -> SVD<T, R, C>
where
R: DimMin<C>,
DimMinimum<R, C>: DimSub<U1>, DefaultAllocator: Allocator<T, R, C>
+ Allocator<T, C>
+ Allocator<T, R>
+ Allocator<T, DimDiff<DimMinimum<R, C>, U1>>
+ Allocator<T, DimMinimum<R, C>, C>
+ Allocator<T, R, DimMinimum<R, C>>
+ Allocator<T, DimMinimum<R, C>>
+ Allocator<T::RealField, DimMinimum<R, C>>
+ Allocator<T::RealField, DimDiff<DimMinimum<R, C>, U1>>,
{
SVD::new(self.into_owned(), compute_u, compute_v)
}
pub fn try_svd(
self,
compute_u: bool,
compute_v: bool,
eps: T::RealField,
max_niter: usize,
) -> Option<SVD<T, R, C>>
where
R: DimMin<C>,
DimMinimum<R, C>: DimSub<U1>, DefaultAllocator: Allocator<T, R, C>
+ Allocator<T, C>
+ Allocator<T, R>
+ Allocator<T, DimDiff<DimMinimum<R, C>, U1>>
+ Allocator<T, DimMinimum<R, C>, C>
+ Allocator<T, R, DimMinimum<R, C>>
+ Allocator<T, DimMinimum<R, C>>
+ Allocator<T::RealField, DimMinimum<R, C>>
+ Allocator<T::RealField, DimDiff<DimMinimum<R, C>, U1>>,
{
SVD::try_new(self.into_owned(), compute_u, compute_v, eps, max_niter)
}
}
impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> Matrix<T, D, D, S> {
pub fn cholesky(self) -> Option<Cholesky<T, D>>
where
DefaultAllocator: Allocator<T, D, D>,
{
Cholesky::new(self.into_owned())
}
pub fn udu(self) -> Option<UDU<T, D>>
where
T: RealField,
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
{
UDU::new(self.into_owned())
}
pub fn hessenberg(self) -> Hessenberg<T, D>
where
D: DimSub<U1>,
DefaultAllocator: Allocator<T, D, D> + Allocator<T, D> + Allocator<T, DimDiff<D, U1>>,
{
Hessenberg::new(self.into_owned())
}
pub fn schur(self) -> Schur<T, D>
where
D: DimSub<U1>, DefaultAllocator: Allocator<T, D, DimDiff<D, U1>>
+ Allocator<T, DimDiff<D, U1>>
+ Allocator<T, D, D>
+ Allocator<T, D>,
{
Schur::new(self.into_owned())
}
pub fn try_schur(self, eps: T::RealField, max_niter: usize) -> Option<Schur<T, D>>
where
D: DimSub<U1>, DefaultAllocator: Allocator<T, D, DimDiff<D, U1>>
+ Allocator<T, DimDiff<D, U1>>
+ Allocator<T, D, D>
+ Allocator<T, D>,
{
Schur::try_new(self.into_owned(), eps, max_niter)
}
pub fn symmetric_eigen(self) -> SymmetricEigen<T, D>
where
D: DimSub<U1>,
DefaultAllocator: Allocator<T, D, D>
+ Allocator<T, DimDiff<D, U1>>
+ Allocator<T::RealField, D>
+ Allocator<T::RealField, DimDiff<D, U1>>,
{
SymmetricEigen::new(self.into_owned())
}
pub fn try_symmetric_eigen(
self,
eps: T::RealField,
max_niter: usize,
) -> Option<SymmetricEigen<T, D>>
where
D: DimSub<U1>,
DefaultAllocator: Allocator<T, D, D>
+ Allocator<T, DimDiff<D, U1>>
+ Allocator<T::RealField, D>
+ Allocator<T::RealField, DimDiff<D, U1>>,
{
SymmetricEigen::try_new(self.into_owned(), eps, max_niter)
}
pub fn symmetric_tridiagonalize(self) -> SymmetricTridiagonal<T, D>
where
D: DimSub<U1>,
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
{
SymmetricTridiagonal::new(self.into_owned())
}
}