Skip to main content

DynMatrix

Struct DynMatrix 

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

Dynamically-sized heap-allocated matrix.

Row-major Vec<T> storage, matching the layout of fixed-size Matrix. Dimensions are set at runtime. Implements MatrixRef and MatrixMut, so all generic linalg free functions work with DynMatrix out of the box.

§Examples

use numeris::DynMatrix;

let a = DynMatrix::from_slice(2, 2, &[1.0_f64, 2.0, 3.0, 4.0]);
assert_eq!(a[(0, 1)], 2.0);
assert_eq!(a.nrows(), 2);
assert_eq!(a.ncols(), 2);

let b = DynMatrix::eye(3, 0.0_f64);
assert_eq!(b[(0, 0)], 1.0);
assert_eq!(b[(0, 1)], 0.0);

Implementations§

Source§

impl<T: Scalar> DynMatrix<T>

Source

pub fn block(&self, i: usize, j: usize, rows: usize, cols: usize) -> Self

Extract a sub-matrix of size rows x cols starting at (i, j).

Panics if the block extends beyond the matrix bounds.

use numeris::DynMatrix;
let m = DynMatrix::from_fn(3, 3, |i, j| (i * 3 + j) as f64);
let b = m.block(1, 1, 2, 2);
assert_eq!(b[(0, 0)], 4.0);
assert_eq!(b[(1, 1)], 8.0);
Source

pub fn set_block(&mut self, i: usize, j: usize, src: &DynMatrix<T>)

Write a sub-matrix into self starting at position (i, j).

Panics if the block extends beyond the matrix bounds.

use numeris::DynMatrix;
let mut m = DynMatrix::zeros(3, 3, 0.0_f64);
let patch = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
m.set_block(1, 1, &patch);
assert_eq!(m[(1, 1)], 1.0);
assert_eq!(m[(2, 2)], 4.0);
Source

pub fn top_left(&self, rows: usize, cols: usize) -> Self

Extract the top-left corner of size rows x cols.

Source

pub fn top_right(&self, rows: usize, cols: usize) -> Self

Extract the top-right corner of size rows x cols.

Source

pub fn bottom_left(&self, rows: usize, cols: usize) -> Self

Extract the bottom-left corner of size rows x cols.

Source

pub fn bottom_right(&self, rows: usize, cols: usize) -> Self

Extract the bottom-right corner of size rows x cols.

Source

pub fn top_rows(&self, n: usize) -> Self

Extract the first n rows.

Source

pub fn bottom_rows(&self, n: usize) -> Self

Extract the last n rows.

Source

pub fn left_cols(&self, n: usize) -> Self

Extract the first n columns.

Source

pub fn right_cols(&self, n: usize) -> Self

Extract the last n columns.

Source§

impl<T: LinalgScalar> DynMatrix<T>

Source

pub fn lu(&self) -> Result<DynLu<T>, LinalgError>

LU decomposition with partial pivoting.

Source

pub fn cholesky(&self) -> Result<DynCholesky<T>, LinalgError>

Cholesky decomposition (A = L * L^H).

Source

pub fn qr(&self) -> Result<DynQr<T>, LinalgError>

QR decomposition using Householder reflections.

Source

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

Solve Ax = b for x via LU decomposition.

use numeris::{DynMatrix, DynVector};
let a = DynMatrix::from_slice(2, 2, &[2.0_f64, 1.0, 5.0, 3.0]);
let b = DynVector::from_slice(&[4.0, 11.0]);
let x = a.solve(&b).unwrap();
assert!((x[0] - 1.0).abs() < 1e-12);
assert!((x[1] - 2.0).abs() < 1e-12);
Source

pub fn inverse(&self) -> Result<DynMatrix<T>, LinalgError>

Matrix inverse via LU decomposition.

use numeris::DynMatrix;
let a = DynMatrix::from_slice(2, 2, &[4.0_f64, 7.0, 2.0, 6.0]);
let a_inv = a.inverse().unwrap();
let id = &a * &a_inv;
assert!((id[(0, 0)] - 1.0).abs() < 1e-12);
assert!((id[(0, 1)]).abs() < 1e-12);
Source

