Trait Array2

Source
pub trait Array2<T: Debug + Display + Copy + Sized>:
    MutArrayView2<T>
    + Sized
    + Clone {
Show 42 methods // Required methods fn fill(nrows: usize, ncols: usize, value: T) -> Self; fn slice<'a>( &'a self, rows: Range<usize>, cols: Range<usize>, ) -> Box<dyn ArrayView2<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; fn from_iterator<I: Iterator<Item = T>>( iter: I, nrows: usize, ncols: usize, axis: u8, ) -> Self; fn get_row<'a>(&'a self, row: usize) -> Box<dyn ArrayView1<T> + 'a> where Self: Sized; fn get_col<'a>(&'a self, col: usize) -> Box<dyn ArrayView1<T> + 'a> where Self: Sized; // Provided methods fn zeros(nrows: usize, ncols: usize) -> Self where T: Number { ... } fn ones(nrows: usize, ncols: usize) -> Self where T: Number { ... } fn eye(size: usize) -> Self where T: Number { ... } fn rand(nrows: usize, ncols: usize) -> Self where T: RealNumber { ... } fn from_slice(slice: &dyn ArrayView2<T>) -> Self { ... } fn from_row(slice: &dyn ArrayView1<T>) -> Self { ... } fn from_column(slice: &dyn ArrayView1<T>) -> Self { ... } fn transpose(&self) -> Self { ... } fn reshape(&self, nrows: usize, ncols: usize, axis: u8) -> Self { ... } fn matmul(&self, other: &dyn ArrayView2<T>) -> Self where T: Number { ... } fn ab( &self, a_transpose: bool, b: &dyn ArrayView2<T>, b_transpose: bool, ) -> Self where T: Number { ... } fn ax(&self, a_transpose: bool, x: &dyn ArrayView1<T>) -> Self where T: Number { ... } fn concatenate_1d<'a>(arrays: &'a [&'a dyn ArrayView1<T>], axis: u8) -> Self { ... } fn concatenate_2d<'a>(arrays: &'a [&'a dyn ArrayView2<T>], axis: u8) -> Self { ... } fn merge_1d<'a>( &'a self, arrays: &'a [&'a dyn ArrayView1<T>], axis: u8, append: bool, ) -> Self { ... } fn v_stack(&self, other: &dyn ArrayView2<T>) -> Self { ... } fn h_stack(&self, other: &dyn ArrayView2<T>) -> Self { ... } fn map<O: Debug + Display + Copy + Sized, A: Array2<O>, F: FnMut(&T) -> O>( self, f: F, ) -> A { ... } fn row_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> { ... } fn take(&self, index: &[usize], axis: u8) -> Self { ... } fn take_column(&self, column_index: usize) -> Self { ... } fn add_scalar(&self, x: T) -> Self where T: Number { ... } fn sub_scalar(&self, x: T) -> Self where T: Number { ... } fn div_scalar(&self, x: T) -> Self where T: Number { ... } fn mul_scalar(&self, x: T) -> Self where T: Number { ... } fn add(&self, other: &dyn Array<T, (usize, usize)>) -> Self where T: Number { ... } fn sub(&self, other: &dyn Array<T, (usize, usize)>) -> Self where T: Number { ... } fn mul(&self, other: &dyn Array<T, (usize, usize)>) -> Self where T: Number { ... } fn div(&self, other: &dyn Array<T, (usize, usize)>) -> Self where T: Number { ... } fn abs(&self) -> Self where T: Number + Signed { ... } fn neg(&self) -> Self where T: Number + Neg<Output = T> { ... } fn pow(&self, p: T) -> Self where T: RealNumber { ... } fn column_mean(&self) -> Vec<f64> where T: Number + ToPrimitive { ... } fn copy_col_as_vec(&self, col: usize, result: &mut Vec<T>) { ... } fn approximate_eq(&self, other: &Self, error: T) -> bool where T: Number + RealNumber { ... }
}
Expand description

Trait for mutable 2D-array view

Required Methods§

Source

fn fill(nrows: usize, ncols: usize, value: T) -> Self

fill 2d array with a given value

Source

fn slice<'a>( &'a self, rows: Range<usize>, cols: Range<usize>, ) -> Box<dyn ArrayView2<T> + 'a>
where Self: Sized,

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,

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

create 2d array from iterator

Source

fn get_row<'a>(&'a self, row: usize) -> Box<dyn ArrayView1<T> + 'a>
where Self: Sized,

get row from 2d array

Source

fn get_col<'a>(&'a self, col: usize) -> Box<dyn ArrayView1<T> + 'a>
where Self: Sized,

get column from 2d array

Provided Methods§

Source

fn zeros(nrows: usize, ncols: usize) -> Self
where T: Number,

create a zero 2d array

Source

fn ones(nrows: usize, ncols: usize) -> Self
where T: Number,

create a 2d array of ones

Source

fn eye(size: usize) -> Self
where T: Number,

create an identity matrix

Source

fn rand(nrows: usize, ncols: usize) -> Self
where T: RealNumber,

create a 2d array of random values

Source

fn from_slice(slice: &dyn ArrayView2<T>) -> Self

crate from 2d slice

Source

fn from_row(slice: &dyn ArrayView1<T>) -> Self

create from row

Source

fn from_column(slice: &dyn ArrayView1<T>) -> Self

create from column

Source

fn transpose(&self) -> Self

transpose 2d array

Source

fn reshape(&self, nrows: usize, ncols: usize, axis: u8) -> Self

change shape of 2d array

Source

fn matmul(&self, other: &dyn ArrayView2<T>) -> Self
where T: Number,

multiply two 2d arrays

Source

fn ab( &self, a_transpose: bool, b: &dyn ArrayView2<T>, b_transpose: bool, ) -> Self
where T: Number,

matrix multiplication

Source

fn ax(&self, a_transpose: bool, x: &dyn ArrayView1<T>) -> Self
where T: Number,

matrix vector multiplication

Source

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

concatenate 2d array

Source

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

Stack arrays in sequence vertically

Source

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

map array values

Source

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>

iter cols

Source

fn take(&self, index: &[usize], axis: u8) -> Self

take elements from 2d array

Source

fn take_column(&self, column_index: usize) -> Self

Take an individual column from the matrix.

Source

fn add_scalar(&self, x: T) -> Self
where T: Number,

add a scalar to the array

Source

fn sub_scalar(&self, x: T) -> Self
where T: Number,

subtract a scalar from the array

Source

fn div_scalar(&self, x: T) -> Self
where T: Number,

divide a scalar from the array

Source

fn mul_scalar(&self, x: T) -> Self
where T: Number,

multiply a scalar to the array

Source

fn add(&self, other: &dyn Array<T, (usize, usize)>) -> Self
where T: Number,

sum of two arrays

Source

fn sub(&self, other: &dyn Array<T, (usize, usize)>) -> Self
where T: Number,

subtract two arrays

Source

fn mul(&self, other: &dyn Array<T, (usize, usize)>) -> Self
where T: Number,

multiply two arrays

Source

fn div(&self, other: &dyn Array<T, (usize, usize)>) -> Self
where T: Number,

divide two arrays

Source

fn abs(&self) -> Self
where T: Number + Signed,

absolute values of the array

Source

fn neg(&self) -> Self
where T: Number + Neg<Output = T>,

negation of the array

Source

fn pow(&self, p: T) -> Self
where T: RealNumber,

values at power p

Source

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>)

copy column as a vector

Source

fn approximate_eq(&self, other: &Self, error: T) -> bool
where T: Number + RealNumber,

approximate equality of the elements of a matrix according to a given error

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§