pub trait ArrayFloating<N: Floating>where
    Self: Sized + Clone,{
    // Required methods
    fn signbit(&self) -> Result<Array<bool>, ArrayError>;
    fn copysign(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>;
    fn frexp(&self) -> Result<(Array<N>, Array<i32>), ArrayError>;
    fn ldexp(&self, other: &Array<i32>) -> Result<Array<N>, ArrayError>;
    fn nextafter(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>;
    fn spacing(&self) -> Result<Array<N>, ArrayError>;
}
Expand description

ArrayTrait - Array Floating functions

Required Methods§

source

fn signbit(&self) -> Result<Array<bool>, ArrayError>

Returns element-wise True where signbit is set (less than zero)

Examples
use arr_rs::prelude::*;

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

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

Change the sign of x1 to that of x2, element-wise

Arguments
  • other - array to copy sign from
Examples
use arr_rs::prelude::*;

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

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

Decompose the elements of x into man and twos exp

Examples
use arr_rs::prelude::*;

let arr = Array::arange(0., 8., None);
let result = arr.frexp().unwrap();
assert_eq!(Array::flat(vec![0., 0.5, 0.5, 0.75, 0.5, 0.625, 0.75, 0.875, 0.5]).unwrap(), result.0);
assert_eq!(Array::flat(vec![0, 1, 2, 2, 3, 3, 3, 3, 4]).unwrap(), result.1);
source

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

Returns x1 * 2**x2, element-wise. Inverse of frexp

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![0., 0.5, 0.5, 0.75, 0.5, 0.625, 0.75, 0.875, 0.5]);
let other = Array::flat(vec![0, 1, 2, 2, 3, 3, 3, 3, 4]);
assert_eq!(Array::arange(0., 8., None), arr.ldexp(&other.unwrap()));
source

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

Return the next floating-point value after x1 towards x2, element-wise

Examples
use arr_rs::prelude::*;

let expected = Array::flat(vec![1. + f64::EPSILON, 2. - f64::EPSILON]);
assert_eq!(expected, Array::flat(vec![1., 2.]).nextafter(&Array::flat(vec![2., 1.]).unwrap()));
source

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

Return the distance between x and the nearest adjacent number

Examples
use arr_rs::prelude::*;

assert_eq!(Array::flat(vec![f64::EPSILON, f64::EPSILON * 2.]), Array::flat(vec![1., 2.]).spacing());

Implementations on Foreign Types§

source§

impl<N: Floating> ArrayFloating<N> for Result<Array<N>, ArrayError>

source§

fn signbit(&self) -> Result<Array<bool>, ArrayError>

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§