pub struct DenseMatrix<T> { /* private fields */ }
Expand description
Dense matrix
Implementations§
Source§impl<T: Debug + Display + Copy + Sized> DenseMatrix<T>
impl<T: Debug + Display + Copy + Sized> DenseMatrix<T>
Sourcepub fn new(
nrows: usize,
ncols: usize,
values: Vec<T>,
column_major: bool,
) -> Result<Self, Failed>
pub fn new( nrows: usize, ncols: usize, values: Vec<T>, column_major: bool, ) -> Result<Self, Failed>
Create new instance of DenseMatrix
without copying data.
values
should be in column-major order.
Sourcepub fn from_2d_array(values: &[&[T]]) -> Result<Self, Failed>
pub fn from_2d_array(values: &[&[T]]) -> Result<Self, Failed>
New instance of DenseMatrix
from 2d array.
Trait Implementations§
Source§impl<T: Number + RealNumber + AbsDiffEq> AbsDiffEq for DenseMatrix<T>
impl<T: Number + RealNumber + AbsDiffEq> AbsDiffEq for DenseMatrix<T>
Source§fn default_epsilon() -> T::Epsilon
fn default_epsilon() -> T::Epsilon
The default tolerance to use when testing values that are close together. Read more
Source§fn abs_diff_eq(&self, other: &Self, epsilon: T::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: T::Epsilon) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq
.Source§impl<T: Debug + Display + Copy + Sized> Array2<T> for DenseMatrix<T>
impl<T: Debug + Display + Copy + Sized> Array2<T> for DenseMatrix<T>
Source§fn slice<'a>(
&'a self,
rows: Range<usize>,
cols: Range<usize>,
) -> Box<dyn ArrayView2<T> + 'a>
fn slice<'a>( &'a self, rows: Range<usize>, cols: Range<usize>, ) -> Box<dyn ArrayView2<T> + 'a>
get a view of the 2d array
Source§fn slice_mut<'a>(
&'a mut self,
rows: Range<usize>,
cols: Range<usize>,
) -> Box<dyn MutArrayView2<T> + 'a>where
Self: Sized,
fn slice_mut<'a>(
&'a mut self,
rows: Range<usize>,
cols: Range<usize>,
) -> Box<dyn MutArrayView2<T> + 'a>where
Self: Sized,
get a mutable view of the 2d array
Source§fn from_iterator<I: Iterator<Item = T>>(
iter: I,
nrows: usize,
ncols: usize,
axis: u8,
) -> Self
fn from_iterator<I: Iterator<Item = T>>( iter: I, nrows: usize, ncols: usize, axis: u8, ) -> Self
create 2d array from iterator
Source§fn rand(nrows: usize, ncols: usize) -> Selfwhere
T: RealNumber,
fn rand(nrows: usize, ncols: usize) -> Selfwhere
T: RealNumber,
create a 2d array of random values
Source§fn from_slice(slice: &dyn ArrayView2<T>) -> Self
fn from_slice(slice: &dyn ArrayView2<T>) -> Self
crate from 2d slice
Source§fn from_row(slice: &dyn ArrayView1<T>) -> Self
fn from_row(slice: &dyn ArrayView1<T>) -> Self
create from row
Source§fn from_column(slice: &dyn ArrayView1<T>) -> Self
fn from_column(slice: &dyn ArrayView1<T>) -> Self
create from column
Source§fn matmul(&self, other: &dyn ArrayView2<T>) -> Selfwhere
T: Number,
fn matmul(&self, other: &dyn ArrayView2<T>) -> Selfwhere
T: Number,
multiply two 2d arrays
Source§fn ab(
&self,
a_transpose: bool,
b: &dyn ArrayView2<T>,
b_transpose: bool,
) -> Selfwhere
T: Number,
fn ab(
&self,
a_transpose: bool,
b: &dyn ArrayView2<T>,
b_transpose: bool,
) -> Selfwhere
T: Number,
matrix multiplication
Source§fn ax(&self, a_transpose: bool, x: &dyn ArrayView1<T>) -> Selfwhere
T: Number,
fn ax(&self, a_transpose: bool, x: &dyn ArrayView1<T>) -> Selfwhere
T: Number,
matrix vector multiplication
Source§fn concatenate_1d<'a>(arrays: &'a [&'a dyn ArrayView1<T>], axis: u8) -> Self
fn concatenate_1d<'a>(arrays: &'a [&'a dyn ArrayView1<T>], axis: u8) -> Self
concatenate 1d array
Source§fn concatenate_2d<'a>(arrays: &'a [&'a dyn ArrayView2<T>], axis: u8) -> Self
fn concatenate_2d<'a>(arrays: &'a [&'a dyn ArrayView2<T>], axis: u8) -> Self
concatenate 2d array
Source§fn merge_1d<'a>(
&'a self,
arrays: &'a [&'a dyn ArrayView1<T>],
axis: u8,
append: bool,
) -> Self
fn merge_1d<'a>( &'a self, arrays: &'a [&'a dyn ArrayView1<T>], axis: u8, append: bool, ) -> Self
merge 1d arrays
Source§fn v_stack(&self, other: &dyn ArrayView2<T>) -> Self
fn v_stack(&self, other: &dyn ArrayView2<T>) -> Self
Stack arrays in sequence vertically
Source§fn h_stack(&self, other: &dyn ArrayView2<T>) -> Self
fn h_stack(&self, other: &dyn ArrayView2<T>) -> Self
Stack arrays in sequence horizontally
Source§fn map<O: Debug + Display + Copy + Sized, A: Array2<O>, F: FnMut(&T) -> O>(
self,
f: F,
) -> A
fn map<O: Debug + Display + Copy + Sized, A: Array2<O>, F: FnMut(&T) -> O>( self, f: F, ) -> A
map array values
Source§fn row_iter<'a>(
&'a self,
) -> Box<dyn Iterator<Item = Box<dyn ArrayView1<T> + 'a>> + 'a>
fn row_iter<'a>( &'a self, ) -> Box<dyn Iterator<Item = Box<dyn ArrayView1<T> + 'a>> + 'a>
iter rows
Source§fn col_iter<'a>(
&'a self,
) -> Box<dyn Iterator<Item = Box<dyn ArrayView1<T> + 'a>> + 'a>
fn col_iter<'a>( &'a self, ) -> Box<dyn Iterator<Item = Box<dyn ArrayView1<T> + 'a>> + 'a>
iter cols
Source§fn take_column(&self, column_index: usize) -> Self
fn take_column(&self, column_index: usize) -> Self
Take an individual column from the matrix.
Source§fn add_scalar(&self, x: T) -> Selfwhere
T: Number,
fn add_scalar(&self, x: T) -> Selfwhere
T: Number,
add a scalar to the array
Source§fn sub_scalar(&self, x: T) -> Selfwhere
T: Number,
fn sub_scalar(&self, x: T) -> Selfwhere
T: Number,
subtract a scalar from the array
Source§fn div_scalar(&self, x: T) -> Selfwhere
T: Number,
fn div_scalar(&self, x: T) -> Selfwhere
T: Number,
divide a scalar from the array
Source§fn mul_scalar(&self, x: T) -> Selfwhere
T: Number,
fn mul_scalar(&self, x: T) -> Selfwhere
T: Number,
multiply a scalar to the array
Source§fn sub(&self, other: &dyn Array<T, (usize, usize)>) -> Selfwhere
T: Number,
fn sub(&self, other: &dyn Array<T, (usize, usize)>) -> Selfwhere
T: Number,
subtract two arrays
Source§fn mul(&self, other: &dyn Array<T, (usize, usize)>) -> Selfwhere
T: Number,
fn mul(&self, other: &dyn Array<T, (usize, usize)>) -> Selfwhere
T: Number,
multiply two arrays
Source§fn pow(&self, p: T) -> Selfwhere
T: RealNumber,
fn pow(&self, p: T) -> Selfwhere
T: RealNumber,
values at power
p
Source§fn column_mean(&self) -> Vec<f64>where
T: Number + ToPrimitive,
fn column_mean(&self) -> Vec<f64>where
T: Number + ToPrimitive,
compute mean for each column
Source§fn copy_col_as_vec(&self, col: usize, result: &mut Vec<T>)
fn copy_col_as_vec(&self, col: usize, result: &mut Vec<T>)
copy column as a vector
Source§fn approximate_eq(&self, other: &Self, error: T) -> boolwhere
T: Number + RealNumber,
fn approximate_eq(&self, other: &Self, error: T) -> boolwhere
T: Number + RealNumber,
approximate equality of the elements of a matrix according to a given error
Source§impl<T: Debug + Display + Copy + Sized> ArrayView2<T> for DenseMatrix<T>
impl<T: Debug + Display + Copy + Sized> ArrayView2<T> for DenseMatrix<T>
Source§fn argmax(&self, axis: u8) -> Vec<usize>where
T: Number + PartialOrd,
fn argmax(&self, axis: u8) -> Vec<usize>where
T: Number + PartialOrd,
return positions of max values in both rows
Source§fn mean_by(&self, axis: u8) -> Vec<f64>where
T: Number,
fn mean_by(&self, axis: u8) -> Vec<f64>where
T: Number,
return mean value
TODO: this can be made more readable and efficient using the
methods in
linalg::traits::stats
Source§impl<T: Number + RealNumber> CholeskyDecomposable<T> for DenseMatrix<T>
impl<T: Number + RealNumber> CholeskyDecomposable<T> for DenseMatrix<T>
Source§fn cholesky(&self) -> Result<Cholesky<T, Self>, Failed>
fn cholesky(&self) -> Result<Cholesky<T, Self>, Failed>
Compute the Cholesky decomposition of a matrix.
Source§fn cholesky_mut(self) -> Result<Cholesky<T, Self>, Failed>
fn cholesky_mut(self) -> Result<Cholesky<T, Self>, Failed>
Compute the Cholesky decomposition of a matrix. The input matrix
will be used for factorization.
Source§fn cholesky_solve_mut(self, b: Self) -> Result<Self, Failed>
fn cholesky_solve_mut(self, b: Self) -> Result<Self, Failed>
Solves Ax = b
Source§impl<T: Clone> Clone for DenseMatrix<T>
impl<T: Clone> Clone for DenseMatrix<T>
Source§fn clone(&self) -> DenseMatrix<T>
fn clone(&self) -> DenseMatrix<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for DenseMatrix<T>
impl<T: Debug> Debug for DenseMatrix<T>
Source§impl<T: Number + RealNumber> EVDDecomposable<T> for DenseMatrix<T>
impl<T: Number + RealNumber> EVDDecomposable<T> for DenseMatrix<T>
Source§impl<T: Number + RealNumber> LUDecomposable<T> for DenseMatrix<T>
impl<T: Number + RealNumber> LUDecomposable<T> for DenseMatrix<T>
Source§impl<T: RealNumber> MatrixPreprocessing<T> for DenseMatrix<T>
impl<T: RealNumber> MatrixPreprocessing<T> for DenseMatrix<T>
Source§fn binarize_mut(&mut self, threshold: T)
fn binarize_mut(&mut self, threshold: T)
Each element of the matrix greater than the threshold becomes 1, while values less than or equal to the threshold become 0 Read more
Source§impl<T: RealNumber> MatrixStats<T> for DenseMatrix<T>
impl<T: RealNumber> MatrixStats<T> for DenseMatrix<T>
Source§fn _mean_of_vector(v: &[T]) -> T
fn _mean_of_vector(v: &[T]) -> T
http://en.wikipedia.org/wiki/Arithmetic_mean
Taken from
statistical
The MIT License (MIT)
Copyright (c) 2015 Jeff BelgumSource§fn _sum_square_deviations_vec(v: &[T], c: Option<T>) -> T
fn _sum_square_deviations_vec(v: &[T], c: Option<T>) -> T
Taken from statistical
The MIT License (MIT)
Copyright (c) 2015 Jeff Belgum
Source§fn _var_of_vec(v: &[T], xbar: Option<T>) -> T
fn _var_of_vec(v: &[T], xbar: Option<T>) -> T
http://en.wikipedia.org/wiki/Variance#Sample_variance
Taken from statistical
The MIT License (MIT)
Copyright (c) 2015 Jeff Belgum
Source§impl<T: Debug + Display + Copy + Sized> MutArray<T, (usize, usize)> for DenseMatrix<T>
impl<T: Debug + Display + Copy + Sized> MutArray<T, (usize, usize)> for DenseMatrix<T>
Source§fn iterator_mut<'b>(
&'b mut self,
axis: u8,
) -> Box<dyn Iterator<Item = &'b mut T> + 'b>
fn iterator_mut<'b>( &'b mut self, axis: u8, ) -> Box<dyn Iterator<Item = &'b mut T> + 'b>
iterate over mutable values
Source§fn div_element_mut(&mut self, pos: S, x: T)
fn div_element_mut(&mut self, pos: S, x: T)
divide element by a given value
Source§fn mul_element_mut(&mut self, pos: S, x: T)
fn mul_element_mut(&mut self, pos: S, x: T)
multiply element for a given value
Source§fn add_element_mut(&mut self, pos: S, x: T)
fn add_element_mut(&mut self, pos: S, x: T)
add a given value to an element
Source§fn sub_element_mut(&mut self, pos: S, x: T)
fn sub_element_mut(&mut self, pos: S, x: T)
subtract a given value to an element
Source§fn sub_scalar_mut(&mut self, x: T)where
T: Number,
fn sub_scalar_mut(&mut self, x: T)where
T: Number,
subtract a given value to all the elements
Source§fn add_scalar_mut(&mut self, x: T)where
T: Number,
fn add_scalar_mut(&mut self, x: T)where
T: Number,
add a given value to all the elements
Source§fn mul_scalar_mut(&mut self, x: T)where
T: Number,
fn mul_scalar_mut(&mut self, x: T)where
T: Number,
multiply a given value to all the elements
Source§fn div_scalar_mut(&mut self, x: T)where
T: Number,
fn div_scalar_mut(&mut self, x: T)where
T: Number,
divide a given value to all the elements
Source§fn add_mut(&mut self, other: &dyn Array<T, S>)
fn add_mut(&mut self, other: &dyn Array<T, S>)
add values from another array to the values of initial array
Source§fn sub_mut(&mut self, other: &dyn Array<T, S>)
fn sub_mut(&mut self, other: &dyn Array<T, S>)
subtract values from another array to the values of initial array
Source§impl<T: Debug + Display + Copy + Sized> MutArrayView2<T> for DenseMatrix<T>
impl<T: Debug + Display + Copy + Sized> MutArrayView2<T> for DenseMatrix<T>
Source§fn pow_mut(&mut self, p: T)where
T: RealNumber,
fn pow_mut(&mut self, p: T)where
T: RealNumber,
update view values at power
p
Source§impl<T: Number + RealNumber> QRDecomposable<T> for DenseMatrix<T>
impl<T: Number + RealNumber> QRDecomposable<T> for DenseMatrix<T>
Source§impl<T: Number + RealNumber + RelativeEq> RelativeEq for DenseMatrix<T>
impl<T: Number + RealNumber + RelativeEq> RelativeEq for DenseMatrix<T>
Source§fn default_max_relative() -> T::Epsilon
fn default_max_relative() -> T::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
Source§fn relative_eq(
&self,
other: &Self,
epsilon: T::Epsilon,
max_relative: T::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: T::Epsilon, max_relative: T::Epsilon, ) -> bool
A test for equality that uses a relative comparison if the values are far apart.
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
The inverse of
RelativeEq::relative_eq
.Source§impl<T: Number + RealNumber> SVDDecomposable<T> for DenseMatrix<T>
impl<T: Number + RealNumber> SVDDecomposable<T> for DenseMatrix<T>
Source§fn svd_solve_mut(self, b: Self) -> Result<Self, Failed>
fn svd_solve_mut(self, b: Self) -> Result<Self, Failed>
Solves Ax = b. Overrides original matrix in the process.
Auto Trait Implementations§
impl<T> Freeze for DenseMatrix<T>
impl<T> RefUnwindSafe for DenseMatrix<T>where
T: RefUnwindSafe,
impl<T> Send for DenseMatrix<T>where
T: Send,
impl<T> Sync for DenseMatrix<T>where
T: Sync,
impl<T> Unpin for DenseMatrix<T>where
T: Unpin,
impl<T> UnwindSafe for DenseMatrix<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more