Trait ArraySumProdDiff

Source
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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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));
§Errors

may returns ArrayError

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.

Implementations on Foreign Types§

Source§

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

Source§

fn prod(&self, axis: Option<isize>) -> Self

Source§

fn sum(&self, axis: Option<isize>) -> Self

Source§

fn nanprod(&self, axis: Option<isize>) -> Self

Source§

fn nansum(&self, axis: Option<isize>) -> Self

Source§

fn cumprod(&self, axis: Option<isize>) -> Self

Source§

fn cumsum(&self, axis: Option<isize>) -> Self

Source§

fn nancumprod(&self, axis: Option<isize>) -> Self

Source§

fn nancumsum(&self, axis: Option<isize>) -> Self

Source§

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

Source§

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

Implementors§