Struct rusty_machine::linalg::matrix::MatrixSlice
[−]
[src]
pub struct MatrixSlice<T> {
// some fields omitted
}A MatrixSlice
This struct provides a 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> MatrixSlice<T>[src]
fn from_matrix(mat: &Matrix<T>, start: [usize; 2], rows: usize, cols: usize) -> MatrixSlice<T>
Produce a matrix slice from a matrix
Examples
use rusty_machine::linalg::matrix::Matrix; use rusty_machine::linalg::matrix::MatrixSlice; let a = Matrix::new(3,3, (0..9).collect::<Vec<usize>>()); let slice = MatrixSlice::from_matrix(&a, [1,1], 2, 2);
fn reslice(self, start: [usize; 2], rows: usize, cols: usize) -> MatrixSlice<T>
Produce a matrix slice from an existing matrix slice.
Examples
use rusty_machine::linalg::matrix::Matrix; use rusty_machine::linalg::matrix::MatrixSlice; let a = Matrix::new(3,3, (0..9).collect::<Vec<usize>>()); let slice = MatrixSlice::from_matrix(&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::MatrixSlice; let a = Matrix::new(3,3, (0..9).collect::<Vec<usize>>()); let slice = MatrixSlice::from_matrix(&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]);
impl<T: Copy> MatrixSlice<T>[src]
fn into_matrix(self) -> Matrix<T>
Convert the matrix slice into a new Matrix.
Trait Implementations
impl<T> Index<[usize; 2]> for MatrixSlice<T>[src]
Indexes 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: Copy + Mul<T, Output=T>> Mul<T> for MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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 MatrixSlice<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.
impl<T: Copy> Copy for MatrixSlice<T>[src]
impl<T: Clone> Clone for MatrixSlice<T>[src]
fn clone(&self) -> MatrixSlice<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more