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§
Sourcefn slice<'a>(
&'a self,
rows: Range<usize>,
cols: Range<usize>,
) -> Box<dyn ArrayView2<T> + 'a>where
Self: Sized,
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
Sourcefn 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
Sourcefn 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
Provided Methods§
Sourcefn rand(nrows: usize, ncols: usize) -> Selfwhere
T: RealNumber,
fn rand(nrows: usize, ncols: usize) -> Selfwhere
T: RealNumber,
create a 2d array of random values
Sourcefn from_slice(slice: &dyn ArrayView2<T>) -> Self
fn from_slice(slice: &dyn ArrayView2<T>) -> Self
crate from 2d slice
Sourcefn from_row(slice: &dyn ArrayView1<T>) -> Self
fn from_row(slice: &dyn ArrayView1<T>) -> Self
create from row
Sourcefn from_column(slice: &dyn ArrayView1<T>) -> Self
fn from_column(slice: &dyn ArrayView1<T>) -> Self
create from column
Sourcefn matmul(&self, other: &dyn ArrayView2<T>) -> Selfwhere
T: Number,
fn matmul(&self, other: &dyn ArrayView2<T>) -> Selfwhere
T: Number,
multiply two 2d arrays
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn v_stack(&self, other: &dyn ArrayView2<T>) -> Self
fn v_stack(&self, other: &dyn ArrayView2<T>) -> Self
Stack arrays in sequence vertically
Sourcefn h_stack(&self, other: &dyn ArrayView2<T>) -> Self
fn h_stack(&self, other: &dyn ArrayView2<T>) -> Self
Stack arrays in sequence horizontally
Sourcefn 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
Sourcefn 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
Sourcefn 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
Sourcefn take_column(&self, column_index: usize) -> Self
fn take_column(&self, column_index: usize) -> Self
Take an individual column from the matrix.
Sourcefn add_scalar(&self, x: T) -> Selfwhere
T: Number,
fn add_scalar(&self, x: T) -> Selfwhere
T: Number,
add a scalar to the array
Sourcefn sub_scalar(&self, x: T) -> Selfwhere
T: Number,
fn sub_scalar(&self, x: T) -> Selfwhere
T: Number,
subtract a scalar from the array
Sourcefn div_scalar(&self, x: T) -> Selfwhere
T: Number,
fn div_scalar(&self, x: T) -> Selfwhere
T: Number,
divide a scalar from the array
Sourcefn mul_scalar(&self, x: T) -> Selfwhere
T: Number,
fn mul_scalar(&self, x: T) -> Selfwhere
T: Number,
multiply a scalar to the array
Sourcefn 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
Sourcefn 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
Sourcefn pow(&self, p: T) -> Selfwhere
T: RealNumber,
fn pow(&self, p: T) -> Selfwhere
T: RealNumber,
values at power p
Sourcefn column_mean(&self) -> Vec<f64>where
T: Number + ToPrimitive,
fn column_mean(&self) -> Vec<f64>where
T: Number + ToPrimitive,
compute mean for each column
Sourcefn 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
Sourcefn 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
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.