Trait ArrayMathMisc

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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());
§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: Numeric> ArrayMathMisc<N> for Result<Array<N>, ArrayError>

Source§

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

Source§

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

Source§

fn sqrt(&self) -> Self

Source§

fn cbrt(&self) -> Self

Source§

fn square(&self) -> Self

Source§

fn absolute(&self) -> Self

Source§

fn abs(&self) -> Self

Source§

fn fabs(&self) -> Self

Source§

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

Source§

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

Source§

fn nan_to_num(&self) -> Self

Implementors§