Struct Matrix

Source
pub struct Matrix<T> { /* private fields */ }

Implementations§

Source§

impl<T> Matrix<T>

Source

pub fn clear(&mut self)

Remove all the elements from the matrix

Source§

impl<T: Clone + Copy + Number> Matrix<T>

Source

pub fn get_row(&self, row: usize) -> Vector<T>

Get a row of the matrix as a vector

Source

pub fn get_col(&self, col: usize) -> Vector<T>

Get a column of the matrix as a vector

Source

pub fn set_row(&mut self, row: usize, vec: Vector<T>)

Set a row of the matrix using a vector

Source

pub fn set_col(&mut self, col: usize, vec: Vector<T>)

Set a column of the matrix using a vector

Source

pub fn delete_row(&mut self, row: usize)

Delete a row from the matrix

Source

pub fn multiply(&self, vec: &Vector<T>) -> Vector<T>

Multiply the matrix by a (column) vector and return a vector

Source

pub fn eye(size: usize) -> Self

Create a square identity matrix of specified size

Source

pub fn resize(&mut self, n_rows: usize, n_cols: usize)

Resize the matrix (empty entries are appended if necessary)

Source

pub fn transpose_in_place(&mut self)

Transpose the matrix in place

Source

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

Return the transpose of the matrix

Source

pub fn swap_rows(&mut self, row_1: usize, row_2: usize)

Swap two rows of the matrix

Source

pub fn swap_elem( &mut self, row_1: usize, col_1: usize, row_2: usize, col_2: usize, )

Swap two elements of the matrix

Source

pub fn fill(&mut self, elem: T)

Fill the matrix with specified elements

Source

pub fn fill_diag(&mut self, elem: T)

Fill the leading diagonal of the matrix with specified elements

Source

pub fn fill_band(&mut self, offset: isize, elem: T)

Fill a diagonal band of the matrix with specified elements ( offset above main diagonal +, below main diagonal - )

Source

pub fn fill_tridiag(&mut self, lower: T, diag: T, upper: T)

Fill the main three diagonals of the matrix with specified elements

Source

pub fn fill_row(&mut self, row: usize, elem: T)

Fill a row of the matrix with specified elements

Source

pub fn fill_col(&mut self, col: usize, elem: T)

Fill a column of the matrix with specified elements

Source§

impl<T: Clone + Copy + Number + Signed + PartialOrd> Matrix<T>

Source

pub fn solve_basic(&mut self, b: &Vector<T>) -> Vector<T>

Solve the system of equations Ax=b where b is a specified vector using Gaussian elimination (the matrix A is modified in the process)

