Trait ArrayFloating

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

Source§

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

Source§

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

Source§

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

Source§

fn ldexp(&self, other: &Array<i32>) -> Self

Source§

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

Source§

fn spacing(&self) -> Self

Implementors§