pub fn solve_qr(&self, b: &DynVector<T>) -> Result<DynVector<T>, LinalgError>

Solve Ax = b via QR decomposition.

Source§

impl<T: Scalar> DynMatrix<T>

Source

pub fn frobenius_norm_squared(&self) -> T

Squared Frobenius norm (sum of all elements squared).

Source§

impl<T: LinalgScalar> DynMatrix<T>

Source

pub fn frobenius_norm(&self) -> T::Real

Frobenius norm (square root of sum of squared moduli).

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0_f64, 2.0, 3.0, 4.0]);
assert!((m.frobenius_norm() - 30.0_f64.sqrt()).abs() < 1e-12);
Source

pub fn norm_inf(&self) -> T::Real

Infinity norm (maximum row sum of moduli).

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0_f64, -2.0, 3.0, 4.0]);
assert!((m.norm_inf() - 7.0).abs() < 1e-12);
Source

pub fn norm_one(&self) -> T::Real

One norm (maximum column sum of moduli).

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0_f64, -2.0, 3.0, 4.0]);
assert!((m.norm_one() - 6.0).abs() < 1e-12);
Source§

impl<T: Scalar> DynMatrix<T>

Source

pub fn element_mul(&self, rhs: &Self) -> Self

Element-wise (Hadamard) product: c[i][j] = a[i][j] * b[i][j].

use numeris::DynMatrix;
let a = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
let b = DynMatrix::from_slice(2, 2, &[5.0, 6.0, 7.0, 8.0]);
let c = a.element_mul(&b);
assert_eq!(c[(0, 0)], 5.0);
assert_eq!(c[(1, 1)], 32.0);
Source

pub fn element_div(&self, rhs: &Self) -> Self

Element-wise division: c[i][j] = a[i][j] / b[i][j].

use numeris::DynMatrix;
let a = DynMatrix::from_slice(2, 2, &[10.0, 12.0, 21.0, 32.0]);
let b = DynMatrix::from_slice(2, 2, &[5.0, 6.0, 7.0, 8.0]);
let c = a.element_div(&b);
assert_eq!(c[(0, 0)], 2.0);
assert_eq!(c[(1, 1)], 4.0);
Source

pub fn transpose(&self) -> Self
where T: Copy,

Transpose: (M×N) → (N×M).

use numeris::DynMatrix;
let a = DynMatrix::from_slice(2, 3, &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);
let t = a.transpose();
assert_eq!(t.nrows(), 3);
assert_eq!(t.ncols(), 2);
assert_eq!(t[(1, 0)], 2.0);
Source§

impl<T> DynMatrix<T>

Source

pub fn as_slice(&self) -> &[T]

View the entire matrix as a flat slice in row-major order.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
assert_eq!(m.as_slice(), &[1.0, 2.0, 3.0, 4.0]);
Source

pub fn as_mut_slice(&mut self) -> &mut [T]

View the entire matrix as a mutable flat slice.

Source

pub fn row_slice(&self, i: usize) -> &[T]

View row i as a slice.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 3, &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);
assert_eq!(m.row_slice(0), &[1.0, 2.0, 3.0]);
assert_eq!(m.row_slice(1), &[4.0, 5.0, 6.0]);
Source

pub fn row_slice_mut(&mut self, i: usize) -> &mut [T]

View row i as a mutable slice.

Source

pub fn iter(&self) -> Iter<'_, T>

Iterate over all elements in row-major order.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Iterate mutably over all elements in row-major order.

Source§

impl<T: Scalar> DynMatrix<T>

Source

pub fn trace(&self) -> T

Sum of diagonal elements.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
assert_eq!(m.trace(), 5.0);
Source

pub fn diag(&self) -> DynVector<T>

Extract the diagonal as a DynVector.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
let d = m.diag();
assert_eq!(d[0], 1.0);
assert_eq!(d[1], 4.0);
Source

