pub trait ArrayFloating<N: Floating>{
// 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§
Sourcefn copysign(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>
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
Sourcefn frexp(&self) -> Result<(Array<N>, Array<i32>), ArrayError>
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
Sourcefn ldexp(&self, other: &Array<i32>) -> Result<Array<N>, ArrayError>
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
Sourcefn nextafter(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>
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
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.