pub trait ArraySumProdDiff<N: NumericOps>where
    Self: Sized + Clone,{
    // Required methods
    fn prod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>;
    fn sum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>;
    fn nanprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>;
    fn nansum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>;
    fn cumprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>;
    fn cumsum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>;
    fn nancumprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>;
    fn nancumsum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>;
    fn diff(
        &self,
        n: usize,
        axis: Option<isize>,
        prepend: Option<Array<N>>,
        append: Option<Array<N>>
    ) -> Result<Array<N>, ArrayError>;
    fn ediff1d(
        &self,
        to_end: Option<Array<N>>,
        to_begin: Option<Array<N>>
    ) -> Result<Array<N>, ArrayError>;
}
Expand description

ArrayTrait - Array Sum, Product, Diff functions

Required Methods§

source

fn prod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

Multiplication of array elements

Arguments
  • axis - the axis along which to execute the function. optional. if negative, counts from last to first axis. if None, array is raveled
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, 2, 3, 4]);
assert_eq!(Array::single(24), arr.prod(None));
source

fn sum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

Sum of array elements

Arguments
  • axis - the axis along which to execute the function. optional. if negative, counts from last to first axis. if None, array is raveled
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, 2, 3, 4]);
assert_eq!(Array::single(10), arr.sum(None));
source

fn nanprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

Sum of array elements treating NaN as one

Arguments
  • axis - the axis along which to execute the function. optional. if negative, counts from last to first axis. if None, array is raveled
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., 3., 4., f64::NAN]);
assert_eq!(Array::single(24.), arr.nanprod(None));
source

fn nansum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

Sum of array elements treating NaN as zero

Arguments
  • axis - the axis along which to execute the function. optional. if negative, counts from last to first axis. if None, array is raveled
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., 3., 4., f64::NAN]);
assert_eq!(Array::single(10.), arr.nansum(None));
source

fn cumprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

Cumulative product of array elements

Arguments
  • axis - the axis along which to execute the function. optional. if negative, counts from last to first axis. if None, array is raveled
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, 2, 3, 4]);
assert_eq!(Array::flat(vec![1, 2, 6, 24]), arr.cumprod(None));
source

fn cumsum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

Cumulative sum of array elements

Arguments
  • axis - the axis along which to execute the function. optional. if negative, counts from last to first axis. if None, array is raveled
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, 2, 3, 4]);
assert_eq!(Array::flat(vec![1, 3, 6, 10]), arr.cumsum(None));
source

fn nancumprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

Cumulative product of array elements

Arguments
  • axis - the axis along which to execute the function. optional. if negative, counts from last to first axis. if None, array is raveled
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., 3., 4., f64::NAN]);
assert_eq!(Array::flat(vec![1., 2., 6., 24., 24.]), arr.nancumprod(None));
source

fn nancumsum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

Cumulative sum of array elements

Arguments
  • axis - the axis along which to execute the function. optional. if negative, counts from last to first axis. if None, array is raveled
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., 3., 4., f64::NAN]);
assert_eq!(Array::flat(vec![1., 3., 6., 10., 10.]), arr.nancumsum(None));
source

fn diff( &self, n: usize, axis: Option<isize>, prepend: Option<Array<N>>, append: Option<Array<N>> ) -> Result<Array<N>, ArrayError>

The differences between consecutive elements of an array

Arguments
  • n - number of times values are differenced
  • axis - the axis along which to execute the function. optional. defaults to last axis
  • append - number(s) to append at the end along axis prior to performing the difference
  • prepend - number(s) to append at the beginning along axis prior to performing the difference
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., 4., 4., 7.]);
assert_eq!(Array::flat(vec![1., 2., 0., 3.]), arr.diff(1, None, None, None));
source

fn ediff1d( &self, to_end: Option<Array<N>>, to_begin: Option<Array<N>> ) -> Result<Array<N>, ArrayError>

The differences between consecutive elements of an array

Arguments
  • to_end - number(s) to append at the end of the returned differences
  • to_begin - number(s) to append at the beginning of the returned differences
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., 4., 4., 7.]);
assert_eq!(Array::flat(vec![1., 2., 0., 3.]), arr.ediff1d(None, None));

Implementations on Foreign Types§

source§

impl<N: NumericOps> ArraySumProdDiff<N> for Result<Array<N>, ArrayError>

source§

fn prod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

source§

fn sum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

source§

fn nanprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

source§

fn nansum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

source§

fn cumprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

source§

fn cumsum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

source§

fn nancumprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

source§

fn nancumsum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>

source§

fn diff( &self, n: usize, axis: Option<isize>, prepend: Option<Array<N>>, append: Option<Array<N>> ) -> Result<Array<N>, ArrayError>

source§

fn ediff1d( &self, to_end: Option<Array<N>>, to_begin: Option<Array<N>> ) -> Result<Array<N>, ArrayError>

Implementors§