pub fn from_diag(v: &DynVector<T>) -> Self

Create a square diagonal matrix from a vector.

use numeris::{DynMatrix, DynVector};
let v = DynVector::from_slice(&[2.0, 3.0]);
let m = DynMatrix::from_diag(&v);
assert_eq!(m[(0, 0)], 2.0);
assert_eq!(m[(1, 1)], 3.0);
assert_eq!(m[(0, 1)], 0.0);
Source

pub fn pow(&self, n: u32) -> Self

Integer matrix power via repeated squaring.

pow(0) returns the identity matrix. Panics if not square.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0, 1.0, 0.0, 1.0]);
let m3 = m.pow(3);
assert_eq!(m3[(0, 1)], 3.0);
Source

pub fn is_symmetric(&self) -> bool

Check if the matrix is symmetric (A == A^T).

use numeris::DynMatrix;
let sym = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 2.0, 3.0]);
assert!(sym.is_symmetric());
Source§

impl<T: LinalgScalar> DynMatrix<T>

Source

pub fn det(&self) -> T

Determinant via Gaussian elimination with partial pivoting.

Panics if the matrix is not square.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[3.0_f64, 8.0, 4.0, 6.0]);
assert!((m.det() - (-14.0)).abs() < 1e-12);
Source§

impl<T: Scalar> DynMatrix<T>

Source

pub fn sum(&self) -> T

Sum of all elements.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
assert_eq!(m.sum(), 10.0);
Source§

impl<T> DynMatrix<T>

Source

pub fn map<U>(&self, f: impl Fn(T) -> U) -> DynMatrix<U>
where T: Copy,

Apply a function to every element, producing a new matrix.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0_f64, 4.0, 9.0, 16.0]);
let r = m.map(|x: f64| x.sqrt());
assert_eq!(r[(0, 0)], 1.0);
assert_eq!(r[(1, 1)], 4.0);
Source§

impl<T: FloatScalar> DynMatrix<T>

Source

pub fn abs(&self) -> Self

Element-wise absolute value.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0_f64, -2.0, -3.0, 4.0]);
let a = m.abs();
assert_eq!(a[(0, 1)], 2.0);
assert_eq!(a[(1, 0)], 3.0);
Source

pub fn element_max(&self, rhs: &Self) -> Self

Element-wise maximum: c[i][j] = max(a[i][j], b[i][j]).

use numeris::DynMatrix;
let a = DynMatrix::from_slice(2, 2, &[1.0_f64, 5.0, 3.0, 2.0]);
let b = DynMatrix::from_slice(2, 2, &[4.0, 2.0, 1.0, 6.0]);
let c = a.element_max(&b);
assert_eq!(c[(0, 0)], 4.0);
assert_eq!(c[(0, 1)], 5.0);
Source§

impl<T> DynMatrix<T>

Source

pub fn swap_rows(&mut self, a: usize, b: usize)

Swap two rows in place.

use numeris::DynMatrix;
let mut m = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
m.swap_rows(0, 1);
assert_eq!(m[(0, 0)], 3.0);
assert_eq!(m[(1, 0)], 1.0);
Source§

impl<T: Copy> DynMatrix<T>

Source

pub fn swap_cols(&mut self, a: usize, b: usize)

Swap two columns in place.

use numeris::DynMatrix;
let mut m = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
m.swap_cols(0, 1);
assert_eq!(m[(0, 0)], 2.0);
assert_eq!(m[(0, 1)], 1.0);
Source§

impl<T: Scalar> DynMatrix<T>

Source

pub fn row(&self, i: usize) -> DynVector<T>

Extract row i as a DynVector.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
let r = m.row(0);
assert_eq!(r[0], 1.0);
assert_eq!(r[1], 2.0);
Source

pub fn set_row(&mut self, i: usize, v: &DynVector<T>)

Set row i from a DynVector.

Source

pub fn col(&self, j: usize) -> DynVector<T>

Extract column j as a DynVector.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
let c = m.col(1);
assert_eq!(c[0], 2.0);
assert_eq!(c[1], 4.0);
Source

