Skip to main content

Array1

Trait Array1 

Source
pub trait Array1<T: Debug + Display + Copy + Sized>:
    MutArrayView1<T>
    + Sized
    + Clone {
Show 26 methods // Required methods fn slice<'a>(&'a self, range: Range<usize>) -> Box<dyn ArrayView1<T> + 'a>; fn slice_mut<'a>( &'a mut self, range: Range<usize>, ) -> Box<dyn MutArrayView1<T> + 'a>; fn fill(len: usize, value: T) -> Self where Self: Sized; fn from_iterator<I: Iterator<Item = T>>(iter: I, len: usize) -> Self where Self: Sized; fn from_vec_slice(slice: &[T]) -> Self where Self: Sized; fn from_slice(slice: &dyn ArrayView1<T>) -> Self where Self: Sized; // Provided methods fn zeros(len: usize) -> Self where T: Number, Self: Sized { ... } fn ones(len: usize) -> Self where T: Number, Self: Sized { ... } fn rand(len: usize) -> Self where T: RealNumber, Self: Sized { ... } fn add_scalar(&self, x: T) -> Self where T: Number, Self: Sized { ... } fn sub_scalar(&self, x: T) -> Self where T: Number, Self: Sized { ... } fn div_scalar(&self, x: T) -> Self where T: Number, Self: Sized { ... } fn mul_scalar(&self, x: T) -> Self where T: Number, Self: Sized { ... } fn add(&self, other: &dyn Array<T, usize>) -> Self where T: Number, Self: Sized { ... } fn sub(&self, other: &impl Array1<T>) -> Self where T: Number, Self: Sized { ... } fn mul(&self, other: &dyn Array<T, usize>) -> Self where T: Number, Self: Sized { ... } fn div(&self, other: &dyn Array<T, usize>) -> Self where T: Number, Self: Sized { ... } fn take(&self, index: &[usize]) -> Self where Self: Sized { ... } fn abs(&self) -> Self where T: Number + Signed, Self: Sized { ... } fn neg(&self) -> Self where T: Number + Neg<Output = T>, Self: Sized { ... } fn pow(&self, p: T) -> Self where T: RealNumber, Self: Sized { ... } fn argsort(&self) -> Vec<usize> where T: Number + PartialOrd { ... } fn map<O: Debug + Display + Copy + Sized, A: Array1<O>, F: FnMut(&T) -> O>( self, f: F, ) -> A { ... } fn softmax(&self) -> Self where T: RealNumber, Self: Sized { ... } fn xa(&self, a_transpose: bool, a: &dyn ArrayView2<T>) -> Self where T: Number, Self: Sized { ... } fn approximate_eq(&self, other: &Self, error: T) -> bool where T: Number + RealNumber, Self: Sized { ... }
}
Expand description

Trait for mutable 1D-array view

Required Methods§

Source

fn slice<'a>(&'a self, range: Range<usize>) -> Box<dyn ArrayView1<T> + 'a>

return a view of the array

Source

fn slice_mut<'a>( &'a mut self, range: Range<usize>, ) -> Box<dyn MutArrayView1<T> + 'a>

return a mutable view of the array

Source

fn fill(len: usize, value: T) -> Self
where Self: Sized,

fill array with a given value

Source

fn from_iterator<I: Iterator<Item = T>>(iter: I, len: usize) -> Self
where Self: Sized,

create array from iterator

Source

fn from_vec_slice(slice: &[T]) -> Self
where Self: Sized,

create array from vector

Source

fn from_slice(slice: &dyn ArrayView1<T>) -> Self
where Self: Sized,

create array from slice

Provided Methods§

Source

fn zeros(len: usize) -> Self
where T: Number, Self: Sized,

create a zero array

Source

fn ones(len: usize) -> Self
where T: Number, Self: Sized,

create an array of ones

Source

fn rand(len: usize) -> Self
where T: RealNumber, Self: Sized,

create an array of random values

Source

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

add a scalar to the array

Source

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

subtract a scalar from the array

Source

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

divide a scalar from the array

Source

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

multiply a scalar to the array

Source

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

sum of two arrays

Source

fn sub(&self, other: &impl Array1<T>) -> Self
where T: Number, Self: Sized,

subtract two arrays

Source

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

multiply two arrays

Source

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

divide two arrays

Source

fn take(&self, index: &[usize]) -> Self
where Self: Sized,

replace values with another array

Source

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

create a view of the array with absolute values

Source

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

create a view of the array with opposite sign

Source

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

create a view of the array with values at power p

Source

fn argsort(&self) -> Vec<usize>
where T: Number + PartialOrd,

apply argsort to the array

Source

fn map<O: Debug + Display + Copy + Sized, A: Array1<O>, F: FnMut(&T) -> O>( self, f: F, ) -> A

map values of the array

Source

fn softmax(&self) -> Self
where T: RealNumber, Self: Sized,

apply softmax to the array

Source

fn xa(&self, a_transpose: bool, a: &dyn ArrayView2<T>) -> Self
where T: Number, Self: Sized,

multiply array by matrix

Source

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

check if two arrays are approximately equal

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Debug + Display + Copy + Sized> Array1<T> for Vec<T>

Source§

fn slice<'a>(&'a self, range: Range<usize>) -> Box<dyn ArrayView1<T> + 'a>

Source§

fn slice_mut<'b>( &'b mut self, range: Range<usize>, ) -> Box<dyn MutArrayView1<T> + 'b>

Source§

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

Source§

fn from_iterator<I: Iterator<Item = T>>(iter: I, len: usize) -> Self
where Self: Sized,

Source§

fn from_vec_slice(slice: &[T]) -> Self

Source§

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

Implementors§