Examples found in repository?
examples/sparse_linear_system.rs (line 31)
9fn main() {
10    println!( "------------------ Sparse linear system ------------------" );
11    println!( "  * Solving the linear system Ax = b, for x, where" );
12    let n: usize = 4;
13    let mut a = Mat64::new( n, n, 0.0 );
14    let mut triplets = Vec::new();
15    for i in 0..n {
16        a[(i,i)] = 2.0;
17        triplets.push( ( i, i, 2.0 ) );
18        if i > 0 {
19            a[( i - 1 , i )] = 1.0;
20            triplets.push( ( i - 1, i, 1.0 ) );
21        }
22        if i < n - 1 {
23            a[( i + 1 , i )] = 1.0;
24            triplets.push( ( i + 1, i, 1.0 ) );
25        }
26    }
27    println!( "  * A ={}", a );
28    let b = Vec64::random( n );
29    println!( "  * b^T ={}", b );
30    println!( "  * as both dense and sparse linear systems.");
31    let dense_x = a.solve_basic( &b );
32    println!( "  * The dense system gives the solution vector");
33    println!( "  * x^T ={}", dense_x );
34    let sparse = Sparse::<f64>::from_triplets( n, n, &mut triplets );
35    //let sparse_x = sparse.solve( b ).unwrap();
36    let mut sparse_x = Vector::<f64>::new( n, 0.0 );
37    let max_iter = 1000;
38    let tol = 1e-8;
39    let result = sparse.solve_bicgstab( &b, &mut sparse_x, max_iter, tol );
40    println!( "  * The sparse system gives the solution vector");
41    println!( "  * x^T ={}", sparse_x );
42    match result {
43        Ok( iter ) => println!( "  * The sparse system converged in {} iterations.", iter ),
44        Err( error ) => println!( "  * The sparse system failed to converge, error = {}", error )
45    }
46    let diff = dense_x - sparse_x;
47    println!( "  * The maximum difference between the two is {:+.2e}", diff.norm_inf() );
48    println!( "-------------------- FINISHED ---------------------" );
49}
More examples
Hide additional examples
examples/linear_systems.rs (line 21)
11fn main() {
12    println!( "------------------ Linear system ------------------" );
13    println!( "  * Solving the linear system Ax = b, for x, where" );
14    let mut a = Mat64::new( 3, 3, 0.0 );
15    a[(0,0)] = 1.0; a[(0,1)] = 1.0; a[(0,2)] =   1.0;
16    a[(1,0)] = 0.0; a[(1,1)] = 2.0; a[(1,2)] =   5.0;
17    a[(2,0)] = 2.0; a[(2,1)] = 5.0; a[(2,2)] = - 1.0;
18    println!( "  * A ={}", a );
19    let b = Vec64::create( vec![ 6.0, -4.0, 27.0 ] ); 
20    println!( "  * b^T ={}", b );
21    let x = a.clone().solve_basic( &b );
22    println!( "  * gives the solution vector");
23    println!( "  * x^T ={}", x );
24    println!( "---------------------------------------------------" );
25    println!( "  * Lets solve the complex linear system Cy = d where" );
26    let mut c = Matrix::<Cmplx>::new( 2, 2, Cmplx::new( 1.0, 1.0 ) );
27    c[(0,1)] = Cmplx::new( -1.0, 0.0 );
28    c[(1,0)] = Cmplx::new( 1.0, -1.0 );
29    println!( "  * C ={}", c );
30    let mut d = Vector::<Cmplx>::new( 2, Cmplx::new( 0.0, 1.0 ) );
31    d[1] = Cmplx::new( 1.0, 0.0 );
32    println!( "  * d^T ={}", d );
33    println!( "  * Using LU decomposition we find that ");
34    let y = c.clone().solve_lu( &d );
35    println!( "  * y^T ={}", y );
36    println!( "---------------------------------------------------" );
37    println!( "  * We may also find the determinant of a matrix" );
38    println!( "  * |A| = {}", a.determinant() );
39    println!( "  * |C| = {}", c.determinant() ); 
40    println!( "  * or the inverse of a matrix" );
41    let inverse = a.inverse();
42    println!( "  * A^-1 =\n{}", inverse );
43    println!( "  * C^-1 =\n{}", c.inverse() );
44    println!( "  * We can check this by multiplication" );
45    println!( "  * I = A * A^-1 =\n{}", a * inverse );
46    println!( "  * which is sufficiently accurate for our purposes.");
47    println!( "-------------------- FINISHED ---------------------" );
48}
Source

pub fn lu_decomp_in_place(&mut self) -> (usize, Matrix<T>)

Replace the matrix with its LU decomposition and return the number of pivots and a permutation matrix

Source

pub fn solve_lu(&mut self, b: &Vector<T>) -> Vector<T>

Solve the system of equations Ax=b where b is a specified vector using LU decomposition (the matrix A is modified in the process)

