Skip to main content

Mat

Struct Mat 

Source
pub struct Mat(/* private fields */);
Expand description

A matrix backed by libmat’s C implementation.

Owns its underlying C allocation and frees it on drop. Uses column-major storage.

Implementations§

Source§

impl Mat

Source

pub fn new(rows: usize, cols: usize) -> Self

Creates a zero-initialized matrix with the given dimensions.

Source

pub fn from_slice(rows: usize, cols: usize, data: &[f32]) -> Self

Creates a matrix from a slice of values in column-major order.

Source

pub fn eye(dim: usize) -> Self

Creates an identity matrix of the given dimension.

Source

pub fn mul(&self, other: &Mat) -> Self

Returns the matrix product self * other.

Source

pub fn add(&self, other: &Mat) -> Self

Returns the element-wise sum self + other.

Source

pub fn at(&self, row: usize, col: usize) -> f32

Returns the element at (row, col).

Source

pub fn equals(&self, other: &Mat) -> bool

Returns true if all elements are equal.

Source

pub fn print(&self)

Prints the matrix to stdout.

Source

pub fn rows(&self) -> usize

Returns the number of rows.

Source

pub fn cols(&self) -> usize

Returns the number of columns.

Source

pub fn eigvals(&self) -> Mat

Computes eigenvalues of a general square matrix.

Uses Hessenberg reduction followed by implicit QR iteration. For complex eigenvalues (conjugate pairs), only the real part is stored.

Source

pub fn eigvals_sym(&self) -> Mat

Computes eigenvalues of a symmetric matrix.

Faster than eigvals for symmetric input. Uses tridiagonal reduction + implicit QR iteration.

Source

pub fn eigen_sym(&self) -> Eigen

Computes eigendecomposition of a symmetric matrix: A = V * diag(eigenvalues) * V^T.

Returns an Eigen where eigenvectors columns are orthogonal eigenvectors and eigenvalues are sorted in ascending order.

Source

pub fn eigen(&self) -> Eigen

Computes eigendecomposition of a general square matrix.

Returns an Eigen where eigenvectors columns are the eigenvectors and eigenvalues holds eigenvalues (real parts for complex conjugate pairs).

Trait Implementations§

Source§

impl Drop for Mat

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Mat

§

impl RefUnwindSafe for Mat

§

impl !Send for Mat

§

impl !Sync for Mat

§

impl Unpin for Mat

§

impl UnsafeUnpin for Mat

§

impl UnwindSafe for Mat

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