use crate::{
- f16::F16,
- prim::{PrimFloat, PrimSInt, PrimUInt},
+ prim::{PrimFloat, PrimUInt},
traits::{Compare, Context, ConvertFrom, ConvertTo, Float, Make, Select},
};
) -> (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();
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::*;