Skip to main content

DMatrix

Struct DMatrix 

Source
pub struct DMatrix<T = f64> { /* private fields */ }
Expand description

Dense matrix / vector types re-exported from the tpt-math substrate so callers can consume assembled operators without a separate dependency. A dynamically-sized matrix of T, stored column-major in a contiguous Vec ((i, j) lives at i + j * nrows).

Implementations§

Source§

impl<T> DMatrix<T>

Source

pub fn zeros(nrows: usize, ncols: usize) -> DMatrix<T>
where T: Scalar,

A zero matrix of the given shape.

Source

pub fn from_vec(nrows: usize, ncols: usize, data: Vec<T>) -> DMatrix<T>

Build from a Vec laid out column-major: element (i, j) is data[i + j * nrows].

Source

pub fn from_row_slice(nrows: usize, ncols: usize, data: &[T]) -> DMatrix<T>
where T: Clone,

Build from a slice laid out row-major.

Source

pub fn from_fn( nrows: usize, ncols: usize, f: impl FnMut(usize, usize) -> T, ) -> DMatrix<T>

Build element-by-element with f(i, j).

Source

pub fn from_diagonal(v: &DVector<T>) -> DMatrix<T>
where T: Scalar + Clone,

A square matrix with v’s elements on the diagonal, zeros elsewhere.

Source§

impl<T> DMatrix<T>

Source

pub fn nrows(&self) -> usize

Number of rows.

Source

pub fn ncols(&self) -> usize

Number of columns.

Source

pub fn is_empty(&self) -> bool

True if the matrix has no entries.

Source

pub fn iter(&self) -> impl Iterator<Item = &T>

Iterate over all elements in column-major order.

Source§

impl<T> DMatrix<T>
where T: Scalar + Clone,

Source

pub fn transpose(&self) -> DMatrix<T>

Transpose, swapping rows and columns.

Source§

impl DMatrix

Source

pub fn solve(&self, b: &DVector) -> Result<DVector, DenseError>

Solve A x = b for x, where A is self. Errors if A is singular or the dimensions do not match.

Source

pub fn inverse(&self) -> Result<DMatrix, DenseError>

Compute the inverse of self. Errors if self is singular.

Trait Implementations§

Source§

impl<T> Add for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

type Output = DMatrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: DMatrix<T>) -> DMatrix<T>

Performs the + operation. Read more
Source§

impl<T> Add<T> for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

type Output = DMatrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> DMatrix<T>

Performs the + operation. Read more
Source§

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

Source§

fn clone(&self) -> DMatrix<T>

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 for DMatrix<T>
where T: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Div<T> for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

type Output = DMatrix<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> DMatrix<T>

Performs the / operation. Read more
Source§

impl<T> Index<(usize, usize)> for DMatrix<T>

Source§

fn index(&self, _: (usize, usize)) -> &T

§Panics

Panics if (i, j) is out of bounds.

Source§

type Output = T

The returned type after indexing.
Source§

impl<T> Mul for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

fn mul(self, rhs: DMatrix<T>) -> DMatrix<T>

§Panics

Panics if the inner dimensions do not match.

Source§

type Output = DMatrix<T>

The resulting type after applying the * operator.
Source§

impl<T> Mul<DVector<T>> for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

fn mul(self, rhs: DVector<T>) -> DVector<T>

§Panics

Panics if the matrix column count does not match the vector length.

Source§

type Output = DVector<T>

The resulting type after applying the * operator.
Source§

impl<T> Mul<T> for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

type Output = DMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> DMatrix<T>

Performs the * operation. Read more
Source§

impl<T> Neg for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

type Output = DMatrix<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> DMatrix<T>

Performs the unary - operation. Read more
Source§

impl<T> PartialEq for DMatrix<T>
where T: PartialEq,

Source§

fn eq(&self, other: &DMatrix<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T> Sub for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

type Output = DMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: DMatrix<T>) -> DMatrix<T>

Performs the - operation. Read more
Source§

impl<T> Sub<T> for DMatrix<T>
where T: Scalar,

Available on crate feature alloc only.
Source§

type Output = DMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> DMatrix<T>

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for DMatrix<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for DMatrix<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for DMatrix<T>
where Vec<T>: Send,

§

impl<T> Sync for DMatrix<T>
where Vec<T>: Sync,

§

impl<T> Unpin for DMatrix<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for DMatrix<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for DMatrix<T>
where Vec<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> 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.

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