pub trait ArrayTrigonometric<N: NumericOps>{
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§
Sourcefn sin(&self) -> Result<Array<N>, ArrayError>
fn sin(&self) -> Result<Array<N>, ArrayError>
Sourcefn cos(&self) -> Result<Array<N>, ArrayError>
fn cos(&self) -> Result<Array<N>, ArrayError>
Sourcefn tan(&self) -> Result<Array<N>, ArrayError>
fn tan(&self) -> Result<Array<N>, ArrayError>
Sourcefn asin(&self) -> Result<Array<N>, ArrayError>
fn asin(&self) -> Result<Array<N>, ArrayError>
Sourcefn acos(&self) -> Result<Array<N>, ArrayError>
fn acos(&self) -> Result<Array<N>, ArrayError>
Sourcefn atan(&self) -> Result<Array<N>, ArrayError>
fn atan(&self) -> Result<Array<N>, ArrayError>
Sourcefn atan2(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>
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
Sourcefn hypot(&self, other: &Array<N>) -> Result<Array<N>, ArrayError>
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
Sourcefn degrees(&self) -> Result<Array<N>, ArrayError>
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
Sourcefn rad2deg(&self) -> Result<Array<N>, ArrayError>
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
Sourcefn radians(&self) -> Result<Array<N>, ArrayError>
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
Sourcefn deg2rad(&self) -> Result<Array<N>, ArrayError>
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
Sourcefn unwrap_phase(
&self,
discont: Option<Array<f64>>,
axis: Option<isize>,
period: Option<Array<f64>>,
) -> Result<Array<N>, ArrayError>
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.