Examples found in repository?
examples/linear_systems.rs (line 34)
11fn main() {
12    println!( "------------------ Linear system ------------------" );
13    println!( "  * Solving the linear system Ax = b, for x, where" );
14    let mut a = Mat64::new( 3, 3, 0.0 );
15    a[(0,0)] = 1.0; a[(0,1)] = 1.0; a[(0,2)] =   1.0;
16    a[(1,0)] = 0.0; a[(1,1)] = 2.0; a[(1,2)] =   5.0;
17    a[(2,0)] = 2.0; a[(2,1)] = 5.0; a[(2,2)] = - 1.0;
18    println!( "  * A ={}", a );
19    let b = Vec64::create( vec![ 6.0, -4.0, 27.0 ] ); 
20    println!( "  * b^T ={}", b );
21    let x = a.clone().solve_basic( &b );
22    println!( "  * gives the solution vector");
23    println!( "  * x^T ={}", x );
24    println!( "---------------------------------------------------" );
25    println!( "  * Lets solve the complex linear system Cy = d where" );
26    let mut c = Matrix::<Cmplx>::new( 2, 2, Cmplx::new( 1.0, 1.0 ) );
27    c[(0,1)] = Cmplx::new( -1.0, 0.0 );
28    c[(1,0)] = Cmplx::new( 1.0, -1.0 );
29    println!( "  * C ={}", c );
30    let mut d = Vector::<Cmplx>::new( 2, Cmplx::new( 0.0, 1.0 ) );
31    d[1] = Cmplx::new( 1.0, 0.0 );
32    println!( "  * d^T ={}", d );
33    println!( "  * Using LU decomposition we find that ");
34    let y = c.clone().solve_lu( &d );
35    println!( "  * y^T ={}", y );
36    println!( "---------------------------------------------------" );
37    println!( "  * We may also find the determinant of a matrix" );
38    println!( "  * |A| = {}", a.determinant() );
39    println!( "  * |C| = {}", c.determinant() ); 
40    println!( "  * or the inverse of a matrix" );
41    let inverse = a.inverse();
42    println!( "  * A^-1 =\n{}", inverse );
43    println!( "  * C^-1 =\n{}", c.inverse() );
44    println!( "  * We can check this by multiplication" );
45    println!( "  * I = A * A^-1 =\n{}", a * inverse );
46    println!( "  * which is sufficiently accurate for our purposes.");
47    println!( "-------------------- FINISHED ---------------------" );
48}
Source

pub fn determinant(&self) -> T

Calculate the determinant of the matrix ( via LU decomposition )

Examples found in repository?
examples/linear_systems.rs (line 38)
11fn main() {
12    println!( "------------------ Linear system ------------------" );
13    println!( "  * Solving the linear system Ax = b, for x, where" );
14    let mut a = Mat64::new( 3, 3, 0.0 );
15    a[(0,0)] = 1.0; a[(0,1)] = 1.0; a[(0,2)] =   1.0;
16    a[(1,0)] = 0.0; a[(1,1)] = 2.0; a[(1,2)] =   5.0;
17    a[(2,0)] = 2.0; a[(2,1)] = 5.0; a[(2,2)] = - 1.0;
18    println!( "  * A ={}", a );
19    let b = Vec64::create( vec![ 6.0, -4.0, 27.0 ] ); 
20    println!( "  * b^T ={}", b );
21    let x = a.clone().solve_basic( &b );
22    println!( "  * gives the solution vector");
23    println!( "  * x^T ={}", x );
24    println!( "---------------------------------------------------" );
25    println!( "  * Lets solve the complex linear system Cy = d where" );
26    let mut c = Matrix::<Cmplx>::new( 2, 2, Cmplx::new( 1.0, 1.0 ) );
27    c[(0,1)] = Cmplx::new( -1.0, 0.0 );
28    c[(1,0)] = Cmplx::new( 1.0, -1.0 );
29    println!( "  * C ={}", c );
30    let mut d = Vector::<Cmplx>::new( 2, Cmplx::new( 0.0, 1.0 ) );
31    d[1] = Cmplx::new( 1.0, 0.0 );
32    println!( "  * d^T ={}", d );
33    println!( "  * Using LU decomposition we find that ");
34    let y = c.clone().solve_lu( &d );
35    println!( "  * y^T ={}", y );
36    println!( "---------------------------------------------------" );
37    println!( "  * We may also find the determinant of a matrix" );
38    println!( "  * |A| = {}", a.determinant() );
39    println!( "  * |C| = {}", c.determinant() ); 
40    println!( "  * or the inverse of a matrix" );
41    let inverse = a.inverse();
42    println!( "  * A^-1 =\n{}", inverse );
43    println!( "  * C^-1 =\n{}", c.inverse() );
44    println!( "  * We can check this by multiplication" );
45    println!( "  * I = A * A^-1 =\n{}", a * inverse );
46    println!( "  * which is sufficiently accurate for our purposes.");
47    println!( "-------------------- FINISHED ---------------------" );
48}
Source

