[−][src]Struct mathru::algebra::linear::matrix::matrix::Matrix
Methods
impl<T> Matrix<T> where
T: Clone,
[src]
T: Clone,
pub fn apply(self: Matrix<T>, f: &dyn Fn(&T) -> T) -> Matrix<T>
[src]
Applies the function f on every element in the matrix
pub fn apply_mut(self: &Matrix<T>, f: &dyn Fn(&T) -> T) -> Matrix<T>
[src]
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn transpose(&self) -> Self
[src]
Returns the transposed matrix
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let mut a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, -2.0, 3.0, -7.0]); a = a.transpose(); let a_trans: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 3.0, -2.0, -7.0]); assert_eq!(a_trans, a);
impl<T> Matrix<T> where
T: Semiring + Sign,
[src]
T: Semiring + Sign,
pub fn transpose_inplace<'a>(self) -> Matrix<T>
[src]
Function to transpose a matrix without allocating memory for the transposed matrix
catanzaro.name/papers/PPoPP-2014.pdf
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let mut uut: Matrix<f64> = Matrix::new(4, 2, vec![1.0, 0.0, 3.0, 0.0, 1.0, -7.0, 0.5, 0.25]); uut = uut.transpose_inplace(); let refer: Matrix<f64> = Matrix::new(2, 4, vec![1.0, 3.0, 1.0, 0.5, 0.0, 0.0, -7.0, 0.25]); assert_eq!(refer, uut);
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn det<'a>(&'a self) -> T
[src]
Calculates the determinant
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, -2.0, 3.0, -7.0]); let determinant_a: f64 = a.det(); assert_eq!(-1.0, determinant_a);
pub fn trace(&self) -> T where
T: MulAssign + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + One + Zero + Clone + PartialOrd + Neg<Output = T> + AddAssign,
[src]
T: MulAssign + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T> + One + Zero + Clone + PartialOrd + Neg<Output = T> + AddAssign,
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn get_column<'a, 'b>(&'a self, i: &'b usize) -> Vector<T>
[src]
pub fn get_row<'a, 'b>(&'a self, i: &'b usize) -> Vector<T>
[src]
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn givens<'a, 'b, 'c, 'd, 'e>(
m: &'a usize,
i: &'b usize,
j: &'c usize,
c: &'d T,
s: &'e T
) -> Self
[src]
m: &'a usize,
i: &'b usize,
j: &'c usize,
c: &'d T,
s: &'e T
) -> Self
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn householder(v: &Vector<T>, k: usize) -> Self
[src]
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn dec_sv<'a>(&'a self) -> (Self, Self, Self)
[src]
Computes the singular value decomposition
M = U * S * V*
Return
(u, s, v)
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(4, 4, vec![4.0, 1.0, -2.0, 2.0, 1.0, 2.0, 0.0, -2.0, 0.0, 3.0, -2.0, 2.0, 2.0, 1.0, -2.0, -1.0]); let (u, s, v): (Matrix<f64>, Matrix<f64>, Matrix<f64>) = a.dec_sv();
pub fn rot(f: T, g: T) -> (T, T, T)
[src]
pub fn householder_bidiag<'a>(&'a self) -> (Self, Self, Self)
[src]
self is an m times n matrix with m >= n A = UBV^{T} U \in T^{m \times n} B \in T^{n \times n} V \in T^{n \times n}
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn get_slice(
&self,
row_s: usize,
row_e: usize,
column_s: usize,
column_e: usize
) -> Matrix<T>
[src]
&self,
row_s: usize,
row_e: usize,
column_s: usize,
column_e: usize
) -> Matrix<T>
Returns a slice of the matrix
Arugments
0 <= row_s < m
0 <= row_e < m
0 <= column_s < n
0 <= column_e <= n
row_s: start row
row_e: end row
column_s: start column
column_e: end column
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let mut a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, -2.0, 3.0, -7.0]); a = a.get_slice(0, 0, 1, 1); let a_ref: Matrix<f64> = Matrix::new(1, 1, vec![-2.0]); assert_eq!(a_ref, a);
pub fn set_slice(self, slice: &Self, row: usize, column: usize) -> Matrix<T>
[src]
Replaces parts of the matrix with the given values
Arugments
0 <= row < m
0 <= column < n
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let mut a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(1, 2, vec![2.0, -1.0]); a = a.set_slice(&b, 0, 0); let a_updated: Matrix<f64> = Matrix::new(2, 2, vec![2.0, -1.0, 3.0, -7.0]); assert_eq!(a_updated, a);
impl<T> Matrix<T>
[src]
pub fn get_mut<'a, 'b, 'c>(
&'a mut self,
i: &'b usize,
j: &'c usize
) -> &'a mut T
[src]
&'a mut self,
i: &'b usize,
j: &'c usize
) -> &'a mut T
Returns the mutual element a_ij from the matrix
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let mut a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); *a.get_mut(&1, &0) = -8.0; let a_updated: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, -8.0, -7.0]); assert_eq!(a_updated, a);
pub fn get<'a, 'b, 'c>(&'a self, i: &'b usize, j: &'c usize) -> &'a T
[src]
Returns the element a_ij from the matrix
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let a_ref: f64 = 3.0; let element: f64 = *a.get(&1, &0); assert_eq!(a_ref, element);
impl<T> Matrix<T> where
T: Clone + Copy + Zero + One,
[src]
T: Clone + Copy + Zero + One,
impl<T> Matrix<T> where
T: Number + Clone + Copy + Zero + One,
[src]
T: Number + Clone + Copy + Zero + One,
pub fn new_random(m: usize, n: usize) -> Matrix<T>
[src]
impl<T> Matrix<T> where
T: Zero + Clone,
[src]
T: Zero + Clone,
pub fn zero(m: usize, n: usize) -> Self
[src]
Returns the zero matrix(additive neutral element)
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = &a + &Matrix::zero(2, 2); assert_eq!(a, b);
impl<T> Matrix<T> where
T: One + Zero + Clone,
[src]
T: One + Zero + Clone,
pub fn one(size: usize) -> Self
[src]
Returns the eye matrix(multiplicative neutral element)
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = &a * &Matrix::one(2); assert_eq!(a, b);
pub fn ones(m: usize, n: usize) -> Self
[src]
impl<T> Matrix<T>
[src]
pub fn dim(&self) -> (usize, usize)
[src]
Returns the matrix dimension
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(4, 2, vec![1.0, 0.0, 3.0, 0.0, 1.0, -7.0, 0.5, 0.25]); let (m, n) = a.dim(); assert_eq!(4, m); assert_eq!(2, n);
impl<T> Matrix<T> where
T: Real + 'static,
[src]
T: Real + 'static,
pub fn eigenvalue(&self) -> Vector<T>
[src]
Computes the eigenvalues of a real matrix
Arguments
Return
Vector with unsorted eigenvalues
Example
extern crate mathru; use mathru::algebra::linear::{Vector, Matrix}; let a: Matrix<f64> = Matrix::new(3, 3, vec![1.0, -3.0, 3.0, 3.0, -5.0, 3.0, 6.0, -6.0, 4.0]); let eig: Vector<f64> = a.eigenvalue();
pub fn eigenvalue_r(&self) -> Vector<T>
[src]
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn dec_qr<'a>(&'a self) -> (Matrix<T>, Matrix<T>)
[src]
QR Decomposition with Givens rotations
A = QR
Q is an orthogonal matrix
R is an upper triangular matrix
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, -2.0, 3.0, -7.0]); let (q, r): (Matrix<f64>, Matrix<f64>) = a.dec_qr();
impl<T> Matrix<T> where
T: Real,
[src]
T: Real,
pub fn inv<'a>(&'a self) -> Result<Matrix<T>, ()>
[src]
Inverse Matrix
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b_inv: Matrix<f64> = a.inv().unwrap();
pub fn inv_r(&self) -> Result<Matrix<T>, ()>
[src]
Trait Implementations
impl<T> PartialEq<Matrix<T>> for Matrix<T> where
T: PartialEq,
[src]
T: PartialEq,
fn eq<'a, 'b>(&'a self, other: &'b Self) -> bool
[src]
Checks if two matrices are equal
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); assert_eq!(true, a==b);
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: Clone> Clone for Matrix<T>
[src]
fn clone(&self) -> Matrix<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Matrix<T>
[src]
impl<T> Display for Matrix<T> where
T: Display,
[src]
T: Display,
impl<T> Sub<Matrix<T>> for Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self::Output
[src]
Subtracts two matrices
A = (a_{ij}) \in T^{m \times n} B = (b_{ij}) \in T^{m \times n} A - B = ( a_{ij} - b_{ij} )
Arguments
rhs:
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); assert_eq!(Matrix::zero(2, 2), a - b);
impl<'a, 'b, T> Sub<&'b Matrix<T>> for &'a Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'b Matrix<T>) -> Self::Output
[src]
impl<'a, 'b, T> Sub<&'b T> for &'a Matrix<T> where
T: Real,
[src]
T: Real,
Subtracts scalar from all matrix elements
type Output = Matrix<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &T) -> Self::Output
[src]
Subtracts a scalar value from all matrix elements
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![5.0, 4.0, 7.0, -3.0]); assert_eq!(b, &a - &-4.0);
impl<T> Sub<T> for Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: T) -> Self::Output
[src]
Subtracts a scalar from all matrix elements
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![5.0, 4.0, 7.0, -3.0]); assert_eq!(b, a - -4.0);
impl<T> Add<Matrix<T>> for Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self::Output
[src]
Adds two matrices
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); assert_eq!(b, Matrix::zero(2, 2) + a);
impl<'a, 'b, T> Add<&'b Matrix<T>> for &'a Matrix<T> where
T: Real,
[src]
T: Real,
Adds two matrices
type Output = Matrix<T>
The resulting type after applying the +
operator.
fn add(self, rhs: &'b Matrix<T>) -> Self::Output
[src]
Adds two matrices
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); assert_eq!(b, &Matrix::zero(2, 2) + &a);
impl<'a, 'b, T> Add<&'b T> for &'a Matrix<T> where
T: Add + Zero + Clone,
[src]
T: Add + Zero + Clone,
Add scalar to matrix
type Output = Matrix<T>
The resulting type after applying the +
operator.
fn add(self, rhs: &T) -> Self::Output
[src]
Add a scalar to the matrix
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![-3.0, -4.0, -1.0, -11.0]); assert_eq!(b, &a + &-4.0);
impl<T> Add<T> for Matrix<T> where
T: Add + Zero + Clone,
[src]
T: Add + Zero + Clone,
Add scalar to matrix
type Output = Matrix<T>
The resulting type after applying the +
operator.
fn add(self, rhs: T) -> Self::Output
[src]
Add a scalar to the matrix
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![-3.0, -4.0, -1.0, -11.0]); assert_eq!(b, a + -4.0);
impl<T> Mul<Matrix<T>> for Vector<T> where
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + Display,
[src]
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + Display,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: Matrix<T>) -> Self::Output
[src]
impl<'a, 'b, T> Mul<&'b Matrix<T>> for &'a Vector<T> where
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + Display,
[src]
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + Display,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Matrix<T>) -> Self::Output
[src]
impl<'a, 'b, T> Mul<&'b Vector<T>> for &'a Matrix<T> where
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + AddAssign,
[src]
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + AddAssign,
Multiplies matrix by vector.
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, v: &'b Vector<T>) -> Vector<T>
[src]
impl<T> Mul<T> for Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the *
operator.
fn mul(self, m: T) -> Matrix<T>
[src]
Multiplies a matrix with a scalar
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let f: f64 = 7.0; let res_ref: Matrix<f64> = Matrix::new(2, 2, vec![7.0, 0.0, 21.0, -49.0]); assert_eq!(res_ref, a * f);
impl<'a, 'b, T> Mul<&'b T> for &'a Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the *
operator.
fn mul(self, m: &'b T) -> Matrix<T>
[src]
Multiplies a matrix with a scalar
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let res_ref: Matrix<f64> = Matrix::new(2, 2, vec![4.0, 0.0, 12.0, -28.0]); assert_eq!(res_ref, &a * &4.0);
impl<T> Mul<Vector<T>> for Matrix<T> where
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + AddAssign,
[src]
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + AddAssign,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, m: Vector<T>) -> Vector<T>
[src]
impl<T> Mul<Matrix<T>> for Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: Self) -> Self::Output
[src]
Multiplies two matrices
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let res_ref: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, -18.0, 49.0]); assert_eq!(res_ref, a * b);
impl<'a, 'b, T> Mul<&'b Matrix<T>> for &'a Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Matrix<T>) -> Self::Output
[src]
Multiplies two matrices
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let a: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let b: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let res_ref: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, -18.0, 49.0]); assert_eq!(res_ref, &a * &b);
impl<T> Div<T> for Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the /
operator.
fn div(self, m: T) -> Matrix<T>
[src]
Divides all matrix element with a scalar
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let res_ref: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let f: f64 = 7.0; let a: Matrix<f64> = Matrix::new(2, 2, vec![7.0, 0.0, 21.0, -49.0]); assert_eq!(res_ref, a / f);
impl<'a, 'b, T> Div<&'b T> for &'a Matrix<T> where
T: Real,
[src]
T: Real,
type Output = Matrix<T>
The resulting type after applying the /
operator.
fn div(self, m: &'b T) -> Matrix<T>
[src]
Divide all matrix with a scalar
Example
extern crate mathru; use mathru::algebra::linear::{Matrix}; let res_ref: Matrix<f64> = Matrix::new(2, 2, vec![1.0, 0.0, 3.0, -7.0]); let a: Matrix<f64> = Matrix::new(2, 2, vec![4.0, 0.0, 12.0, -28.0]); assert_eq!(res_ref, &a / &4.0);
impl<T> Serialize for Matrix<T> where
T: Serialize,
[src]
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de, T> Deserialize<'de> for Matrix<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,