diff --git a/build.rs b/build.rs index 4d739a1..4da50a8 100644 --- a/build.rs +++ b/build.rs @@ -41,18 +41,18 @@ mod musl_reference_tests { "rem_pio2.rs", "rem_pio2_large.rs", "rem_pio2f.rs", - "remquo.rs", // more than 1 result - "remquof.rs", // more than 1 result + "remquo.rs", // more than 1 result + "remquof.rs", // more than 1 result "lgamma_r.rs", // more than 1 result "lgammaf_r.rs", // more than 1 result - "frexp.rs", // more than 1 result - "frexpf.rs", // more than 1 result - "sincos.rs", // more than 1 result - "sincosf.rs", // more than 1 result - "modf.rs", // more than 1 result - "modff.rs", // more than 1 result - "jn.rs", // passed, but very slow - "jnf.rs", // passed, but very slow + "frexp.rs", // more than 1 result + "frexpf.rs", // more than 1 result + "sincos.rs", // more than 1 result + "sincosf.rs", // more than 1 result + "modf.rs", // more than 1 result + "modff.rs", // more than 1 result + "jn.rs", // passed, but very slow + "jnf.rs", // passed, but very slow ]; struct Function { diff --git a/src/lib.rs b/src/lib.rs index 5e94541..0d0f615 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,13 +119,7 @@ pub trait F32Ext: private::Sealed + Sized { fn atan2(self, other: Self) -> Self; - #[inline] - fn sin_cos(self) -> (Self, Self) - where - Self: Copy, - { - (self.sin(), self.cos()) - } + fn sin_cos(self) -> (Self, Self); fn exp_m1(self) -> Self; @@ -289,6 +283,11 @@ impl F32Ext for f32 { atan2f(self, other) } + #[inline] + fn sin_cos(self) -> (Self, Self) { + sincosf(self) + } + #[inline] fn exp_m1(self) -> Self { expm1f(self) @@ -316,24 +315,17 @@ impl F32Ext for f32 { #[inline] fn asinh(self) -> Self { - if self == f32::NEG_INFINITY { - f32::NEG_INFINITY - } else { - (self + ((self * self) + 1.0).sqrt()).ln() - } + asinhf(self) } #[inline] fn acosh(self) -> Self { - match self { - x if x < 1.0 => f32::NAN, - x => (x + ((x * x) - 1.0).sqrt()).ln(), - } + acoshf(self) } #[inline] fn atanh(self) -> Self { - 0.5 * ((2.0 * self) / (1.0 - self)).ln_1p() + atanhf(self) } } @@ -401,13 +393,7 @@ pub trait F64Ext: private::Sealed + Sized { fn atan2(self, other: Self) -> Self; - #[inline] - fn sin_cos(self) -> (Self, Self) - where - Self: Copy, - { - (self.sin(), self.cos()) - } + fn sin_cos(self) -> (Self, Self); fn exp_m1(self) -> Self; @@ -571,6 +557,11 @@ impl F64Ext for f64 { atan2(self, other) } + #[inline] + fn sin_cos(self) -> (Self, Self) { + sincos(self) + } + #[inline] fn exp_m1(self) -> Self { expm1(self) @@ -598,24 +589,17 @@ impl F64Ext for f64 { #[inline] fn asinh(self) -> Self { - if self == f64::NEG_INFINITY { - f64::NEG_INFINITY - } else { - (self + ((self * self) + 1.0).sqrt()).ln() - } + asinh(self) } #[inline] fn acosh(self) -> Self { - match self { - x if x < 1.0 => f64::NAN, - x => (x + ((x * x) - 1.0).sqrt()).ln(), - } + acosh(self) } #[inline] fn atanh(self) -> Self { - 0.5 * ((2.0 * self) / (1.0 - self)).ln_1p() + atanh(self) } }