pub fn inverse(&self) -> Matrix<T>

Return the inverse of the matrix ( via LU decomposition )

Examples found in repository?
examples/linear_systems.rs (line 41)
11fn main() {
12    println!( "------------------ Linear system ------------------" );
13    println!( "  * Solving the linear system Ax = b, for x, where" );
14    let mut a = Mat64::new( 3, 3, 0.0 );
15    a[(0,0)] = 1.0; a[(0,1)] = 1.0; a[(0,2)] =   1.0;
16    a[(1,0)] = 0.0; a[(1,1)] = 2.0; a[(1,2)] =   5.0;
17    a[(2,0)] = 2.0; a[(2,1)] = 5.0; a[(2,2)] = - 1.0;
18    println!( "  * A ={}", a );
19    let b = Vec64::create( vec![ 6.0, -4.0, 27.0 ] ); 
20    println!( "  * b^T ={}", b );
21    let x = a.clone().solve_basic( &b );
22    println!( "  * gives the solution vector");
23    println!( "  * x^T ={}", x );
24    println!( "---------------------------------------------------" );
25    println!( "  * Lets solve the complex linear system Cy = d where" );
26    let mut c = Matrix::<Cmplx>::new( 2, 2, Cmplx::new( 1.0, 1.0 ) );
27    c[(0,1)] = Cmplx::new( -1.0, 0.0 );
28    c[(1,0)] = Cmplx::new( 1.0, -1.0 );
29    println!( "  * C ={}", c );
30    let mut d = Vector::<Cmplx>::new( 2, Cmplx::new( 0.0, 1.0 ) );
31    d[1] = Cmplx::new( 1.0, 0.0 );
32    println!( "  * d^T ={}", d );
33    println!( "  * Using LU decomposition we find that ");
34    let y = c.clone().solve_lu( &d );
35    println!( "  * y^T ={}", y );
36    println!( "---------------------------------------------------" );
37    println!( "  * We may also find the determinant of a matrix" );
38    println!( "  * |A| = {}", a.determinant() );
39    println!( "  * |C| = {}", c.determinant() ); 
40    println!( "  * or the inverse of a matrix" );
41    let inverse = a.inverse();
42    println!( "  * A^-1 =\n{}", inverse );
43    println!( "  * C^-1 =\n{}", c.inverse() );
44    println!( "  * We can check this by multiplication" );
45    println!( "  * I = A * A^-1 =\n{}", a * inverse );
46    println!( "  * which is sufficiently accurate for our purposes.");
47    println!( "-------------------- FINISHED ---------------------" );
48}
Source§

impl Matrix<f64>

Source

pub fn norm_1(&self) -> f64

Return the matrix one-norm (max absolute column sum)

Source

pub fn norm_inf(&self) -> f64

Return the matrix inf-norm (max absolute row sum)

Source

pub fn norm_p(&self, p: f64) -> f64

Return the matrix p-norm (p=2 is Frobenius, p=inf is max norm)

Source

pub fn norm_frob(&self) -> f64

Return the matrix Frobenius norm

Source

pub fn norm_max(&self) -> f64

Return the entrywise max-norm of the matrix

Source

pub fn jacobian(point: Vec64, func: &dyn Fn(Vec64) -> Vec64, delta: f64) -> Self

Create the Jacobian matrix of a vector valued function at a point using finite-differences

Source§

