Skip to main content

CappedFullPivLu

Struct CappedFullPivLu 

Source
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>

Source

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);
Source

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);
Source

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]);
Source

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 is min(cap, n) when the cap stops it, and fewer when a zero or subnormal Schur complement stops it first (0 for a zero matrix).
  • Some(cap), a NaN or infinite entry: min(cap, n), whether or not the elimination stopped earlier.
  • None: always n, also for a singular matrix whose elimination stopped early (a zero matrix reports n). 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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for CappedFullPivLu<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V