pub fn set_col(&mut self, j: usize, v: &DynVector<T>)

Set column j from a DynVector.

Source§

impl<T: Scalar> DynMatrix<T>

Source

pub fn zeros(nrows: usize, ncols: usize, _zero: T) -> Self

Create an nrows x ncols matrix filled with value.

use numeris::DynMatrix;
let m = DynMatrix::zeros(2, 3, 0.0_f64);
assert_eq!(m.nrows(), 2);
assert_eq!(m.ncols(), 3);
assert_eq!(m[(1, 2)], 0.0);
Source

pub fn fill(nrows: usize, ncols: usize, value: T) -> Self

Create a matrix filled with a given value.

use numeris::DynMatrix;
let m = DynMatrix::fill(2, 3, 7.0_f64);
assert_eq!(m[(0, 0)], 7.0);
assert_eq!(m[(1, 2)], 7.0);
Source

pub fn eye(n: usize, _zero: T) -> Self

Create an n x n identity matrix.

The _zero parameter is only used for type inference.

use numeris::DynMatrix;
let id = DynMatrix::eye(3, 0.0_f64);
assert_eq!(id[(0, 0)], 1.0);
assert_eq!(id[(0, 1)], 0.0);
assert_eq!(id[(2, 2)], 1.0);
Source

pub fn from_slice(nrows: usize, ncols: usize, slice: &[T]) -> Self

Create a matrix from a flat slice in row-major order.

Panics if slice.len() != nrows * ncols.

use numeris::DynMatrix;
let m = DynMatrix::from_slice(2, 3, &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);
assert_eq!(m[(0, 2)], 3.0);
assert_eq!(m[(1, 0)], 4.0);
Source

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

Create a matrix from an owned Vec<T> in row-major order.

Panics if data.len() != nrows * ncols.

use numeris::DynMatrix;
let m = DynMatrix::from_vec(2, 2, vec![1.0, 2.0, 3.0, 4.0]);
assert_eq!(m[(0, 0)], 1.0);
assert_eq!(m[(1, 1)], 4.0);
Source§

impl<T> DynMatrix<T>

Source

pub fn nrows(&self) -> usize

Number of rows.

Source

pub fn ncols(&self) -> usize

Number of columns.

Source

pub fn is_square(&self) -> bool

Whether the matrix is square.

Source

pub fn from_fn( nrows: usize, ncols: usize, f: impl Fn(usize, usize) -> T, ) -> Self

Create a matrix by calling f(row, col) for each element.

use numeris::DynMatrix;
let m = DynMatrix::from_fn(3, 3, |i, j| if i == j { 1.0_f64 } else { 0.0 });
assert_eq!(m[(0, 0)], 1.0);
assert_eq!(m[(0, 1)], 0.0);

Trait Implementations§

Source§

impl<T: Scalar> Add<&DynMatrix<T>> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: Scalar> Add<&DynMatrix<T>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Add<&DynMatrix<T>> for Matrix<T, M, N>

Source§

type Output = DynMatrix<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Add<&Matrix<T, M, N>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Matrix<T, M, N>) -> DynMatrix<T>

Performs the + operation. Read more
Source§

impl<T: Scalar> Add<DynMatrix<T>> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Add<DynMatrix<T>> for Matrix<T, M, N>

Source§

type Output = DynMatrix<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Add<Matrix<T, M, N>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Matrix<T, M, N>) -> DynMatrix<T>

Performs the + operation. Read more
Source§

impl<T: Scalar> Add for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<T: Scalar> AddAssign<&DynMatrix<T>> for DynMatrix<T>

Source§

fn add_assign(&mut self, rhs: &DynMatrix<T>)

Performs the += operation. Read more
Source§

impl<T: Scalar> AddAssign for DynMatrix<T>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for DynMatrix<T>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for DynMatrix<T>

Source§

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

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

impl<T: Display> Display for DynMatrix<T>

Source§

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

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

impl<T: Scalar> Div<T> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T: Scalar> Div<T> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self