impl Matrix<Cmplx>

Source

pub fn jacobian_cmplx( point: Vector<Cmplx>, func: &dyn Fn(Vector<Cmplx>) -> Vector<Cmplx>, delta: f64, ) -> Self

Create the Jacobian matrix of a complex vector valued function at a point using finite-differences

Source§

impl<T> Matrix<T>

Source

pub fn empty() -> Self

Create a new matrix of unspecified size

Source

pub fn rows(&self) -> usize

Return the number of rows in the matrix

Source

pub fn cols(&self) -> usize

Return the number of columns in the matrix

Source

pub fn numel(&self) -> usize

Return the number of elements in the matrix

Source§

impl<T: Clone + Number> Matrix<T>

Source

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

Create a new matrix of specified size

Examples found in repository?
examples/sparse_linear_system.rs (line 13)
9fn main() {
10    println!( "------------------ Sparse linear system ------------------" );
11    println!( "  * Solving the linear system Ax = b, for x, where" );
12    let n: usize = 4;
13    let mut a = Mat64::new( n, n, 0.0 );
14    let mut triplets = Vec::new();
15    for i in 0..n {
16        a[(i,i)] = 2.0;
17        triplets.push( ( i, i, 2.0 ) );
18        if i > 0 {
19            a[( i - 1 , i )] = 1.0;
20            triplets.push( ( i - 1, i, 1.0 ) );
21        }
22        if i < n - 1 {
23            a[( i + 1 , i )] = 1.0;
24            triplets.push( ( i + 1, i, 1.0 ) );
25        }
26    }
27    println!( "  * A ={}", a );
28    let b = Vec64::random( n );
29    println!( "  * b^T ={}", b );
30    println!( "  * as both dense and sparse linear systems.");
31    let dense_x = a.solve_basic( &b );
32    println!( "  * The dense system gives the solution vector");
33    println!( "  * x^T ={}", dense_x );
34    let sparse = Sparse::<f64>::from_triplets( n, n, &mut triplets );
35    //let sparse_x = sparse.solve( b ).unwrap();
36    let mut sparse_x = Vector::<f64>::new( n, 0.0 );
37    let max_iter = 1000;
38    let tol = 1e-8;
39    let result = sparse.solve_bicgstab( &b, &mut sparse_x, max_iter, tol );
40    println!( "  * The sparse system gives the solution vector");
41    println!( "  * x^T ={}", sparse_x );
42    match result {
43        Ok( iter ) => println!( "  * The sparse system converged in {} iterations.", iter ),
44        Err( error ) => println!( "  * The sparse system failed to converge, error = {}", error )
45    }
46    let diff = dense_x - sparse_x;
47    println!( "  * The maximum difference between the two is {:+.2e}", diff.norm_inf() );
48    println!( "-------------------- FINISHED ---------------------" );
49}
More examples
Hide additional examples
examples/linear_systems.rs (line 14)
11fn main() {
12    println!( "------------------ Linear system ------------------" );
13    println!( "  * Solving the linear system Ax = b, for x, where" );
14    let mut a = Mat64::new( 3, 3, 0.0 );
15    a[(0,0)] = 1.0; a[(0,1)] = 1.0; a[(0,2)] =   1.0;
16    a[(1,0)] = 0.0; a[(1,1)] = 2.0; a[(1,2)] =   5.0;
17    a[(2,0)] = 2.0; a[(2,1)] = 5.0; a[(2,2)] = - 1.0;
18    println!( "  * A ={}", a );
19    let b = Vec64::create( vec![ 6.0, -4.0, 27.0 ] ); 
20    println!( "  * b^T ={}", b );
21    let x = a.clone().solve_basic( &b );
22    println!( "  * gives the solution vector");
23    println!( "  * x^T ={}", x );
24    println!( "---------------------------------------------------" );
25    println!( "  * Lets solve the complex linear system Cy = d where" );
26    let mut c = Matrix::<Cmplx>::new( 2, 2, Cmplx::new( 1.0, 1.0 ) );
27    c[(0,1)] = Cmplx::new( -1.0, 0.0 );
28    c[(1,0)] = Cmplx::new( 1.0, -1.0 );
29    println!( "  * C ={}", c );
30    let mut d = Vector::<Cmplx>::new( 2, Cmplx::new( 0.0, 1.0 ) );
31    d[1] = Cmplx::new( 1.0, 0.0 );
32    println!( "  * d^T ={}", d );
33    println!( "  * Using LU decomposition we find that ");
34    let y = c.clone().solve_lu( &d );
35    println!( "  * y^T ={}", y );
36    println!( "---------------------------------------------------" );
37    println!( "  * We may also find the determinant of a matrix" );
38    println!( "  * |A| = {}", a.determinant() );
39    println!( "  * |C| = {}", c.determinant() ); 
40    println!( "  * or the inverse of a matrix" );
41    let inverse = a.inverse();
42    println!( "  * A^-1 =\n{}", inverse );
43    println!( "  * C^-1 =\n{}", c.inverse() );
44    println!( "  * We can check this by multiplication" );
45    println!( "  * I = A * A^-1 =\n{}", a * inverse );
46    println!( "  * which is sufficiently accurate for our purposes.");
47    println!( "-------------------- FINISHED ---------------------" );
48}
Source§

