remove note to convert to sin_cos_tau instead sin_cos_pi
[vector-math.git] / src / algorithms / trig_pi.rs
index 1dca80a33522bc333f85e89909b96e37b9577ab3..5be0ad65b017a389823488c1050a1b22eeb51293 100644 (file)
@@ -158,8 +158,7 @@ pub fn sin_cos_pi_impl<
 ) -> (VecF, VecF) {
     let two_f: VecF = ctx.make(2.0.to());
     let one_half: VecF = ctx.make(0.5.to());
-    let max_contiguous_integer: VecF =
-        ctx.make((PrimU::cvt_from(1) << (PrimF::MANTISSA_FIELD_WIDTH + 1.to())).to());
+    let max_contiguous_integer: VecF = ctx.make(PrimF::max_contiguous_integer());
     // if `x` is finite and bigger than `max_contiguous_integer`, then x is an even integer
     let in_range = x.abs().lt(max_contiguous_integer); // use `lt` so nans are counted as out-of-range
     let is_finite = x.is_finite();
@@ -250,6 +249,27 @@ pub fn cos_pi_f64<Ctx: Context>(ctx: Ctx, x: Ctx::VecF64) -> Ctx::VecF64 {
     sin_cos_pi_f64(ctx, x).1
 }
 
+/// computes `tan(pi * x)`
+/// error inherited from `sin_pi / cos_pi`
+pub fn tan_pi_f16<Ctx: Context>(ctx: Ctx, x: Ctx::VecF16) -> Ctx::VecF16 {
+    let (sin, cos) = sin_cos_pi_f16(ctx, x);
+    sin / cos
+}
+
+/// computes `tan(pi * x)`
+/// error inherited from `sin_pi / cos_pi`
+pub fn tan_pi_f32<Ctx: Context>(ctx: Ctx, x: Ctx::VecF32) -> Ctx::VecF32 {
+    let (sin, cos) = sin_cos_pi_f32(ctx, x);
+    sin / cos
+}
+
+/// computes `tan(pi * x)`
+/// error inherited from `sin_pi / cos_pi`
+pub fn tan_pi_f64<Ctx: Context>(ctx: Ctx, x: Ctx::VecF64) -> Ctx::VecF64 {
+    let (sin, cos) = sin_cos_pi_f64(ctx, x);
+    sin / cos
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;