Performs the / operation. Read more
Source§

impl<T: Scalar> DivAssign<T> for DynMatrix<T>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T: Scalar> From<&DynVector<T>> for DynMatrix<T>

Source§

fn from(v: &DynVector<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Scalar, const M: usize, const N: usize> From<&Matrix<T, M, N>> for DynMatrix<T>

Source§

fn from(m: &Matrix<T, M, N>) -> Self

Converts to this type from the input type.
Source§

impl<T: Scalar> From<DynVector<T>> for DynMatrix<T>

Source§

fn from(v: DynVector<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Scalar, const M: usize, const N: usize> From<Matrix<T, M, N>> for DynMatrix<T>

Source§

fn from(m: Matrix<T, M, N>) -> Self

Convert a fixed-size Matrix into a DynMatrix.

use numeris::{Matrix, DynMatrix};
let m = Matrix::new([[1.0, 2.0], [3.0, 4.0]]);
let d: DynMatrix<f64> = m.into();
assert_eq!(d.nrows(), 2);
assert_eq!(d[(1, 1)], 4.0);
Source§

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

Source§

type Output = T

The returned type after indexing.
Source§

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

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<(usize, usize)> for DynMatrix<T>

Source§

fn index_mut(&mut self, (row, col): (usize, usize)) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a DynMatrix<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T> IntoIterator for &'a mut DynMatrix<T>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> MatrixMut<T> for DynMatrix<T>

Source§

fn get_mut(&mut self, row: usize, col: usize) -> &mut T

Mutable reference to the element at (row, col).
Source§

impl<T> MatrixRef<T> for DynMatrix<T>

Source§

fn nrows(&self) -> usize

Number of rows.
Source§

fn ncols(&self) -> usize

Number of columns.
Source§

fn get(&self, row: usize, col: usize) -> &T

Reference to the element at (row, col).
Source§

impl<T: Scalar> Mul<&DynMatrix<T>> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Mul<&DynMatrix<T>> for &Matrix<T, M, N>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Scalar> Mul<&DynMatrix<T>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Mul<&DynMatrix<T>> for Matrix<T, M, N>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<f32>> for f32

Source§

type Output = DynMatrix<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<f32>) -> DynMatrix<f32>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<f64>> for f64

Source§

type Output = DynMatrix<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<f64>) -> DynMatrix<f64>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<i128>> for i128

Source§

type Output = DynMatrix<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<i128>) -> DynMatrix<i128>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<i16>> for i16

Source§

type Output = DynMatrix<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<i16>) -> DynMatrix<i16>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<i32>> for i32

Source§

type Output = DynMatrix<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<i32>) -> DynMatrix<i32>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<i64>> for i64

Source§

type Output = DynMatrix<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<i64>) -> DynMatrix<i64>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<i8>> for i8

Source§

type Output = DynMatrix<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<i8>) -> DynMatrix<i8>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<u128>> for u128

Source§

type Output = DynMatrix<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<u128>) -> DynMatrix<u128>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<u16>> for u16

Source§

type Output = DynMatrix<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<u16>) -> DynMatrix<u16>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<u32>> for u32

Source§

type Output = DynMatrix<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<u32>) -> DynMatrix<u32>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<u64>> for u64

Source§

type Output = DynMatrix<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<u64>) -> DynMatrix<u64>

Performs the * operation. Read more
Source§

impl Mul<&DynMatrix<u8>> for u8

Source§

type Output = DynMatrix<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &DynMatrix<u8>) -> DynMatrix<u8>

Performs the * operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Mul<&Matrix<T, M, N>> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Matrix<T, M, N>) -> DynMatrix<T>

Performs the * operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Mul<&Matrix<T, M, N>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Matrix<T, M, N>) -> DynMatrix<T>

Performs the * operation. Read more
Source§

impl<T: Scalar> Mul<DynMatrix<T>> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Mul<DynMatrix<T>> for &Matrix<T, M, N>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Mul<DynMatrix<T>> for Matrix<T, M, N>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<f32>> for f32

Source§

