[−][src]Struct numas::array::Array
Array structure
Fields
data: Rc<RefCell<Vec<T>>>
shape: Shape
Methods
impl<T: Copy> Array<T>
[src]
pub fn new_bounded(
data: Vec<T>,
shape: Vec<i32>,
start: usize,
end: usize
) -> Array<T>
[src]
data: Vec<T>,
shape: Vec<i32>,
start: usize,
end: usize
) -> Array<T>
Creates new bounded array
Arguments
data
- array elementsshape
- vector representing array shapestart
- start offset of array dataend
- end offset of array data
pub fn new(data: Vec<T>, shape: Vec<i32>) -> Array<T>
[src]
pub fn shape(&self) -> &Shape
[src]
Returns Shape instance
pub fn get_shape(&self) -> &Vec<i32>
[src]
Returns vector representing array shape
pub fn reshape(&mut self, shape: Vec<i32>) -> &Array<T>
[src]
pub fn set_shape(&mut self, shape: Vec<i32>)
[src]
pub fn set(&self, indices: Vec<usize>, value: T)
[src]
Set values on given indices to given value
Arguments
indices
- vector of indicesvalue
- value to fill it with
Examples
#[macro_use] extern crate numas; use numas::array::Array; let f_array = Array::new(vec![1,2,3,4,5,6,7,8,9], vec![3,3]); // first row f_array.set(s![0], -1); assert_eq!(f_array.collect(), vec![-1,-1,-1,4,5,6,7,8,9]); let s_array = Array::new(vec![1,2,3,4,5,6,7,8,9], vec![3,3]); // fist two rows s_array.set(s![0 => 2], -1); assert_eq!(s_array.collect(), vec![-1,-1,-1,-1,-1,-1,7,8,9]); let t_array = Array::new(vec![1,2,3,4,5,6,7,8,9], vec![3,3]); // second row, second column t_array.set(s![1; 1], -1); assert_eq!(t_array.collect(), vec![1,2,3,4,-1,6,7,8,9]); let x_array = Array::new(vec![1,2,3,4,5,6,7,8,9], vec![3,3]); // last row, two last columns x_array.set(s![2; 1 => 3], -1); assert_eq!(x_array.collect(), vec![1,2,3,4,5,6,7,-1,-1]);
pub fn fill(&self, value: T) -> &Array<T>
[src]
pub fn get(&self, indices: Vec<usize>) -> Array<T>
[src]
Return new Array from given indices
Arguments
indices
- vector of indices
Examples
#[macro_use] extern crate numas; use numas::array::Array; let array = Array::new(vec![1,2,3,4,5,6,7,8,9], vec![3,3]); // first row assert_eq!(array.get(s![0]).collect(), vec![1,2,3]); // fist two rows assert_eq!(array.get(s![0 => 2]).collect(), vec![1,2,3,4,5,6]); // second row, second column assert_eq!(array.get(s![1; 1]).collect(), vec![5]); // last row, two last columns assert_eq!(array.get(s![2; 1 => 3]).collect(), vec![8,9]);
pub fn len(&self) -> usize
[src]
Returns length of array
pub fn base_len(&self) -> usize
[src]
Returns base length of array
pub fn view(&self) -> Array<T>
[src]
Creates view into array
pub fn bounded_view(
&self,
shape: &Vec<i32>,
start: usize,
end: usize
) -> Array<T>
[src]
&self,
shape: &Vec<i32>,
start: usize,
end: usize
) -> Array<T>
Creates bounded view into array
Arguments
shape
- vector representing array shapestart
- start offset of array dataend
- end offset of array data
pub fn collect(&self) -> Vec<T>
[src]
Collects elements of array into vector
impl<T> Array<T> where
T: Copy + PartialOrd,
[src]
T: Copy + PartialOrd,
pub fn lt(&self, other: &Array<T>) -> Array<u8>
[src]
Returns array of 1s and 0s representing truth value of lesser than element wise
Arguments
other
- Array to compare with
Examples
use numas::array::Array;; let first = Array::new(vec![1, 2, 3, 3], vec![4]); let second = Array::new(vec![1, 0, 3, 4], vec![4]); let less = first.lt(&second); assert_eq!(less.collect(), vec![0, 0, 0, 1]);
pub fn le(&self, other: &Array<T>) -> Array<u8>
[src]
Returns array of 1s and 0s representing truth value of lesser equal element wise
Arguments
other
- Array to compare with
Examples
use numas::array::Array;; let first = Array::new(vec![1, 2, 3, 3], vec![4]); let second = Array::new(vec![1, 0, 3, 4], vec![4]); let less_equal = first.le(&second); assert_eq!(less_equal.collect(), vec![1, 0, 1, 1]);
pub fn gt(&self, other: &Array<T>) -> Array<u8>
[src]
Returns array of 1s and 0s representing truth value of greater than element wise
Arguments
other
- Array to compare with with
Examples
use numas::array::Array;; let first = Array::new(vec![1, 2, 3, 3], vec![4]); let second = Array::new(vec![1, 0, 3, 4], vec![4]); let greater = first.gt(&second); assert_eq!(greater.collect(), vec![0, 1, 0, 0]);
pub fn ge(&self, other: &Array<T>) -> Array<u8>
[src]
Returns array of 1s and 0s representing truth value of greater equal element wise
Arguments
other
- Array to compare with
Examples
use numas::array::Array;; let first = Array::new(vec![1, 2, 3, 3], vec![4]); let second = Array::new(vec![1, 0, 3, 4], vec![4]); let greater_equal = first.ge(&second); assert_eq!(greater_equal.collect(), vec![1, 1, 1, 0]);
impl<T> Array<T> where
T: Copy + PartialEq,
[src]
T: Copy + PartialEq,
pub fn eq(&self, other: &Array<T>) -> Array<u8>
[src]
Returns array of 1s and 0s representing truth value of equality element wise
Arguments
other
- Array to comapre with
Examples
use numas::array::Array;; let first = Array::new(vec![1, 2, 3, 4], vec![4]); let second = Array::new(vec![1, 0, 3, 4], vec![4]); let equality = first.eq(&second); assert_eq!(equality.collect(), vec![1, 0, 1, 1]);
pub fn neq(&self, other: &Array<T>) -> Array<u8>
[src]
Returns array of 1s and 0s representing truth value of not equality element wise
Arguments
other
- Array to compare with
Examples
use numas::array::Array;; let first = Array::new(vec![1, 2, 3, 4], vec![4]); let second = Array::new(vec![1, 0, 3, 4], vec![4]); let not_equality = first.neq(&second); assert_eq!(not_equality.collect(), vec![0, 1, 0, 0]);
impl<T> Array<T> where
T: Copy + Into<f64>,
[src]
T: Copy + Into<f64>,
pub fn sinh(&self) -> Array<f64>
[src]
Applies hyperbolic sine on elements from given array and creates new array
pub fn cosh(&self) -> Array<f64>
[src]
Applies hyperbolic cosine on elements from given array and creates new array
pub fn tanh(&self) -> Array<f64>
[src]
Applies hyperbolic tangent on elements from given array and creates new array
pub fn arcsinh(&self) -> Array<f64>
[src]
Applies inverse hyperbolic sine on elements from given array and creates new array
pub fn arccosh(&self) -> Array<f64>
[src]
Applies hyperbolic cosine on elements from given array and creates new array
pub fn arctanh(&self) -> Array<f64>
[src]
Applies hyperbolic tangent on elements from given array and creates new array
impl<T> Array<T> where
T: Copy + Into<f64>,
[src]
T: Copy + Into<f64>,
pub fn sin(&self) -> Array<f64>
[src]
Applies sine on elements from given array and creates new array
pub fn cos(&self) -> Array<f64>
[src]
Applies cosine on elements from given array and creates new array
pub fn tan(&self) -> Array<f64>
[src]
Applies tangent on elements from given array and creates new array
pub fn arcsin(&self) -> Array<f64>
[src]
Applies inverse sine on elements from given array and creates new array
pub fn arccos(&self) -> Array<f64>
[src]
Applies inverse cosine on elements from given array and creates new array
pub fn arctan(&self) -> Array<f64>
[src]
Applies inverse tangent on elements from given array and creates new array
pub fn degrees(&self) -> Array<f64>
[src]
Converts elements from given array to degrees and creates new array
pub fn radians(&self) -> Array<f64>
[src]
Converts elements from given array to radians and creates new array
pub fn deg2rad(&self) -> Array<f64>
[src]
Converts elements from given array to degrees and creates new array
pub fn rad2deg(&self) -> Array<f64>
[src]
Converts elements from given array to radians and creates new array
impl<T> Array<T> where
T: Copy + From<u8>,
[src]
T: Copy + From<u8>,
pub fn sum(&self) -> T where
T: AddAssign,
[src]
T: AddAssign,
Returns sums of all elements in array or view
Examples
use numas::array::Array;; let array = Array::new(vec![1, 2, 3, 4], vec![4]); assert_eq!(array.sum(), 10);
pub fn prod(&self) -> T where
T: MulAssign,
[src]
T: MulAssign,
Returns product of all elements in array or view
Examples
use numas::array::Array;; let array = Array::new(vec![1, 2, 3, 4], vec![4]); assert_eq!(array.prod(), 24);
impl<T> Array<T> where
T: Copy + Into<f64>,
[src]
T: Copy + Into<f64>,
pub fn sqrt(&self) -> Array<f64>
[src]
Applies square root on elements from given array and creates new array
Examples
use numas::array::Array; let array = Array::new(vec![4, 9, 16, 25], vec![4]); let sqrt_array = array.sqrt(); let data = sqrt_array.collect(); assert_eq!(data, vec![2.0, 3.0, 4.0, 5.0]);
impl<T> Array<T> where
T: Copy + Into<f64>,
[src]
T: Copy + Into<f64>,
pub fn round(&self) -> Array<f64>
[src]
Applies rounding on elements from given array and creates new array
Examples
use numas::array::Array; let array = Array::new(vec![1.4, 1.5, 2.1, 2.6], vec![4]); let rounded = array.round(); let data = rounded.collect(); assert_eq!(data, vec![1.0, 2.0, 2.0, 3.0]);
pub fn ceil(&self) -> Array<f64>
[src]
Applies round ceil on elements from given array and creates new array
Examples
use numas::array::Array; let array = Array::new(vec![1.4, -1.5, 2.1, 2.6], vec![4]); let rounded = array.ceil(); let data = rounded.collect(); assert_eq!(data, vec![2.0, -1.0, 3.0, 3.0]);
pub fn floor(&self) -> Array<f64>
[src]
Applies round floor on elements from given array and creates new array
Examples
use numas::array::Array; let array = Array::new(vec![1.4, -1.5, 2.1, 2.6], vec![4]); let rounded = array.floor(); let data = rounded.collect(); assert_eq!(data, vec![1.0, -2.0, 2.0, 2.0]);
pub fn trunc(&self) -> Array<f64>
[src]
Applies truncating on elements from given array and creates new array
Examples
use numas::array::Array; let array = Array::new(vec![1.4, -1.5, 2.1, 2.6], vec![4]); let rounded = array.round(); let data = rounded.collect(); assert_eq!(data, vec![1.0, -2.0, 2.0, 3.0]);
impl<T> Array<T> where
T: Copy + Into<f64>,
[src]
T: Copy + Into<f64>,
pub fn log(&self, base: f64) -> Array<f64>
[src]
Applies logarithm with given base on elements from given array and creates new array
pub fn log2(&self) -> Array<f64>
[src]
Applies logarithm with base 2 on elements from given array and creates new array
pub fn log10(&self) -> Array<f64>
[src]
Applies logarithm with base 10 on elements from given array and creates new array
pub fn loge(&self) -> Array<f64>
[src]
Applies natural logarithm on elements from given array and creates new array
impl<T> Array<T> where
T: Copy + Into<f64>,
[src]
T: Copy + Into<f64>,
pub fn exp(&self) -> Array<f64>
[src]
Applies exponential of elements from given array and creates new array
pub fn exp_m1(&self) -> Array<f64>
[src]
Applies exponential minus one with base 2 on elements from given array and creates new array
pub fn exp2(&self) -> Array<f64>
[src]
Applies exponential of 2 with base 10 on elements from given array and creates new array
Trait Implementations
impl<T: Copy> Clone for Array<T>
[src]
fn clone(&self) -> Array<T>
[src]
Clones array object
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug + Copy> Debug for Array<T>
[src]
impl<'_, T> Div<&'_ Array<T>> for &'_ Array<T> where
T: Copy + Div<Output = T>,
[src]
T: Copy + Div<Output = T>,
type Output = Array<T>
The resulting type after applying the /
operator.
fn div(self, other: &Array<T>) -> Array<T>
[src]
impl<'_, T> Add<&'_ Array<T>> for &'_ Array<T> where
T: Copy + Add<Output = T>,
[src]
T: Copy + Add<Output = T>,
type Output = Array<T>
The resulting type after applying the +
operator.
fn add(self, other: &Array<T>) -> Array<T>
[src]
impl<'_, T> Sub<&'_ Array<T>> for &'_ Array<T> where
T: Copy + Sub<Output = T>,
[src]
T: Copy + Sub<Output = T>,
type Output = Array<T>
The resulting type after applying the -
operator.
fn sub(self, other: &Array<T>) -> Array<T>
[src]
impl<'_, T> Mul<&'_ Array<T>> for &'_ Array<T> where
T: Copy + Mul<Output = T>,
[src]
T: Copy + Mul<Output = T>,
type Output = Array<T>
The resulting type after applying the *
operator.
fn mul(self, other: &Array<T>) -> Array<T>
[src]
impl<T> Neg for Array<T> where
T: Copy + Neg<Output = T>,
[src]
T: Copy + Neg<Output = T>,
type Output = Array<T>
The resulting type after applying the -
operator.
fn neg(self) -> Array<T>
[src]
impl<'_, T> AddAssign<&'_ Array<T>> for &'_ Array<T> where
T: Copy + Add<Output = T>,
[src]
T: Copy + Add<Output = T>,
fn add_assign(&mut self, other: &Array<T>)
[src]
impl<'_, T> SubAssign<&'_ Array<T>> for &'_ Array<T> where
T: Copy + Sub<Output = T>,
[src]
T: Copy + Sub<Output = T>,
fn sub_assign(&mut self, other: &Array<T>)
[src]
impl<'_, T> MulAssign<&'_ Array<T>> for &'_ Array<T> where
T: Copy + Mul<Output = T>,
[src]
T: Copy + Mul<Output = T>,
fn mul_assign(&mut self, other: &Array<T>)
[src]
impl<'_, T> DivAssign<&'_ Array<T>> for &'_ Array<T> where
T: Copy + Div<Output = T>,
[src]
T: Copy + Div<Output = T>,
fn div_assign(&mut self, other: &Array<T>)
[src]
Auto Trait Implementations
impl<T> !Sync for Array<T>
impl<T> !Send for Array<T>
impl<T> Unpin for Array<T>
impl<T> !RefUnwindSafe for Array<T>
impl<T> !UnwindSafe for Array<T>
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,