]> git.proxmox.com Git - rustc.git/blob - vendor/packed_simd_2/src/api/math/float/sin.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / vendor / packed_simd_2 / src / api / math / float / sin.rs
1 //! Implements vertical (lane-wise) floating-point `sin`.
2
3 macro_rules! impl_math_float_sin {
4 ([$elem_ty:ident; $elem_count:expr]: $id:ident | $test_tt:tt) => {
5 impl $id {
6 /// Sine.
7 #[inline]
8 pub fn sin(self) -> Self {
9 use crate::codegen::math::float::sin::Sin;
10 Sin::sin(self)
11 }
12
13 /// Sine of `self * PI`.
14 #[inline]
15 pub fn sin_pi(self) -> Self {
16 use crate::codegen::math::float::sin_pi::SinPi;
17 SinPi::sin_pi(self)
18 }
19
20 /// Sine and cosine of `self * PI`.
21 #[inline]
22 pub fn sin_cos_pi(self) -> (Self, Self) {
23 use crate::codegen::math::float::sin_cos_pi::SinCosPi;
24 SinCosPi::sin_cos_pi(self)
25 }
26 }
27
28 test_if!{
29 $test_tt:
30 paste::item! {
31 pub mod [<$id _math_sin>] {
32 use super::*;
33 #[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
34 fn sin() {
35 use crate::$elem_ty::consts::PI;
36 let z = $id::splat(0 as $elem_ty);
37 let p = $id::splat(PI as $elem_ty);
38 let ph = $id::splat(PI as $elem_ty / 2.);
39 let o_r = $id::splat((PI as $elem_ty / 2.).sin());
40 let z_r = $id::splat((PI as $elem_ty).sin());
41
42 assert_eq!(z, z.sin());
43 assert_eq!(o_r, ph.sin());
44 assert_eq!(z_r, p.sin());
45 }
46 }
47 }
48 }
49 };
50 }