pub trait ArrayTrigonometric<N: NumericOps>where
    Self: Sized + Clone,{
Show 13 methods // Required methods fn sin(&self) -> Result<Array<N>, ArrayError>; fn cos(&self) -> Result<Array<N>, ArrayError>; fn tan(&self) -> Result<Array<N>, ArrayError>; fn asin(&self) -> Result<Array<N>, ArrayError>; fn acos(&self) -> Result<Array<N>, ArrayError>; fn atan(&self) -> Result<Array<N>, ArrayError>; fn atan2(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>; fn hypot(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>; fn degrees(&self) -> Result<Array<N>, ArrayError>; fn rad2deg(&self) -> Result<Array<N>, ArrayError>; fn radians(&self) -> Result<Array<N>, ArrayError>; fn deg2rad(&self) -> Result<Array<N>, ArrayError>; fn unwrap_phase( &self, discont: Option<Array<f64>>, axis: Option<isize>, period: Option<Array<f64>> ) -> Result<Array<N>, ArrayError>;
}
Expand description

ArrayTrait - Array Trigonometric functions

Required Methods§

source

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

Compute the sine of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![-1., 0., 1.]).unwrap();
assert_eq!(Array::flat(vec![-0.8414709848078965, 0., 0.8414709848078965]), arr.sin());
source

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

Compute the cosine of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![-1., 0., 1.]).unwrap();
assert_eq!(Array::flat(vec![0.5403023058681398, 1., 0.5403023058681398]), arr.cos());
source

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

Compute the tangent of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![-1., 0., 1.]).unwrap();
assert_eq!(Array::flat(vec![-1.5574077246549023, 0., 1.5574077246549023]), arr.tan());
source

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

Compute the inverse sine of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![-1., 0., 1.]).unwrap();
assert_eq!(Array::flat(vec![-std::f64::consts::FRAC_PI_2, 0., std::f64::consts::FRAC_PI_2]), arr.asin());
source

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

Compute the inverse cosine of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![-1., 0., 1.]).unwrap();
assert_eq!(Array::flat(vec![std::f64::consts::PI, std::f64::consts::FRAC_PI_2, 0.]), arr.acos());
source

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

Compute the inverse tangent of array elements

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![-1., 0., 1.]).unwrap();
assert_eq!(Array::flat(vec![-std::f64::consts::FRAC_PI_4, 0., std::f64::consts::FRAC_PI_4]), arr.atan());
source

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

Compute the inverse tangent of x1/x2 choosing the quadrant correctly

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

let arr = Array::flat(vec![-1., 0., 1.]).unwrap();
let other = Array::flat(vec![2., 4., 6.]).unwrap();
assert_eq!(Array::flat(vec![-0.4636476090008061,0., 0.16514867741462683]), arr.atan2(&other));
source

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

Given the “legs” of a right triangle, return its hypotenuse

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

let arr = Array::full(vec![3, 3], 3).unwrap();
let other = Array::full(vec![3, 3], 4).unwrap();
assert_eq!(Array::full(vec![3, 3], 5), arr.hypot(&other));
source

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

Convert angles from radians to degrees

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![std::f64::consts::FRAC_PI_6, std::f64::consts::FRAC_PI_4, std::f64::consts::FRAC_PI_3, std::f64::consts::FRAC_PI_2]).unwrap();
let expected = Array::flat(vec![30., 45., 60., 90.]);
assert_eq!(format!("{expected:.8?}"), format!("{:.8?}", arr.degrees()));
source

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

Convert angles from radians to degrees. alias on degrees

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![std::f64::consts::FRAC_PI_6, std::f64::consts::FRAC_PI_4, std::f64::consts::FRAC_PI_3, std::f64::consts::FRAC_PI_2]).unwrap();
let expected = Array::flat(vec![30., 45., 60., 90.]);
assert_eq!(format!("{expected:.8?}"), format!("{:.8?}", arr.rad2deg()));
source

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

Convert angles from degrees to radians

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![30., 45., 60., 90.]).unwrap();
let expected = Array::flat(vec![std::f64::consts::FRAC_PI_6, std::f64::consts::FRAC_PI_4, std::f64::consts::FRAC_PI_3, std::f64::consts::FRAC_PI_2]);
assert_eq!(format!("{expected:.8?}"), format!("{:.8?}", arr.radians()));
source

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

Convert angles from degrees to radians. alias on radians

Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![30., 45., 60., 90.]).unwrap();
let expected = Array::flat(vec![std::f64::consts::FRAC_PI_6, std::f64::consts::FRAC_PI_4, std::f64::consts::FRAC_PI_3, std::f64::consts::FRAC_PI_2]);
assert_eq!(format!("{expected:.8?}"), format!("{:.8?}", arr.deg2rad()));
source

fn unwrap_phase( &self, discont: Option<Array<f64>>, axis: Option<isize>, period: Option<Array<f64>> ) -> Result<Array<N>, ArrayError>

Unwrap by taking the complement of large deltas with respect to the period

Arguments
  • discont - Maximum discontinuity between values, default is period/2. Values below period/2 are treated as if they were period/2.
  • axis - Axis along which unwrap will operate, default is the last axis.
  • period - Size of the range over which the input wraps, default is 2 pi.
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec![0.5, 1.5, 3.2, 6.8, 5.9]).unwrap();
let expected = Array::flat(vec![0.5, 1.5, 3.2, 0.51681469, -0.38318531]);
assert_eq!(format!("{expected:.8?}"), format!("{:.8?}", arr.unwrap_phase(None, None, None)));

Implementations on Foreign Types§

source§

impl<N: NumericOps> ArrayTrigonometric<N> for Result<Array<N>, ArrayError>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

fn unwrap_phase( &self, discont: Option<Array<f64>>, axis: Option<isize>, period: Option<Array<f64>> ) -> Result<Array<N>, ArrayError>

Implementors§