Struct rusty_machine::linalg::matrix::MatrixSliceMut
[−]
[src]
pub struct MatrixSliceMut<T> {
// some fields omitted
}A mutable MatrixSlice
This struct provides a mutable slice into a matrix.
The struct contains the upper left point of the slice and the width and height of the slice.
Methods
impl<T> MatrixSliceMut<T>[src]
fn from_matrix(mat: &mut Matrix<T>, start: [usize; 2], rows: usize, cols: usize) -> MatrixSliceMut<T>
Produce a matrix slice from a matrix
Examples
use rusty_machine::linalg::matrix::Matrix; use rusty_machine::linalg::matrix::MatrixSliceMut; let mut a = Matrix::new(3,3, (0..9).collect::<Vec<usize>>()); let slice = MatrixSliceMut::from_matrix(&mut a, [1,1], 2, 2);
fn reslice(self, start: [usize; 2], rows: usize, cols: usize) -> MatrixSliceMut<T>
Produce a matrix slice from an existing matrix slice.
Examples
use rusty_machine::linalg::matrix::Matrix; use rusty_machine::linalg::matrix::MatrixSliceMut; let mut a = Matrix::new(3,3, (0..9).collect::<Vec<usize>>()); let slice = MatrixSliceMut::from_matrix(&mut a, [1,1], 2, 2); let new_slice = slice.reslice([0,0], 1, 1);
fn iter(&self) -> SliceIter<T>
Returns an iterator over the matrix slice.
Examples
use rusty_machine::linalg::matrix::Matrix; use rusty_machine::linalg::matrix::MatrixSliceMut; let mut a = Matrix::new(3,3, (0..9).collect::<Vec<usize>>()); let slice = MatrixSliceMut::from_matrix(&mut a, [1,1], 2, 2); let slice_data = slice.iter().map(|v| *v).collect::<Vec<usize>>(); assert_eq!(slice_data, vec![4,5,7,8]);
fn iter_mut(&mut self) -> SliceIterMut<T>
Returns a mutable iterator over the matrix slice.
Examples
use rusty_machine::linalg::matrix::Matrix; use rusty_machine::linalg::matrix::MatrixSliceMut; let mut a = Matrix::new(3,3, (0..9).collect::<Vec<usize>>()); { let mut slice = MatrixSliceMut::from_matrix(&mut a, [1,1], 2, 2); for d in slice.iter_mut() { *d = *d + 2; } } // Only the matrix slice is updated. assert_eq!(a.into_vec(), vec![0,1,2,3,6,7,6,9,10]);
impl<T: Copy> MatrixSliceMut<T>[src]
fn into_matrix(self) -> Matrix<T>
Convert the matrix slice into a new Matrix.
Trait Implementations
impl<T> Index<[usize; 2]> for MatrixSliceMut<T>[src]
Indexes mutable matrix slice.
Takes row index first then column.
type Output = T
The returned type after indexing
fn index(&self, idx: [usize; 2]) -> &T
The method for the indexing (Foo[Bar]) operation
impl<T> IndexMut<[usize; 2]> for MatrixSliceMut<T>[src]
Indexes mutable matrix slice.
Takes row index first then column.
impl<T: Copy + Mul<T, Output=T>> Mul<T> for MatrixSliceMut<T>[src]
Scalar multiplication with matrix slice.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, f: T) -> Matrix<T>
The method for the * operator
impl<'a, T: Copy + Mul<T, Output=T>> Mul<&'a T> for MatrixSliceMut<T>[src]
Scalar multiplication with matrix slice.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, f: &T) -> Matrix<T>
The method for the * operator
impl<'a, T: Copy + Mul<T, Output=T>> Mul<T> for &'a MatrixSliceMut<T>[src]
Scalar multiplication with matrix slice.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, f: T) -> Matrix<T>
The method for the * operator
impl<'a, 'b, T: Copy + Mul<T, Output=T>> Mul<&'b T> for &'a MatrixSliceMut<T>[src]
Scalar multiplication with matrix slice.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, f: &T) -> Matrix<T>
The method for the * operator
impl<T: Copy + Div<T, Output=T>> Div<T> for MatrixSliceMut<T>[src]
Scalar division with matrix slice.
type Output = Matrix<T>
The resulting type after applying the / operator
fn div(self, f: T) -> Matrix<T>
The method for the / operator
impl<'a, T: Copy + Div<T, Output=T>> Div<&'a T> for MatrixSliceMut<T>[src]
Scalar division with matrix slice.
type Output = Matrix<T>
The resulting type after applying the / operator
fn div(self, f: &T) -> Matrix<T>
The method for the / operator
impl<'a, T: Copy + Div<T, Output=T>> Div<T> for &'a MatrixSliceMut<T>[src]
Scalar division with matrix slice.
type Output = Matrix<T>
The resulting type after applying the / operator
fn div(self, f: T) -> Matrix<T>
The method for the / operator
impl<'a, 'b, T: Copy + Div<T, Output=T>> Div<&'b T> for &'a MatrixSliceMut<T>[src]
Scalar division with matrix slice.
type Output = Matrix<T>
The resulting type after applying the / operator
fn div(self, f: &T) -> Matrix<T>
The method for the / operator
impl<T: Copy + Add<T, Output=T>> Add<T> for MatrixSliceMut<T>[src]
Scalar addition with matrix slice.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, f: T) -> Matrix<T>
The method for the + operator
impl<'a, T: Copy + Add<T, Output=T>> Add<&'a T> for MatrixSliceMut<T>[src]
Scalar addition with matrix slice.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, f: &T) -> Matrix<T>
The method for the + operator
impl<'a, T: Copy + Add<T, Output=T>> Add<T> for &'a MatrixSliceMut<T>[src]
Scalar addition with matrix slice.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, f: T) -> Matrix<T>
The method for the + operator
impl<'a, 'b, T: Copy + Add<T, Output=T>> Add<&'b T> for &'a MatrixSliceMut<T>[src]
Scalar addition with matrix slice.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, f: &T) -> Matrix<T>
The method for the + operator
impl<T: Copy + Sub<T, Output=T>> Sub<T> for MatrixSliceMut<T>[src]
Scalar subtraction with matrix slice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, f: T) -> Matrix<T>
The method for the - operator
impl<'a, T: Copy + Sub<T, Output=T>> Sub<&'a T> for MatrixSliceMut<T>[src]
Scalar subtraction with matrix slice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, f: &T) -> Matrix<T>
The method for the - operator
impl<'a, T: Copy + Sub<T, Output=T>> Sub<T> for &'a MatrixSliceMut<T>[src]
Scalar subtraction with matrix slice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, f: T) -> Matrix<T>
The method for the - operator
impl<'a, 'b, T: Copy + Sub<T, Output=T>> Sub<&'b T> for &'a MatrixSliceMut<T>[src]
Scalar subtraction with matrix slice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, f: &T) -> Matrix<T>
The method for the - operator
impl<T: Copy + Add<T, Output=T>> Add<MatrixSlice<T>> for MatrixSliceMut<T>[src]
Performs elementwise addition between the slices.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, s: MatrixSlice<T>) -> Matrix<T>
The method for the + operator
impl<'a, T: Copy + Add<T, Output=T>> Add<MatrixSlice<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise addition between the slices.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, s: MatrixSlice<T>) -> Matrix<T>
The method for the + operator
impl<'a, T: Copy + Add<T, Output=T>> Add<&'a MatrixSlice<T>> for MatrixSliceMut<T>[src]
Performs elementwise addition between the slices.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, s: &MatrixSlice<T>) -> Matrix<T>
The method for the + operator
impl<'a, 'b, T: Copy + Add<T, Output=T>> Add<&'b MatrixSlice<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise addition between the slices.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, s: &MatrixSlice<T>) -> Matrix<T>
The method for the + operator
impl<T: Copy + Add<T, Output=T>> Add<MatrixSliceMut<T>> for MatrixSliceMut<T>[src]
Performs elementwise addition between the slices.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, s: MatrixSliceMut<T>) -> Matrix<T>
The method for the + operator
impl<'a, T: Copy + Add<T, Output=T>> Add<MatrixSliceMut<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise addition between the slices.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, s: MatrixSliceMut<T>) -> Matrix<T>
The method for the + operator
impl<'a, T: Copy + Add<T, Output=T>> Add<&'a MatrixSliceMut<T>> for MatrixSliceMut<T>[src]
Performs elementwise addition between the slices.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, s: &MatrixSliceMut<T>) -> Matrix<T>
The method for the + operator
impl<'a, 'b, T: Copy + Add<T, Output=T>> Add<&'b MatrixSliceMut<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise addition between the slices.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, s: &MatrixSliceMut<T>) -> Matrix<T>
The method for the + operator
impl<T: Copy + Sub<T, Output=T>> Sub<MatrixSlice<T>> for MatrixSliceMut<T>[src]
Performs elementwise subtraction between the slices.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, s: MatrixSlice<T>) -> Matrix<T>
The method for the - operator
impl<'a, T: Copy + Sub<T, Output=T>> Sub<MatrixSlice<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise subtraction between the slices.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, s: MatrixSlice<T>) -> Matrix<T>
The method for the - operator
impl<'a, T: Copy + Sub<T, Output=T>> Sub<&'a MatrixSlice<T>> for MatrixSliceMut<T>[src]
Performs elementwise subtraction between the slices.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, s: &MatrixSlice<T>) -> Matrix<T>
The method for the - operator
impl<'a, 'b, T: Copy + Sub<T, Output=T>> Sub<&'b MatrixSlice<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise subtraction between the slices.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, s: &MatrixSlice<T>) -> Matrix<T>
The method for the - operator
impl<T: Copy + Sub<T, Output=T>> Sub<MatrixSliceMut<T>> for MatrixSliceMut<T>[src]
Performs elementwise subtraction between the slices.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, s: MatrixSliceMut<T>) -> Matrix<T>
The method for the - operator
impl<'a, T: Copy + Sub<T, Output=T>> Sub<MatrixSliceMut<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise subtraction between the slices.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, s: MatrixSliceMut<T>) -> Matrix<T>
The method for the - operator
impl<'a, T: Copy + Sub<T, Output=T>> Sub<&'a MatrixSliceMut<T>> for MatrixSliceMut<T>[src]
Performs elementwise subtraction between the slices.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, s: &MatrixSliceMut<T>) -> Matrix<T>
The method for the - operator
impl<'a, 'b, T: Copy + Sub<T, Output=T>> Sub<&'b MatrixSliceMut<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise subtraction between the slices.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, s: &MatrixSliceMut<T>) -> Matrix<T>
The method for the - operator
impl<T: Copy + Add<T, Output=T>> Add<Matrix<T>> for MatrixSliceMut<T>[src]
Performs elementwise
addition
between Matrix and MatrixSlice.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, m: Matrix<T>) -> Matrix<T>
The method for the + operator
impl<'a, T: Copy + Add<T, Output=T>> Add<Matrix<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise
addition
between Matrix and MatrixSlice.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, m: Matrix<T>) -> Matrix<T>
The method for the + operator
impl<'a, T: Copy + Add<T, Output=T>> Add<&'a Matrix<T>> for MatrixSliceMut<T>[src]
Performs elementwise
addition
between Matrix and MatrixSlice.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, m: &Matrix<T>) -> Matrix<T>
The method for the + operator
impl<'a, 'b, T: Copy + Add<T, Output=T>> Add<&'b Matrix<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise
addition
between Matrix and MatrixSlice.
type Output = Matrix<T>
The resulting type after applying the + operator
fn add(self, m: &Matrix<T>) -> Matrix<T>
The method for the + operator
impl<T: Copy + Sub<T, Output=T>> Sub<Matrix<T>> for MatrixSliceMut<T>[src]
Performs elementwise
subtraction
between Matrix and MatrixSlice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, m: Matrix<T>) -> Matrix<T>
The method for the - operator
impl<'a, T: Copy + Sub<T, Output=T>> Sub<Matrix<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise
subtraction
between Matrix and MatrixSlice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, m: Matrix<T>) -> Matrix<T>
The method for the - operator
impl<'a, T: Copy + Sub<T, Output=T>> Sub<&'a Matrix<T>> for MatrixSliceMut<T>[src]
Performs elementwise
subtraction
between Matrix and MatrixSlice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, m: &Matrix<T>) -> Matrix<T>
The method for the - operator
impl<'a, 'b, T: Copy + Sub<T, Output=T>> Sub<&'b Matrix<T>> for &'a MatrixSliceMut<T>[src]
Performs elementwise
subtraction
between Matrix and MatrixSlice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn sub(self, m: &Matrix<T>) -> Matrix<T>
The method for the - operator
impl<T: Neg<Output=T> + Copy> Neg for MatrixSliceMut<T>[src]
Gets negative of matrix slice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn neg(self) -> Matrix<T>
The method for the unary - operator
impl<'a, T: Neg<Output=T> + Copy> Neg for &'a MatrixSliceMut<T>[src]
Gets negative of matrix slice.
type Output = Matrix<T>
The resulting type after applying the - operator
fn neg(self) -> Matrix<T>
The method for the unary - operator
impl<T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<Matrix<T>> for MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: Matrix<T>) -> Matrix<T>
The method for the * operator
impl<'a, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<&'a Matrix<T>> for MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: &Matrix<T>) -> Matrix<T>
The method for the * operator
impl<'a, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<Matrix<T>> for &'a MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: Matrix<T>) -> Matrix<T>
The method for the * operator
impl<'a, 'b, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<&'b Matrix<T>> for &'a MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: &Matrix<T>) -> Matrix<T>
The method for the * operator
impl<T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<MatrixSlice<T>> for MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: MatrixSlice<T>) -> Matrix<T>
The method for the * operator
impl<'a, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<&'a MatrixSlice<T>> for MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: &MatrixSlice<T>) -> Matrix<T>
The method for the * operator
impl<'a, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<MatrixSlice<T>> for &'a MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: MatrixSlice<T>) -> Matrix<T>
The method for the * operator
impl<'a, 'b, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<&'b MatrixSlice<T>> for &'a MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: &MatrixSlice<T>) -> Matrix<T>
The method for the * operator
impl<T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<MatrixSliceMut<T>> for MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: MatrixSliceMut<T>) -> Matrix<T>
The method for the * operator
impl<'a, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<&'a MatrixSliceMut<T>> for MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: &MatrixSliceMut<T>) -> Matrix<T>
The method for the * operator
impl<'a, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<MatrixSliceMut<T>> for &'a MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: MatrixSliceMut<T>) -> Matrix<T>
The method for the * operator
impl<'a, 'b, T: Any + Copy + Zero + Add<T, Output=T> + Mul<T, Output=T>> Mul<&'b MatrixSliceMut<T>> for &'a MatrixSliceMut<T>[src]
Multiplies two matrices together.
type Output = Matrix<T>
The resulting type after applying the * operator
fn mul(self, m: &MatrixSliceMut<T>) -> Matrix<T>
The method for the * operator
impl<T> BaseSlice<T> for MatrixSliceMut<T>[src]
fn rows(&self) -> usize
Rows in the slice.
fn cols(&self) -> usize
Columns in the slice.
fn as_ptr(&self) -> *const T
Top left index of the slice.
unsafe fn get_unchecked(&self, index: [usize; 2]) -> &T
Get a reference to a point in the slice without bounds checking.