Skip to main content

DenseMatrix

Struct DenseMatrix 

Source
pub struct DenseMatrix<S: Scalar + Entity> { /* private fields */ }
Expand description

Dense matrix backed by faer.

Implementations§

Source§

impl<S: Scalar + SimpleEntity + Conjugate<Canonical = S> + ComplexField> DenseMatrix<S>

Source

pub fn eigh(&self) -> Result<SymEigenDecomposition<S>, LinalgError>

Symmetric eigendecomposition.

Source

pub fn eigvalsh(&self) -> Result<Vec<S>, LinalgError>

Symmetric eigenvalues only (ascending order).

Source§

impl DenseMatrix<f64>

Source

pub fn eigvals(&self) -> Result<(Vec<f64>, Vec<f64>), LinalgError>

General eigenvalues as (real_parts, imag_parts).

Source§

impl DenseMatrix<f32>

Source

pub fn eigvals(&self) -> Result<(Vec<f32>, Vec<f32>), LinalgError>

General eigenvalues as (real_parts, imag_parts).

Source§

impl<S: Scalar + Entity> DenseMatrix<S>

Source

pub fn from_faer(mat: Mat<S>) -> Self

Create from a faer Mat.

Source

pub fn as_faer(&self) -> MatRef<'_, S>

Get reference to underlying faer matrix.

Source

pub fn as_faer_mut(&mut self) -> MatMut<'_, S>

Get mutable reference to underlying faer matrix.

Source

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

Create from row-major data.

Source

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

Create from column-major data.

Source

pub fn to_row_major(&self) -> Vec<S>

Convert to row-major vector.

Source

pub fn norm_frobenius(&self) -> S

Frobenius norm.

Source

pub fn norm_inf(&self) -> S

Infinity norm (max row sum).

Source

pub fn rows(&self) -> usize

Number of rows (direct access without trait).

Source

pub fn cols(&self) -> usize

Number of columns (direct access without trait).

Source

pub fn is_square(&self) -> bool

Check if square (direct access without trait).

Source§

impl<S: Scalar + SimpleEntity + Conjugate<Canonical = S> + ComplexField> DenseMatrix<S>
where S::Real: RealField,

Source

pub fn svd(&self) -> Result<SvdDecomposition<S>, LinalgError>

Compute full SVD.

Source

pub fn thin_svd(&self) -> Result<ThinSvdDecomposition<S>, LinalgError>

Compute thin SVD.

Source

pub fn singular_values(&self) -> Vec<S>

Compute singular values only (decreasing order).

Source

pub fn pinv(&self) -> Result<DenseMatrix<S>, LinalgError>

Moore-Penrose pseudoinverse via thin SVD.

Source

pub fn cond(&self) -> S

Condition number via SVD (sigma_max / sigma_min).

Source

pub fn rank(&self, tol: S) -> usize

Numerical rank: count of singular values > tol.

Source

pub fn lstsq(&self, b: &[S]) -> Result<Vec<S>, LinalgError>

Least-squares solve via thin SVD pseudoinverse: min ||Ax - b||_2.

Trait Implementations§

Source§

impl<S: Clone + Scalar + Entity> Clone for DenseMatrix<S>

Source§

fn clone(&self) -> DenseMatrix<S>

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<S: Debug + Scalar + Entity> Debug for DenseMatrix<S>

Source§

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

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

impl<S: Scalar + SimpleEntity + Conjugate<Canonical = S> + ComplexField> LUSolver<S> for DenseMatrix<S>

Source§

fn lu_solve(&self, b: &[S]) -> Result<Vec<S>, LinalgError>

Solve Ax = b.
Source§

fn lu_factor(&self) -> Result<LUFactorization<S>, LinalgError>

Compute and store LU factorization.
Source§

impl<S: Scalar + SimpleEntity + Conjugate<Canonical = S> + ComplexField> Matrix<S> for DenseMatrix<S>

Source§

fn zeros(rows: usize, cols: usize) -> Self

Create a zero matrix with given dimensions.
Source§

fn identity(n: usize) -> Self

Create an identity matrix.
Source§

fn nrows(&self) -> usize

Number of rows.
Source§

fn ncols(&self) -> usize

Number of columns.
Source§

fn get(&self, i: usize, j: usize) -> S

Get element at (i, j).
Source§

fn set(&mut self, i: usize, j: usize, value: S)

Set element at (i, j).
Source§

fn fill_zero(&mut self)

Fill matrix with zeros.
Source§

fn scale(&mut self, alpha: S)

Scale all elements by a constant.
Source§

fn mul_vec(&self, x: &[S], y: &mut [S])

Compute y = self * x (matrix-vector product).
Source§

fn add_scaled(&mut self, alpha: S, other: &Self)

Add another matrix: self += alpha * other.
Source§

fn solve(&self, b: &[S]) -> Result<Vec<S>, LinalgError>

Solve the linear system Ax = b, returning x.
Source§

fn is_square(&self) -> bool

Check if matrix is square.

Auto Trait Implementations§

§

impl<S> Freeze for DenseMatrix<S>
where <<S as Entity>::Group as ForCopyType>::FaerOfCopy<NonNull<<S as Entity>::Unit>>: Freeze,

§

impl<S> RefUnwindSafe for DenseMatrix<S>

§

impl<S> Send for DenseMatrix<S>

§

impl<S> Sync for DenseMatrix<S>

§

impl<S> Unpin for DenseMatrix<S>
where <<S as Entity>::Group as ForCopyType>::FaerOfCopy<NonNull<<S as Entity>::Unit>>: Unpin, S: Unpin,

§

impl<S> UnsafeUnpin for DenseMatrix<S>

§

impl<S> UnwindSafe for DenseMatrix<S>

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.
Source§

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

Source§

fn vzip(self) -> V