Trait ArrayTrigonometric

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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

may returns ArrayError

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)));
§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: NumericOps> ArrayTrigonometric<N> for Result<Array<N>, ArrayError>

Source§

fn sin(&self) -> Self

Source§

fn cos(&self) -> Self

Source§

fn tan(&self) -> Self

Source§

fn asin(&self) -> Self

Source§

fn acos(&self) -> Self

Source§

fn atan(&self) -> Self

Source§

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

Source§

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

Source§

fn degrees(&self) -> Self

Source§

fn rad2deg(&self) -> Self

Source§

fn radians(&self) -> Self

Source§

fn deg2rad(&self) -> Self

Source§

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

Implementors§