diff --git a/src/math/acos.rs b/src/math/acos.rs index d5e1f6865..71789e4c1 100644 --- a/src/math/acos.rs +++ b/src/math/acos.rs @@ -49,6 +49,7 @@ const QS3: f64 = -6.88283971605453293030e-01; /* 0xBFE6066C, 0x1B8D0159 */ const QS4: f64 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn r(z: f64) -> f64 { let p: f64 = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z * (PS4 + z * PS5))))); let q: f64 = 1.0 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4))); diff --git a/src/math/acosf.rs b/src/math/acosf.rs index d0598e811..7dd16f911 100644 --- a/src/math/acosf.rs +++ b/src/math/acosf.rs @@ -23,6 +23,7 @@ const P_S2: f32 = -8.6563630030e-03; const Q_S1: f32 = -7.0662963390e-01; #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn r(z: f32) -> f32 { let p = z * (P_S0 + z * (P_S1 + z * P_S2)); let q = 1. + z * Q_S1; diff --git a/src/math/acosh.rs b/src/math/acosh.rs index ac7a5f1c6..80c3ab8a9 100644 --- a/src/math/acosh.rs +++ b/src/math/acosh.rs @@ -7,6 +7,8 @@ const LN2: f64 = 0.693147180559945309417232121458176568; /* 0x3fe62e42, 0xfefa3 /// Calculates the inverse hyperbolic cosine of `x`. /// Is defined as `log(x + sqrt(x*x-1))`. /// `x` must be a number greater than or equal to 1. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn acosh(x: f64) -> f64 { let u = x.to_bits(); let e = ((u >> 52) as usize) & 0x7ff; diff --git a/src/math/acoshf.rs b/src/math/acoshf.rs index 0879e1edb..cf9d13a3b 100644 --- a/src/math/acoshf.rs +++ b/src/math/acoshf.rs @@ -7,6 +7,8 @@ const LN2: f32 = 0.693147180559945309417232121458176568; /// Calculates the inverse hyperbolic cosine of `x`. /// Is defined as `log(x + sqrt(x*x-1))`. /// `x` must be a number greater than or equal to 1. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn acoshf(x: f32) -> f32 { let u = x.to_bits(); let a = u & 0x7fffffff; diff --git a/src/math/asin.rs b/src/math/asin.rs index 774475e51..f35c9992a 100644 --- a/src/math/asin.rs +++ b/src/math/asin.rs @@ -56,6 +56,7 @@ const Q_S3: f64 = -6.88283971605453293030e-01; /* 0xBFE6066C, 0x1B8D0159 */ const Q_S4: f64 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn comp_r(z: f64) -> f64 { let p = z * (P_S0 + z * (P_S1 + z * (P_S2 + z * (P_S3 + z * (P_S4 + z * P_S5))))); let q = 1.0 + z * (Q_S1 + z * (Q_S2 + z * (Q_S3 + z * Q_S4))); diff --git a/src/math/asinf.rs b/src/math/asinf.rs index ce0f4a997..e979eb95b 100644 --- a/src/math/asinf.rs +++ b/src/math/asinf.rs @@ -25,6 +25,7 @@ const P_S2: f32 = -8.6563630030e-03; const Q_S1: f32 = -7.0662963390e-01; #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn r(z: f32) -> f32 { let p = z * (P_S0 + z * (P_S1 + z * P_S2)); let q = 1. + z * Q_S1; diff --git a/src/math/asinh.rs b/src/math/asinh.rs index 14295357a..0fc4ebf91 100644 --- a/src/math/asinh.rs +++ b/src/math/asinh.rs @@ -7,6 +7,8 @@ const LN2: f64 = 0.693147180559945309417232121458176568; /* 0x3fe62e42, 0xfefa3 /// /// Calculates the inverse hyperbolic sine of `x`. /// Is defined as `sgn(x)*log(|x|+sqrt(x*x+1))`. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn asinh(mut x: f64) -> f64 { let mut u = x.to_bits(); let e = ((u >> 52) as usize) & 0x7ff; diff --git a/src/math/asinhf.rs b/src/math/asinhf.rs index e22a29132..c71728887 100644 --- a/src/math/asinhf.rs +++ b/src/math/asinhf.rs @@ -7,6 +7,8 @@ const LN2: f32 = 0.693147180559945309417232121458176568; /// /// Calculates the inverse hyperbolic sine of `x`. /// Is defined as `sgn(x)*log(|x|+sqrt(x*x+1))`. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn asinhf(mut x: f32) -> f32 { let u = x.to_bits(); let i = u & 0x7fffffff; diff --git a/src/math/atanh.rs b/src/math/atanh.rs index 79a989c42..01a3ace3c 100644 --- a/src/math/atanh.rs +++ b/src/math/atanh.rs @@ -5,6 +5,8 @@ use super::log1p; /// /// Calculates the inverse hyperbolic tangent of `x`. /// Is defined as `log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2`. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn atanh(x: f64) -> f64 { let u = x.to_bits(); let e = ((u >> 52) as usize) & 0x7ff; diff --git a/src/math/atanhf.rs b/src/math/atanhf.rs index 7b2f34d97..f8ac4291f 100644 --- a/src/math/atanhf.rs +++ b/src/math/atanhf.rs @@ -5,6 +5,8 @@ use super::log1pf; /// /// Calculates the inverse hyperbolic tangent of `x`. /// Is defined as `log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2`. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn atanhf(mut x: f32) -> f32 { let mut u = x.to_bits(); let sign = (u >> 31) != 0; diff --git a/src/math/copysign.rs b/src/math/copysign.rs index 1527fb6ea..57408048e 100644 --- a/src/math/copysign.rs +++ b/src/math/copysign.rs @@ -2,6 +2,8 @@ /// /// Constructs a number with the magnitude (absolute value) of its /// first argument, `x`, and the sign of its second argument, `y`. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn copysign(x: f64, y: f64) -> f64 { let mut ux = x.to_bits(); let uy = y.to_bits(); diff --git a/src/math/copysignf.rs b/src/math/copysignf.rs index 35148561a..687862285 100644 --- a/src/math/copysignf.rs +++ b/src/math/copysignf.rs @@ -2,6 +2,8 @@ /// /// Constructs a number with the magnitude (absolute value) of its /// first argument, `x`, and the sign of its second argument, `y`. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn copysignf(x: f32, y: f32) -> f32 { let mut ux = x.to_bits(); let uy = y.to_bits(); diff --git a/src/math/erf.rs b/src/math/erf.rs index a2c617d34..6d764e8ef 100644 --- a/src/math/erf.rs +++ b/src/math/erf.rs @@ -172,6 +172,7 @@ const SB5: f64 = 2.55305040643316442583e+03; /* 0x40A3F219, 0xCEDF3BE6 */ const SB6: f64 = 4.74528541206955367215e+02; /* 0x407DA874, 0xE79FE763 */ const SB7: f64 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */ +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn erfc1(x: f64) -> f64 { let s: f64; let p: f64; @@ -184,6 +185,7 @@ fn erfc1(x: f64) -> f64 { 1.0 - ERX - p / q } +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn erfc2(ix: u32, mut x: f64) -> f64 { let s: f64; let r: f64; @@ -219,6 +221,8 @@ fn erfc2(ix: u32, mut x: f64) -> f64 { /// Calculates an approximation to the “error function”, which estimates /// the probability that an observation will fall within x standard /// deviations of the mean (assuming a normal distribution). +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn erf(x: f64) -> f64 { let r: f64; let s: f64; @@ -268,6 +272,8 @@ pub fn erf(x: f64) -> f64 { /// Is `1 - erf(x)`. Is computed directly, so that you can use it to avoid /// the loss of precision that would result from subtracting /// large probabilities (on large `x`) from 1. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn erfc(x: f64) -> f64 { let r: f64; let s: f64; diff --git a/src/math/erff.rs b/src/math/erff.rs index 384052293..9103b3e82 100644 --- a/src/math/erff.rs +++ b/src/math/erff.rs @@ -83,6 +83,7 @@ const SB5: f32 = 2.5530502930e+03; /* 0x451f90ce */ const SB6: f32 = 4.7452853394e+02; /* 0x43ed43a7 */ const SB7: f32 = -2.2440952301e+01; /* 0xc1b38712 */ +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn erfc1(x: f32) -> f32 { let s: f32; let p: f32; @@ -94,6 +95,7 @@ fn erfc1(x: f32) -> f32 { return 1.0 - ERX - p / q; } +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn erfc2(mut ix: u32, mut x: f32) -> f32 { let s: f32; let r: f32; @@ -130,6 +132,8 @@ fn erfc2(mut ix: u32, mut x: f32) -> f32 { /// Calculates an approximation to the “error function”, which estimates /// the probability that an observation will fall within x standard /// deviations of the mean (assuming a normal distribution). +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn erff(x: f32) -> f32 { let r: f32; let s: f32; @@ -179,6 +183,8 @@ pub fn erff(x: f32) -> f32 { /// Is `1 - erf(x)`. Is computed directly, so that you can use it to avoid /// the loss of precision that would result from subtracting /// large probabilities (on large `x`) from 1. +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn erfcf(x: f32) -> f32 { let r: f32; let s: f32; diff --git a/src/math/exp10.rs b/src/math/exp10.rs index 9537f76f1..4b73fa083 100644 --- a/src/math/exp10.rs +++ b/src/math/exp10.rs @@ -6,6 +6,8 @@ const P10: &[f64] = &[ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, ]; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn exp10(x: f64) -> f64 { let (mut y, n) = modf(x); let u: u64 = n.to_bits(); diff --git a/src/math/exp10f.rs b/src/math/exp10f.rs index d45fff36e..5b3533571 100644 --- a/src/math/exp10f.rs +++ b/src/math/exp10f.rs @@ -6,6 +6,8 @@ const P10: &[f32] = &[ 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, ]; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn exp10f(x: f32) -> f32 { let (mut y, n) = modff(x); let u = n.to_bits(); diff --git a/src/math/fma.rs b/src/math/fma.rs index 07d90f8b7..d1ddca367 100644 --- a/src/math/fma.rs +++ b/src/math/fma.rs @@ -11,6 +11,7 @@ struct Num { } #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn normalize(x: f64) -> Num { let x1p63: f64 = f64::from_bits(0x43e0000000000000); // 0x1p63 === 2 ^ 63 @@ -31,6 +32,7 @@ fn normalize(x: f64) -> Num { } #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn mul(x: u64, y: u64) -> (u64, u64) { let t1: u64; let t2: u64; diff --git a/src/math/frexp.rs b/src/math/frexp.rs index badad786a..92fd5ec39 100644 --- a/src/math/frexp.rs +++ b/src/math/frexp.rs @@ -1,3 +1,5 @@ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn frexp(x: f64) -> (f64, i32) { let mut y = x.to_bits(); let ee = ((y >> 52) & 0x7ff) as i32; diff --git a/src/math/frexpf.rs b/src/math/frexpf.rs index 2919c0ab0..a93544d61 100644 --- a/src/math/frexpf.rs +++ b/src/math/frexpf.rs @@ -1,3 +1,5 @@ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn frexpf(x: f32) -> (f32, i32) { let mut y = x.to_bits(); let ee: i32 = ((y >> 23) & 0xff) as i32; diff --git a/src/math/hypot.rs b/src/math/hypot.rs index e53baf539..d47e39caa 100644 --- a/src/math/hypot.rs +++ b/src/math/hypot.rs @@ -5,6 +5,7 @@ use super::sqrt; const SPLIT: f64 = 134217728. + 1.; // 0x1p27 + 1 === (2 ^ 27) + 1 #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn sq(x: f64) -> (f64, f64) { let xh: f64; let xl: f64; diff --git a/src/math/ilogb.rs b/src/math/ilogb.rs index 0a380b7ef..21e5445ca 100644 --- a/src/math/ilogb.rs +++ b/src/math/ilogb.rs @@ -1,6 +1,8 @@ const FP_ILOGBNAN: i32 = -1 - 0x7fffffff; const FP_ILOGB0: i32 = FP_ILOGBNAN; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn ilogb(x: f64) -> i32 { let mut i: u64 = x.to_bits(); let e = ((i >> 52) & 0x7ff) as i32; diff --git a/src/math/ilogbf.rs b/src/math/ilogbf.rs index b384fa4b2..4d8c6b562 100644 --- a/src/math/ilogbf.rs +++ b/src/math/ilogbf.rs @@ -1,6 +1,8 @@ const FP_ILOGBNAN: i32 = -1 - 0x7fffffff; const FP_ILOGB0: i32 = FP_ILOGBNAN; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn ilogbf(x: f32) -> i32 { let mut i = x.to_bits(); let e = ((i >> 23) & 0xff) as i32; diff --git a/src/math/j0.rs b/src/math/j0.rs index c4258ccca..a163da758 100644 --- a/src/math/j0.rs +++ b/src/math/j0.rs @@ -59,6 +59,7 @@ const INVSQRTPI: f64 = 5.64189583547756279280e-01; /* 0x3FE20DD7, 0x50429B6D */ const TPI: f64 = 6.36619772367581382433e-01; /* 0x3FE45F30, 0x6DC9C883 */ /* common method when |x|>=2 */ +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn common(ix: u32, x: f64, y0: bool) -> f64 { let s: f64; let mut c: f64; @@ -109,6 +110,8 @@ const S02: f64 = 1.16926784663337450260e-04; /* 0x3F1EA6D2, 0xDD57DBF4 */ const S03: f64 = 5.13546550207318111446e-07; /* 0x3EA13B54, 0xCE84D5A9 */ const S04: f64 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn j0(mut x: f64) -> f64 { let z: f64; let r: f64; @@ -162,6 +165,8 @@ const V02: f64 = 7.60068627350353253702e-05; /* 0x3F13ECBB, 0xF578C6C1 */ const V03: f64 = 2.59150851840457805467e-07; /* 0x3E91642D, 0x7FF202FD */ const V04: f64 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn y0(x: f64) -> f64 { let z: f64; let u: f64; diff --git a/src/math/j0f.rs b/src/math/j0f.rs index 91c03dbbc..e74eff129 100644 --- a/src/math/j0f.rs +++ b/src/math/j0f.rs @@ -18,6 +18,7 @@ use super::{cosf, fabsf, logf, sinf, sqrtf}; const INVSQRTPI: f32 = 5.6418961287e-01; /* 0x3f106ebb */ const TPI: f32 = 6.3661974669e-01; /* 0x3f22f983 */ +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn common(ix: u32, x: f32, y0: bool) -> f32 { let z: f32; let s: f32; @@ -62,6 +63,8 @@ const S02: f32 = 1.1692678527e-04; /* 0x38f53697 */ const S03: f32 = 5.1354652442e-07; /* 0x3509daa6 */ const S04: f32 = 1.1661400734e-09; /* 0x30a045e8 */ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn j0f(mut x: f32) -> f32 { let z: f32; let r: f32; @@ -107,6 +110,8 @@ const V02: f32 = 7.6006865129e-05; /* 0x389f65e0 */ const V03: f32 = 2.5915085189e-07; /* 0x348b216c */ const V04: f32 = 4.4111031494e-10; /* 0x2ff280c2 */ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn y0f(x: f32) -> f32 { let z: f32; let u: f32; @@ -215,6 +220,7 @@ const PS2: [f32; 5] = [ 1.4657617569e+01, /* 0x416a859a */ ]; +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn pzerof(x: f32) -> f32 { let p: &[f32; 6]; let q: &[f32; 5]; @@ -327,6 +333,7 @@ const QS2: [f32; 6] = [ -5.3109550476e+00, /* 0xc0a9f358 */ ]; +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn qzerof(x: f32) -> f32 { let p: &[f32; 6]; let q: &[f32; 6]; diff --git a/src/math/j1.rs b/src/math/j1.rs index 02a65ca5a..b4eaf1468 100644 --- a/src/math/j1.rs +++ b/src/math/j1.rs @@ -59,6 +59,7 @@ use super::{cos, fabs, get_high_word, get_low_word, log, sin, sqrt}; const INVSQRTPI: f64 = 5.64189583547756279280e-01; /* 0x3FE20DD7, 0x50429B6D */ const TPI: f64 = 6.36619772367581382433e-01; /* 0x3FE45F30, 0x6DC9C883 */ +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn common(ix: u32, x: f64, y1: bool, sign: bool) -> f64 { let z: f64; let mut s: f64; @@ -113,6 +114,8 @@ const S03: f64 = 1.17718464042623683263e-06; /* 0x3EB3BFF8, 0x333F8498 */ const S04: f64 = 5.04636257076217042715e-09; /* 0x3E35AC88, 0xC97DFF2C */ const S05: f64 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn j1(x: f64) -> f64 { let mut z: f64; let r: f64; @@ -158,6 +161,8 @@ const V0: [f64; 5] = [ 1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */ ]; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn y1(x: f64) -> f64 { let z: f64; let u: f64; diff --git a/src/math/j1f.rs b/src/math/j1f.rs index 5095894d7..d67cbe3ce 100644 --- a/src/math/j1f.rs +++ b/src/math/j1f.rs @@ -1,3 +1,4 @@ +#![allow(unused)] /* origin: FreeBSD /usr/src/lib/msun/src/e_j1f.c */ /* * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. @@ -18,6 +19,8 @@ use super::{cosf, fabsf, logf, sinf, sqrtf}; const INVSQRTPI: f32 = 5.6418961287e-01; /* 0x3f106ebb */ const TPI: f32 = 6.3661974669e-01; /* 0x3f22f983 */ +#[inline(always)] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn common(ix: u32, x: f32, y1: bool, sign: bool) -> f32 { let z: f64; let mut s: f64; @@ -63,6 +66,8 @@ const S03: f32 = 1.1771846857e-06; /* 0x359dffc2 */ const S04: f32 = 5.0463624390e-09; /* 0x31ad6446 */ const S05: f32 = 1.2354227016e-11; /* 0x2d59567e */ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn j1f(x: f32) -> f32 { let mut z: f32; let r: f32; @@ -107,6 +112,8 @@ const V0: [f32; 5] = [ 1.6655924903e-11, /* 0x2d9281cf */ ]; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn y1f(x: f32) -> f32 { let z: f32; let u: f32; @@ -214,6 +221,7 @@ const PS2: [f32; 5] = [ 8.3646392822e+00, /* 0x4105d590 */ ]; +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn ponef(x: f32) -> f32 { let p: &[f32; 6]; let q: &[f32; 5]; @@ -326,6 +334,7 @@ const QS2: [f32; 6] = [ -4.9594988823e+00, /* 0xc09eb437 */ ]; +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn qonef(x: f32) -> f32 { let p: &[f32; 6]; let q: &[f32; 6]; diff --git a/src/math/jn.rs b/src/math/jn.rs index 1be167f84..900da69d5 100644 --- a/src/math/jn.rs +++ b/src/math/jn.rs @@ -38,6 +38,8 @@ use super::{cos, fabs, get_high_word, get_low_word, j0, j1, log, sin, sqrt, y0, const INVSQRTPI: f64 = 5.64189583547756279280e-01; /* 0x3FE20DD7, 0x50429B6D */ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn jn(n: i32, mut x: f64) -> f64 { let mut ix: u32; let lx: u32; @@ -251,6 +253,8 @@ pub fn jn(n: i32, mut x: f64) -> f64 { } } +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn yn(n: i32, x: f64) -> f64 { let mut ix: u32; let lx: u32; diff --git a/src/math/jnf.rs b/src/math/jnf.rs index 360f62e20..e81cc987d 100644 --- a/src/math/jnf.rs +++ b/src/math/jnf.rs @@ -15,6 +15,8 @@ use super::{fabsf, j0f, j1f, logf, y0f, y1f}; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn jnf(n: i32, mut x: f32) -> f32 { let mut ix: u32; let mut nm1: i32; @@ -195,6 +197,8 @@ pub fn jnf(n: i32, mut x: f32) -> f32 { } } +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn ynf(n: i32, x: f32) -> f32 { let mut ix: u32; let mut ib: u32; diff --git a/src/math/k_tan.rs b/src/math/k_tan.rs index ea3c386b0..6687b82ed 100644 --- a/src/math/k_tan.rs +++ b/src/math/k_tan.rs @@ -102,6 +102,7 @@ pub(crate) fn k_tan(mut x: f64, mut y: f64, odd: i32) -> f64 { } #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn zero_low_word(x: f64) -> f64 { f64::from_bits(f64::to_bits(x) & 0xFFFF_FFFF_0000_0000) } diff --git a/src/math/lgamma.rs b/src/math/lgamma.rs index 5bc87e85e..3f04ada29 100644 --- a/src/math/lgamma.rs +++ b/src/math/lgamma.rs @@ -1,5 +1,7 @@ use super::lgamma_r; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn lgamma(x: f64) -> f64 { lgamma_r(x).0 } diff --git a/src/math/lgamma_r.rs b/src/math/lgamma_r.rs index 382a501fc..57d5fb801 100644 --- a/src/math/lgamma_r.rs +++ b/src/math/lgamma_r.rs @@ -145,6 +145,7 @@ const W5: f64 = 8.36339918996282139126e-04; /* 0x3F4B67BA, 0x4CDAD5D1 */ const W6: f64 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */ /* sin(PI*x) assuming x > 2^-100, if sin(PI*x)==0 the sign is arbitrary */ +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn sin_pi(mut x: f64) -> f64 { let mut n: i32; @@ -164,6 +165,8 @@ fn sin_pi(mut x: f64) -> f64 { } } +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn lgamma_r(mut x: f64) -> (f64, i32) { let u: u64 = x.to_bits(); let mut t: f64; diff --git a/src/math/lgammaf.rs b/src/math/lgammaf.rs index dfdc87f96..d97be1a94 100644 --- a/src/math/lgammaf.rs +++ b/src/math/lgammaf.rs @@ -1,5 +1,7 @@ use super::lgammaf_r; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn lgammaf(x: f32) -> f32 { lgammaf_r(x).0 } diff --git a/src/math/lgammaf_r.rs b/src/math/lgammaf_r.rs index 0745359a2..ed6c70293 100644 --- a/src/math/lgammaf_r.rs +++ b/src/math/lgammaf_r.rs @@ -99,6 +99,8 @@ fn sin_pi(mut x: f32) -> f32 { } } +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn lgammaf_r(mut x: f32) -> (f32, i32) { let u = x.to_bits(); let mut t: f32; diff --git a/src/math/mod.rs b/src/math/mod.rs index 48b400a92..2642495b0 100644 --- a/src/math/mod.rs +++ b/src/math/mod.rs @@ -315,16 +315,19 @@ use self::rem_pio2_large::rem_pio2_large; use self::rem_pio2f::rem_pio2f; #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn get_high_word(x: f64) -> u32 { (x.to_bits() >> 32) as u32 } #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn get_low_word(x: f64) -> u32 { x.to_bits() as u32 } #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn with_set_high_word(f: f64, hi: u32) -> f64 { let mut tmp = f.to_bits(); tmp &= 0x00000000_ffffffff; @@ -333,6 +336,7 @@ fn with_set_high_word(f: f64, hi: u32) -> f64 { } #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn with_set_low_word(f: f64, lo: u32) -> f64 { let mut tmp = f.to_bits(); tmp &= 0xffffffff_00000000; @@ -341,6 +345,7 @@ fn with_set_low_word(f: f64, lo: u32) -> f64 { } #[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn combine_words(hi: u32, lo: u32) -> f64 { f64::from_bits((hi as u64) << 32 | lo as u64) } diff --git a/src/math/rem_pio2.rs b/src/math/rem_pio2.rs index dc6b3297d..bd7b02766 100644 --- a/src/math/rem_pio2.rs +++ b/src/math/rem_pio2.rs @@ -50,6 +50,7 @@ pub(crate) fn rem_pio2(x: f64) -> (i32, f64, f64) { let ix = (f64::to_bits(x) >> 32) as u32 & 0x7fffffff; #[inline] + #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn medium(x: f64, ix: u32) -> (i32, f64, f64) { /* rint(x/(pi/2)), Assume round-to-nearest. */ let f_n = x as f64 * INV_PIO2 + TO_INT - TO_INT; diff --git a/src/math/remquo.rs b/src/math/remquo.rs index c72c8f187..c9c786d07 100644 --- a/src/math/remquo.rs +++ b/src/math/remquo.rs @@ -1,3 +1,5 @@ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn remquo(mut x: f64, mut y: f64) -> (f64, i32) { let ux: u64 = x.to_bits(); let mut uy: u64 = y.to_bits(); diff --git a/src/math/remquof.rs b/src/math/remquof.rs index 871d0c7d6..66ac72bd6 100644 --- a/src/math/remquof.rs +++ b/src/math/remquof.rs @@ -1,3 +1,5 @@ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn remquof(mut x: f32, mut y: f32) -> (f32, i32) { let ux: u32 = x.to_bits(); let mut uy: u32 = y.to_bits(); diff --git a/src/math/sincos.rs b/src/math/sincos.rs index 750908df4..755d5a71f 100644 --- a/src/math/sincos.rs +++ b/src/math/sincos.rs @@ -12,6 +12,8 @@ use super::{get_high_word, k_cos, k_sin, rem_pio2}; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn sincos(x: f64) -> (f64, f64) { let s: f64; let c: f64; diff --git a/src/math/sincosf.rs b/src/math/sincosf.rs index bb9a00392..96a07c8a6 100644 --- a/src/math/sincosf.rs +++ b/src/math/sincosf.rs @@ -23,6 +23,8 @@ const S2PIO2: f32 = 2.0 * PI_2; /* 0x400921FB, 0x54442D18 */ const S3PIO2: f32 = 3.0 * PI_2; /* 0x4012D97C, 0x7F3321D2 */ const S4PIO2: f32 = 4.0 * PI_2; /* 0x401921FB, 0x54442D18 */ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn sincosf(x: f32) -> (f32, f32) { let s: f32; let c: f32; diff --git a/src/math/tgamma.rs b/src/math/tgamma.rs index f8ccf669a..17378fc16 100644 --- a/src/math/tgamma.rs +++ b/src/math/tgamma.rs @@ -28,6 +28,7 @@ use super::{exp, floor, k_cos, k_sin, pow}; const PI: f64 = 3.141592653589793238462643383279502884; /* sin(pi x) with x > 0x1p-100, if sin(pi*x)==0 the sign is arbitrary */ +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn sinpi(mut x: f64) -> f64 { let mut n: isize; @@ -111,6 +112,7 @@ const FACT: [f64; 23] = [ ]; /* S(x) rational function for positive x */ +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] fn s(x: f64) -> f64 { let mut num: f64 = 0.0; let mut den: f64 = 0.0; @@ -130,6 +132,8 @@ fn s(x: f64) -> f64 { return num / den; } +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn tgamma(mut x: f64) -> f64 { let u: u64 = x.to_bits(); let absx: f64; diff --git a/src/math/tgammaf.rs b/src/math/tgammaf.rs index a8f161f0c..43e7e3efb 100644 --- a/src/math/tgammaf.rs +++ b/src/math/tgammaf.rs @@ -1,5 +1,7 @@ use super::tgamma; +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn tgammaf(x: f32) -> f32 { tgamma(x as f64) as f32 }