impl<T: Display> Matrix<T>

Source

pub fn output(&self, filename: &str)

Print the matrix to a file

Trait Implementations§

Source§

impl<T: Copy + Number> Add<&Matrix<T>> for &Matrix<T>

Source§

fn add(self, plus: &Matrix<T>) -> Self::Output

Add the elements of two matrices together ( binary + )

Source§

type Output = Matrix<T>

The resulting type after applying the + operator.
Source§

impl<T: Copy + Number> Add for Matrix<T>

Source§

fn add(self, plus: Self) -> Self::Output

Add the elements of two matrices together ( binary + )

Source§

type Output = Matrix<T>

The resulting type after applying the + operator.
Source§

impl<T: Copy + Number> AddAssign<&Matrix<T>> for Matrix<T>

Source§

fn add_assign(&mut self, rhs: &Self)

Add a matrix to a mutable matrix and assign the result ( += )

Source§

impl<T: Copy + Number> AddAssign<T> for Matrix<T>

Source§

fn add_assign(&mut self, rhs: T)

Add the same value to every element in a mutable matrix

Source§

impl<T: Copy + Number> AddAssign for Matrix<T>

Source§

fn add_assign(&mut self, rhs: Self)

Add a matrix to a mutable matrix and assign the result ( += )

Source§

impl<T: Clone> Clone for Matrix<T>

Source§

fn clone(&self) -> Self

Clone the matrix

1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Matrix<T>
where T: Debug,

Source§

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

Format the output

Source§

impl<T> Display for Matrix<T>
where T: Debug,

Source§

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

Format the output

Source§

impl<T: Copy + Number> Div<T> for &Matrix<T>

Source§

fn div(self, scalar: T) -> Self::Output

Divide a matrix by a scalar (matrix / scalar)

Source§

type Output = Matrix<T>

The resulting type after applying the / operator.
Source§

impl<T: Copy + Number> Div<T> for Matrix<T>

Source§

fn div(self, scalar: T) -> Self::Output

Divide a matrix by a scalar (matrix / scalar)

Source§

type Output = Matrix<T>

The resulting type after applying the / operator.
Source§

impl<T: Copy + Number> DivAssign<T> for Matrix<T>

Source§

fn div_assign(&mut self, rhs: T)

Divide a mutable matrix by a scalar (matrix /= scalar)

Source§

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

Source§

fn index<'a>(&'a self, index: (usize, usize)) -> &'a T

Indexing operator [] (read only)

Source§

type Output = T

The returned type after indexing.
Source§

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

Source§

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

Indexing operator [] (read/write)

Source§

impl<T: Clone + Copy + Number> Mul<&Matrix<T>> for &Matrix<T>

