Skip to main content

DynQr

Struct DynQr 

Source
pub struct DynQr<T> { /* private fields */ }
Expand description

QR decomposition of a dynamically-sized matrix (M >= N).

Stores the packed Householder vectors, R, and tau scalars.

§Example

use numeris::{DynMatrix, DynVector};

let a = DynMatrix::from_rows(3, 2, &[
    1.0_f64, 0.0,
    1.0, 1.0,
    1.0, 2.0,
]);
let b = DynVector::from_slice(&[1.0, 2.0, 4.0]);
let x = a.qr().unwrap().solve(&b);
assert!((x[0] - 5.0 / 6.0).abs() < 1e-10);
assert!((x[1] - 3.0 / 2.0).abs() < 1e-10);

Implementations§

Source§

impl<T: LinalgScalar> DynQr<T>

Source

pub fn new(a: &DynMatrix<T>) -> Result<Self, LinalgError>

Decompose a matrix. Returns an error if a column is rank-deficient.

Source

pub fn r(&self) -> DynMatrix<T>

Extract the upper-triangular R factor (N × N).

Source

pub fn q(&self) -> DynMatrix<T>

Compute the thin Q factor (M × N).

Source

pub fn solve(&self, b: &DynVector<T>) -> DynVector<T>

Solve the least-squares problem min ||Ax - b|| for x.

Source

pub fn det(&self) -> T

Determinant of the original matrix (square only).

Trait Implementations§

Source§

impl<T: Debug> Debug for DynQr<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 DynQr<T>

§

impl<T> RefUnwindSafe for DynQr<T>
where T: RefUnwindSafe,

§

impl<T> Send for DynQr<T>
where T: Send,

§

impl<T> Sync for DynQr<T>
where T: Sync,

§

impl<T> Unpin for DynQr<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for DynQr<T>

§

impl<T> UnwindSafe for DynQr<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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.