Trait arr_rs::math::operations::sum_prod_diff::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§
sourcefn nanprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>
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));
sourcefn nansum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>
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));
sourcefn cumprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>
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));
sourcefn cumsum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>
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));
sourcefn nancumprod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>
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));
sourcefn nancumsum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>
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));
sourcefn diff(
&self,
n: usize,
axis: Option<isize>,
prepend: Option<Array<N>>,
append: Option<Array<N>>
) -> Result<Array<N>, ArrayError>
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 differencedaxis
- the axis along which to execute the function. optional. defaults to last axisappend
- number(s) to append at the end along axis prior to performing the differenceprepend
- 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));
sourcefn ediff1d(
&self,
to_end: Option<Array<N>>,
to_begin: Option<Array<N>>
) -> Result<Array<N>, ArrayError>
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 differencesto_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));