Source§

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

Multiply two matrices together ( matrix * matrix )

Source§

type Output = Matrix<T>

The resulting type after applying the * operator.
Source§

impl<T: Clone + Copy + Number> Mul<&Vector<T>> for &Matrix<T>

Source§

fn mul(self, vec: &Vector<T>) -> Vector<T>

Multiply a matrix with a (column) vector ( matrix * vector )

Source§

type Output = Vector<T>

The resulting type after applying the * operator.
Source§

impl Mul<Matrix<f64>> for f64

Source§

fn mul(self, matrix: Matrix<f64>) -> Self::Output

Allow multiplication on the left by f64 (f64 * matrix)

Source§

type Output = Matrix<f64>

The resulting type after applying the * operator.
Source§

impl<T: Copy + Number> Mul<T> for &Matrix<T>

Source§

fn mul(self, scalar: T) -> Self::Output

Multiply a matrix by a scalar (matrix * scalar)

Source§

type Output = Matrix<T>

The resulting type after applying the * operator.
Source§

impl<T: Copy + Number> Mul<T> for Matrix<T>

Source§

fn mul(self, scalar: T) -> Self::Output

Multiply a matrix by a scalar (matrix * scalar)

Source§

type Output = Matrix<T>

The resulting type after applying the * operator.
Source§

impl<T: Clone + Copy + Number> Mul<Vector<T>> for Matrix<T>

Source§

fn mul(self, vec: Vector<T>) -> Vector<T>

Multiply a matrix with a (column) vector ( matrix * vector )

Source§

type Output = Vector<T>

The resulting type after applying the * operator.
Source§

impl<T: Clone + Copy + Number> Mul for Matrix<T>

Source§

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

Multiply two matrices together ( matrix * matrix )

Source§

type Output = Matrix<T>

The resulting type after applying the * operator.
Source§

impl<T: Copy + Number> MulAssign<T> for Matrix<T>

Source§

fn mul_assign(&mut self, rhs: T)

Multiply a mutable matrix by a scalar (matrix *= scalar)

Source§

impl<T: Copy + Neg<Output = T> + Signed> Neg for &Matrix<T>

Source§

fn neg(self) -> Self::Output

Return the unary negation ( unary - ) of each element

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

impl<T: Copy + Neg<Output = T> + Signed> Neg for Matrix<T>

Source§

fn neg(self) -> Self::Output

Return the unary negation ( unary - ) of each element

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

impl<T: PartialEq> PartialEq for Matrix<T>

Source§

fn eq(&self, other: &Matrix<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: Copy + Number> Sub<&Matrix<T>> for &Matrix<T>

Source§

fn sub(self, minus: &Matrix<T>) -> Self::Output

Subtract the elements of one matrix from another ( binary - )

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

impl<T: Copy + Number> Sub for Matrix<T>

Source§

fn sub(self, minus: Self) -> Self::Output

Subtract the elements of one matrix from another ( binary - )

Source§

type Output = Matrix<T>

The resulting type after applying the - operator.
Source§

impl<T: Copy + Number> SubAssign<&Matrix<T>> for Matrix<T>

Source§

fn sub_assign(&mut self, rhs: &Self)

Subtract a matrix from a mutable matrix and assign the result ( -= )

Source§

impl<T: Copy + Number> SubAssign<T> for Matrix<T>

Source§

fn sub_assign(&mut self, rhs: T)

Subtract the same value from every element in a mutable matrix

Source§

impl<T: Copy + Number> SubAssign for Matrix<T>

Source§

fn sub_assign(&mut self, rhs: Self)

Subtract a matrix from a mutable matrix and assign the result ( -= )

Source§

impl<T> StructuralPartialEq for Matrix<T>

Auto Trait Implementations§

§

impl<T> Freeze for Matrix<T>

§

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

§

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

§

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

§

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

§

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

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

Source§

fn vzip(self) -> V

Source§

impl<T, Rhs> AssignOperations<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs>,