pub struct CappedFullPivLu<T> { /* private fields */ }Expand description
The pivots a capped_full_piv_lu call took, and the diagonal it left.
Holds no factor matrices: the row and column permutations, the in-place
diagonal, and the rank count Self::rank (whose meaning depends on the
cap).
§Examples
use tensor4all_tensorbackend::{capped_full_piv_lu, Matrix};
let a = Matrix::from_col_major_vec(2, 2, vec![1.0_f64, 0.0, 0.0, 5.0]);
let lu = capped_full_piv_lu(a, None)?;
assert_eq!(lu.rank(), 2);
assert_eq!(lu.row_perm(), &[1, 0]);
assert_eq!(lu.col_perm(), &[1, 0]);
assert_eq!(lu.diagonal(), &[5.0, 1.0]);Implementations§
Source§impl<T> CappedFullPivLu<T>
impl<T> CappedFullPivLu<T>
Sourcepub fn row_perm(&self) -> &[usize]
pub fn row_perm(&self) -> &[usize]
Row permutation: row_perm()[k] is the input row moved to position k.
Has n entries: the rows of the pivots taken, in order, then the rows the
elimination did not pivot on. Under a cap with finite input the pivots
taken are the first Self::rank entries; without a cap rank() is n
even when the elimination stopped earlier (see Self::rank).
§Examples
use tensor4all_tensorbackend::{capped_full_piv_lu, Matrix};
let a = Matrix::from_col_major_vec(2, 2, vec![0.0_f64, 3.0, 1.0, 0.0]);
let lu = capped_full_piv_lu(a, Some(1))?;
assert_eq!(lu.row_perm()[0], 1);Sourcepub fn col_perm(&self) -> &[usize]
pub fn col_perm(&self) -> &[usize]
Column permutation: col_perm()[k] is the input column moved to position k.
Has n entries: the columns of the pivots taken, in order, then the
columns the elimination did not pivot on. Which leading entries are pivots
is read as for Self::row_perm.
§Examples
use tensor4all_tensorbackend::{capped_full_piv_lu, Matrix};
let a = Matrix::from_col_major_vec(2, 2, vec![0.0_f64, 3.0, 1.0, 0.0]);
let lu = capped_full_piv_lu(a, Some(1))?;
assert_eq!(lu.col_perm()[0], 0);Sourcepub fn diagonal(&self) -> &[T]
pub fn diagonal(&self) -> &[T]
The diagonal of the in-place factorization, n entries.
The leading entries, up to where the elimination stopped, are the pivots
taken, in order. The rest are the trailing block’s diagonal as the
elimination left it: the Schur complement’s diagonal after a cap, the
un-eliminated block’s diagonal (under the permutations) after a zero or
subnormal stop - which is zero or subnormal. Under a cap with finite input
the stop is at Self::rank; without a cap rank() does not report it,
and the first zero or subnormal entry here marks it.
§Examples
use tensor4all_tensorbackend::{capped_full_piv_lu, Matrix};
let a = Matrix::from_col_major_vec(2, 2, vec![2.0_f64, 0.0, 0.0, -7.0]);
let lu = capped_full_piv_lu(a, None)?;
assert_eq!(lu.diagonal(), &[-7.0, 2.0]);Sourcepub fn rank(&self) -> usize
pub fn rank(&self) -> usize
The rank count the factorization reports; what it means depends on the
max_rank the call was given.
Some(cap), finite input: the number of pivots the elimination took. That ismin(cap, n)when the cap stops it, and fewer when a zero or subnormal Schur complement stops it first (0for a zero matrix).Some(cap), a NaN or infinite entry:min(cap, n), whether or not the elimination stopped earlier.None: alwaysn, also for a singular matrix whose elimination stopped early (a zero matrix reportsn). No rank is revealed.
What a caller can decide from it: under a cap with finite input, a
value r < min(cap, n) means the elimination found the remaining
(n - r) x (n - r) Schur complement zero or subnormal, so the r pivots
taken already reproduce the input up to rounding; r == min(cap, n) says
nothing about what lies past the cap. Without a
cap, the count carries no information about the matrix: read
Self::diagonal, or pass Some(n) to have the early stop reported.
§Examples
use tensor4all_tensorbackend::{capped_full_piv_lu, Matrix};
let a = Matrix::from_col_major_vec(3, 3, vec![
4.0_f64, 0.0, 0.0,
0.0, 2.0, 0.0,
0.0, 0.0, 1.0,
]);
assert_eq!(capped_full_piv_lu(a.clone(), None)?.rank(), 3);
assert_eq!(capped_full_piv_lu(a, Some(2))?.rank(), 2);
// A rank-1 matrix: only a cap reports the early stop.
let singular = Matrix::from_col_major_vec(2, 2, vec![3.0_f64, 0.0, 0.0, 0.0]);
assert_eq!(capped_full_piv_lu(singular.clone(), None)?.rank(), 2);
assert_eq!(capped_full_piv_lu(singular, Some(2))?.rank(), 1);Trait Implementations§
Source§impl<T: Clone> Clone for CappedFullPivLu<T>
impl<T: Clone> Clone for CappedFullPivLu<T>
Auto Trait Implementations§
impl<T> Freeze for CappedFullPivLu<T>
impl<T> RefUnwindSafe for CappedFullPivLu<T>where
T: RefUnwindSafe,
impl<T> Send for CappedFullPivLu<T>where
T: Send,
impl<T> Sync for CappedFullPivLu<T>where
T: Sync,
impl<T> Unpin for CappedFullPivLu<T>where
T: Unpin,
impl<T> UnsafeUnpin for CappedFullPivLu<T>
impl<T> UnwindSafe for CappedFullPivLu<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more