pub struct NDArray<T> {
pub shape: Shape,
pub size: usize,
pub rank: usize,
pub values: Vec<T>,
}
Fields§
§shape: Shape
§size: usize
§rank: usize
§values: Vec<T>
Implementations§
Source§impl<T: Default + Clone + Debug + PartialEq> NDArray<T>
impl<T: Default + Clone + Debug + PartialEq> NDArray<T>
Sourcepub fn new(shape: Vec<usize>) -> Result<NDArray<T>, String>
pub fn new(shape: Vec<usize>) -> Result<NDArray<T>, String>
Create instance of NDArray, provide shape dimensions as parameter
Sourcepub fn array(shape: Vec<usize>, values: Vec<T>) -> Result<NDArray<T>, String>
pub fn array(shape: Vec<usize>, values: Vec<T>) -> Result<NDArray<T>, String>
Create instance of NDArray, provide shape dimensions and array values as parameter
Sourcepub fn fill(shape: Vec<usize>, value: T) -> Result<NDArray<T>, String>
pub fn fill(shape: Vec<usize>, value: T) -> Result<NDArray<T>, String>
Fill ndarray with values
Sourcepub fn reshape(&mut self, shape_vals: Vec<usize>) -> Result<(), String>
pub fn reshape(&mut self, shape_vals: Vec<usize>) -> Result<(), String>
Reshape dimensions of array to new shape. Shape must match current size
Sourcepub fn index(&self, indices: Vec<usize>) -> Result<usize, String>
pub fn index(&self, indices: Vec<usize>) -> Result<usize, String>
Get contigous index of array using provided indices as parameter
Sourcepub fn indices(&self, index: usize) -> Result<Vec<usize>, String>
pub fn indices(&self, index: usize) -> Result<Vec<usize>, String>
Get indices from provided contigous index as parameter
Sourcepub fn set_idx(&mut self, idx: usize, value: T) -> Result<(), String>
pub fn set_idx(&mut self, idx: usize, value: T) -> Result<(), String>
Set index and generic value, index must be within size of array
Sourcepub fn set(&mut self, indices: Vec<usize>, value: T) -> Result<(), String>
pub fn set(&mut self, indices: Vec<usize>, value: T) -> Result<(), String>
Set generic value using provided indices. Indices must match rank of array
Sourcepub fn rows(&self, index: usize) -> Result<Vec<T>, String>
pub fn rows(&self, index: usize) -> Result<Vec<T>, String>
Get rows dimension associated with multi dimensional array
Sourcepub fn cols(&self, index: usize) -> Result<Vec<T>, String>
pub fn cols(&self, index: usize) -> Result<Vec<T>, String>
Get column dimension associated with multi dimensional array
Sourcepub fn axis(&self, axis: usize, index: usize) -> Result<NDArray<T>, String>
pub fn axis(&self, axis: usize, index: usize) -> Result<NDArray<T>, String>
Get values from a specific axis/slice
Sourcepub fn axis_indices(
&self,
axis: usize,
indices: Vec<usize>,
) -> Result<NDArray<T>, String>
pub fn axis_indices( &self, axis: usize, indices: Vec<usize>, ) -> Result<NDArray<T>, String>
Get mutiple axis values with provided indices
Sourcepub fn drop_axis(&self, axis: usize, index: usize) -> Result<NDArray<T>, String>
pub fn drop_axis(&self, axis: usize, index: usize) -> Result<NDArray<T>, String>
Drop specified axis of ndarray
Sourcepub fn batch(&self, batch_size: usize) -> Result<Vec<NDArray<T>>, String>
pub fn batch(&self, batch_size: usize) -> Result<Vec<NDArray<T>>, String>
Batch ndarray in specified amount of chunks of rows, cols etc.
pub fn value_indices(&self, value: T) -> Vec<usize>
pub fn indice_query(&self, indices: Vec<usize>) -> Result<NDArray<T>, String>
pub fn split( &self, axis: usize, percentage: f64, ) -> Result<(NDArray<T>, NDArray<T>), String>
Trait Implementations§
Source§impl AggregateOps for NDArray<f64>
impl AggregateOps for NDArray<f64>
Source§fn abs(&self) -> Result<NDArray<f64>, String>
fn abs(&self) -> Result<NDArray<f64>, String>
Get the absolute value of each element in ndarray
Source§fn mean(&self, axis: usize) -> Result<Vec<f64>, String>
fn mean(&self, axis: usize) -> Result<Vec<f64>, String>
Calculate the mean of values along a specific axis
Source§impl BinaryOps for NDArray<f64>
impl BinaryOps for NDArray<f64>
Source§fn mult(&self, other: NDArray<f64>) -> Result<NDArray<f64>, String>
fn mult(&self, other: NDArray<f64>) -> Result<NDArray<f64>, String>
Multiply an ndarray by another
Source§fn add(&self, value: NDArray<f64>) -> Result<NDArray<f64>, String>
fn add(&self, value: NDArray<f64>) -> Result<NDArray<f64>, String>
Add two NDArray’s and get resulting NDArray instance
Source§fn subtract(&self, value: NDArray<f64>) -> Result<NDArray<f64>, String>
fn subtract(&self, value: NDArray<f64>) -> Result<NDArray<f64>, String>
Subtract values in NDArray instances
Source§fn dot(&self, input: NDArray<f64>) -> Result<NDArray<f64>, String>
fn dot(&self, input: NDArray<f64>) -> Result<NDArray<f64>, String>
Perform dot product of current NDArray on another NDArray instance
Source§fn scale_add(&self, value: NDArray<f64>) -> Result<NDArray<f64>, String>
fn scale_add(&self, value: NDArray<f64>) -> Result<NDArray<f64>, String>
Add values by scalar for current NDArray instance
Source§fn scale_mult(&self, value: NDArray<f64>) -> Result<NDArray<f64>, String>
fn scale_mult(&self, value: NDArray<f64>) -> Result<NDArray<f64>, String>
Elementwise multiplication of ndarray
Source§impl<'de, T> Deserialize<'de> for NDArray<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for NDArray<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl ScalarOps for NDArray<f64>
impl ScalarOps for NDArray<f64>
Source§fn scalar_subtract(&self, scalar: f64) -> Result<NDArray<f64>, String>
fn scalar_subtract(&self, scalar: f64) -> Result<NDArray<f64>, String>
Subtract all values in ndarray by scalar
Source§fn scalar_add(&self, scalar: f64) -> Result<NDArray<f64>, String>
fn scalar_add(&self, scalar: f64) -> Result<NDArray<f64>, String>
Add all values in ndarray by scalar
Source§impl UnaryOps for NDArray<f64>
impl UnaryOps for NDArray<f64>
Source§fn transpose(self) -> Result<NDArray<f64>, String>
fn transpose(self) -> Result<NDArray<f64>, String>
Tranpose current NDArray instance, works only on rank 2 values
Source§fn permute(self, indice_order: Vec<usize>) -> Result<NDArray<f64>, String>
fn permute(self, indice_order: Vec<usize>) -> Result<NDArray<f64>, String>
Permute indices of NDArray. Can be used to peform transposes/contraction on rank 3 or higher values.
Source§fn sum_axis(&self, axis: usize) -> Result<NDArray<f64>, String>
fn sum_axis(&self, axis: usize) -> Result<NDArray<f64>, String>
Sum values along a specified axis
Source§fn select_axis(
&self,
axis: usize,
indices: Vec<usize>,
) -> Result<NDArray<f64>, String>
fn select_axis( &self, axis: usize, indices: Vec<usize>, ) -> Result<NDArray<f64>, String>
Select specific indices from an axis
Source§fn apply(
&self,
loss_func: fn(value: f64) -> f64,
) -> Result<NDArray<f64>, String>
fn apply( &self, loss_func: fn(value: f64) -> f64, ) -> Result<NDArray<f64>, String>
Apply loss function on values in ndarray
Source§fn argmax(&self, axis: usize) -> NDArray<f64>
fn argmax(&self, axis: usize) -> NDArray<f64>
Get’s the maximum values index along a specified axis