File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,20 @@ macro_rules! impl_float_vector {
4545 Self :: splat( 1.0 ) / self
4646 }
4747
48+ /// Calculate the sine of the angle
49+ #[ inline]
50+ pub fn sin( self ) -> Self {
51+ let x = Self :: splat( 1.0 / ( 3.14159265358 * 2.0 ) ) * self ;
52+ let x = x - x. floor( ) - 0.5 ;
53+ Self :: splat( 12.268859941019306 )
54+ . mul_add( x * x, Self :: splat( -41.216241051002875 ) )
55+ . mul_add( x * x, Self :: splat( 76.58672703334098 ) )
56+ . mul_add( x * x, Self :: splat( -81.59746095374902 ) )
57+ . mul_add( x * x, Self :: splat( 41.34151143437585 ) )
58+ . mul_add( x * x, Self :: splat( -6.283184525811273 ) )
59+ * x
60+ }
61+
4862 /// Converts each lane from radians to degrees.
4963 #[ inline]
5064 #[ must_use = "method returns a new vector and does not mutate the original value" ]
Original file line number Diff line number Diff line change @@ -397,6 +397,14 @@ macro_rules! impl_float_tests {
397397 )
398398 }
399399
400+ fn sin<const LANES : usize >( ) {
401+ test_helpers:: test_unary_elementwise(
402+ & Vector :: <LANES >:: sin,
403+ & Scalar :: sin,
404+ & |_| true ,
405+ )
406+ }
407+
400408 fn to_degrees<const LANES : usize >( ) {
401409 test_helpers:: test_unary_elementwise(
402410 & Vector :: <LANES >:: to_degrees,
You can’t perform that action at this time.
0 commit comments