pub trait ArrayMathMisc<N: Numeric>where
    Self: Sized + Clone,{
    // Required methods
    fn convolve(
        &self,
        other: &Array<N>,
        mode: Option<impl ConvolveModeType>
    ) -> Result<Array<N>, ArrayError>;
    fn clip(
        &self,
        a_min: Option<Array<N>>,
        a_max: Option<Array<N>>
    ) -> Result<Array<N>, ArrayError>;
    fn sqrt(&self) -> Result<Array<N>, ArrayError>;
    fn cbrt(&self) -> Result<Array<N>, ArrayError>;
    fn square(&self) -> Result<Array<N>, ArrayError>;
    fn absolute(&self) -> Result<Array<N>, ArrayError>;
    fn abs(&self) -> Result<Array<N>, ArrayError>;
    fn fabs(&self) -> Result<Array<N>, ArrayError>;
    fn sign(&self) -> Result<Array<isize>, ArrayError>;
    fn heaviside(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>;
    fn nan_to_num(&self) -> Result<Array<N>, ArrayError>;
}
Expand description

ArrayTrait - Array Math Misc functions

Required Methods§

source

fn convolve( &self, other: &Array<N>, mode: Option<impl ConvolveModeType> ) -> Result<Array<N>, ArrayError>

Returns the discrete, linear convolution of two one-dimensional sequences arrays are flattened for computation

Arguments
  • other - array to perform the operation with
  • mode - {full, valid, same}, optional. defaults to full
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., 3.]);
let other = Array::flat(vec![0., 1., 0.5]);
assert_eq!(Array::flat(vec![0., 1., 2.5, 4., 1.5]), arr.convolve(&other.unwrap(), Some("full")));
source

fn clip( &self, a_min: Option<Array<N>>, a_max: Option<Array<N>> ) -> Result<Array<N>, ArrayError>

Clip (limit) the values in an array

Arguments
  • a_min - minimum array value
  • a_max - maximum array value
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., 3., 4.]);
let a_min = Array::single(2.).unwrap();
let a_max = Array::single(3.).unwrap();
assert_eq!(Array::flat(vec![2., 2., 3., 3.]), arr.clip(Some(a_min), Some(a_max)));
source

fn sqrt(&self) -> Result<Array<N>, ArrayError>

Computes square root of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, 4, 9, 16]);
assert_eq!(Array::flat(vec![1, 2, 3, 4]), arr.sqrt());
source

fn cbrt(&self) -> Result<Array<N>, ArrayError>

Computes cube root of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, 8, 27, 64]);
assert_eq!(Array::flat(vec![1, 2, 3, 4]), arr.cbrt());
source

fn square(&self) -> Result<Array<N>, ArrayError>

Return the element-wise square of the input

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, 2, 3, 4]);
assert_eq!(Array::flat(vec![1, 4, 9, 16]), arr.square());
source

fn absolute(&self) -> Result<Array<N>, ArrayError>

Computes absolute value of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, -2, 3, -4]);
assert_eq!(Array::flat(vec![1, 2, 3, 4]), arr.absolute());
source

fn abs(&self) -> Result<Array<N>, ArrayError>

Computes absolute value of array elements alias on absolute

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, -2, 3, -4]);
assert_eq!(Array::flat(vec![1, 2, 3, 4]), arr.abs());
source

fn fabs(&self) -> Result<Array<N>, ArrayError>

Computes absolute value of array elements alias on absolute

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, -2, 3, -4]);
assert_eq!(Array::flat(vec![1, 2, 3, 4]), arr.fabs());
source

fn sign(&self) -> Result<Array<isize>, ArrayError>

Returns an element-wise indication of the sign of a number

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1, -2, -3, 4]);
assert_eq!(Array::flat(vec![1, -1, -1, 1]), arr.sign());
source

fn heaviside(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>

Compute the Heaviside step function

Arguments
  • other - array to perform the operation with
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![-1.5, 0., 2.]);
assert_eq!(Array::flat(vec![0., 0.5, 1.]), arr.heaviside(&Array::single(0.5).unwrap()));
source

fn nan_to_num(&self) -> Result<Array<N>, ArrayError>

Replace NaN with zero and infinity with large finite numbers

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![1., 2., f64::NAN, f64::INFINITY]);
assert_eq!(Array::flat(vec![1., 2., 0., f64::MAX]), arr.nan_to_num());

Implementations on Foreign Types§

source§

impl<N: Numeric> ArrayMathMisc<N> for Result<Array<N>, ArrayError>

source§

fn convolve( &self, other: &Array<N>, mode: Option<impl ConvolveModeType> ) -> Result<Array<N>, ArrayError>

source§

fn clip( &self, a_min: Option<Array<N>>, a_max: Option<Array<N>> ) -> Result<Array<N>, ArrayError>

source§

fn sqrt(&self) -> Result<Array<N>, ArrayError>

source§

fn cbrt(&self) -> Result<Array<N>, ArrayError>

source§

fn square(&self) -> Result<Array<N>, ArrayError>

source§

fn absolute(&self) -> Result<Array<N>, ArrayError>

source§

fn abs(&self) -> Result<Array<N>, ArrayError>

source§

fn fabs(&self) -> Result<Array<N>, ArrayError>

source§

fn sign(&self) -> Result<Array<isize>, ArrayError>

source§

fn heaviside(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>

source§

fn nan_to_num(&self) -> Result<Array<N>, ArrayError>

Implementors§