pub trait ArraySumProdDiff<N: NumericOps>{
// 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 prod(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>
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
Sourcefn sum(&self, axis: Option<isize>) -> Result<Array<N>, ArrayError>
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
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));
§Errors
may returns ArrayError
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));
§Errors
may returns ArrayError
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));
§Errors
may returns ArrayError
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));
§Errors
may returns ArrayError
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));
§Errors
may returns ArrayError
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));
§Errors
may returns ArrayError
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));
§Errors
may returns ArrayError
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));
§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.