type Output = DynMatrix<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<f32>) -> DynMatrix<f32>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<f64>> for f64

Source§

type Output = DynMatrix<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<f64>) -> DynMatrix<f64>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<i128>> for i128

Source§

type Output = DynMatrix<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<i128>) -> DynMatrix<i128>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<i16>> for i16

Source§

type Output = DynMatrix<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<i16>) -> DynMatrix<i16>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<i32>> for i32

Source§

type Output = DynMatrix<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<i32>) -> DynMatrix<i32>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<i64>> for i64

Source§

type Output = DynMatrix<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<i64>) -> DynMatrix<i64>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<i8>> for i8

Source§

type Output = DynMatrix<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<i8>) -> DynMatrix<i8>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<u128>> for u128

Source§

type Output = DynMatrix<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<u128>) -> DynMatrix<u128>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<u16>> for u16

Source§

type Output = DynMatrix<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<u16>) -> DynMatrix<u16>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<u32>> for u32

Source§

type Output = DynMatrix<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<u32>) -> DynMatrix<u32>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<u64>> for u64

Source§

type Output = DynMatrix<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<u64>) -> DynMatrix<u64>

Performs the * operation. Read more
Source§

impl Mul<DynMatrix<u8>> for u8

Source§

type Output = DynMatrix<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DynMatrix<u8>) -> DynMatrix<u8>

Performs the * operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Mul<Matrix<T, M, N>> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix<T, M, N>) -> DynMatrix<T>

Performs the * operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Mul<Matrix<T, M, N>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix<T, M, N>) -> DynMatrix<T>

Performs the * operation. Read more
Source§

impl<T: Scalar> Mul<T> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T: Scalar> Mul<T> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self

Performs the * operation. Read more
Source§

impl<T: Scalar> Mul for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<T: Scalar> MulAssign<T> for DynMatrix<T>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: Scalar> Neg for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> DynMatrix<T>

Performs the unary - operation. Read more
Source§

impl<T: Scalar> Neg for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: PartialEq> PartialEq for DynMatrix<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Scalar> Sub<&DynMatrix<T>> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T: Scalar> Sub<&DynMatrix<T>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Sub<&DynMatrix<T>> for Matrix<T, M, N>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Sub<&Matrix<T, M, N>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Matrix<T, M, N>) -> DynMatrix<T>

Performs the - operation. Read more
Source§

impl<T: Scalar> Sub<DynMatrix<T>> for &DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Sub<DynMatrix<T>> for Matrix<T, M, N>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> Sub<Matrix<T, M, N>> for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Matrix<T, M, N>) -> DynMatrix<T>

Performs the - operation. Read more
Source§

impl<T: Scalar> Sub for DynMatrix<T>

Source§

type Output = DynMatrix<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl<T: Scalar> SubAssign<&DynMatrix<T>> for DynMatrix<T>

Source§

fn sub_assign(&mut self, rhs: &DynMatrix<T>)

Performs the -= operation. Read more
Source§

impl<T: Scalar> SubAssign for DynMatrix<T>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<T: Scalar, const M: usize, const N: usize> TryFrom<&DynMatrix<T>> for Matrix<T, M, N>

Source§

fn try_from(d: &DynMatrix<T>) -> Result<Self, Self::Error>

Try to convert a DynMatrix into a fixed-size Matrix.

Fails if the runtime dimensions don’t match M x N.

use numeris::{Matrix, DynMatrix};
let d = DynMatrix::from_slice(2, 2, &[1.0, 2.0, 3.0, 4.0]);
let m: Matrix<f64, 2, 2> = (&d).try_into().unwrap();
assert_eq!(m[(0, 0)], 1.0);
assert_eq!(m[(1, 1)], 4.0);
Source§

type Error = DimensionMismatch

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

impl<T> StructuralPartialEq for DynMatrix<T>

Auto Trait Implementations§

§

impl<T> Freeze for DynMatrix<T>

§

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

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for DynMatrix<T>

§

impl<T> UnwindSafe for DynMatrix<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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.