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/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..01b7710eb 100644 --- a/src/math/erf.rs +++ b/src/math/erf.rs @@ -219,6 +219,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 +270,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..f6c14a5e0 100644 --- a/src/math/erff.rs +++ b/src/math/erff.rs @@ -130,6 +130,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 +181,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/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/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..7103729c1 100644 --- a/src/math/j0.rs +++ b/src/math/j0.rs @@ -109,6 +109,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 +164,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..c8f793c6d 100644 --- a/src/math/j0f.rs +++ b/src/math/j0f.rs @@ -62,6 +62,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 +109,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; diff --git a/src/math/j1.rs b/src/math/j1.rs index 02a65ca5a..8b6352a10 100644 --- a/src/math/j1.rs +++ b/src/math/j1.rs @@ -113,6 +113,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 +160,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..c15cf1f62 100644 --- a/src/math/j1f.rs +++ b/src/math/j1f.rs @@ -63,6 +63,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 +109,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; 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/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..f1ab295d0 100644 --- a/src/math/lgamma_r.rs +++ b/src/math/lgamma_r.rs @@ -164,6 +164,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/modf.rs b/src/math/modf.rs index bcab33a81..6b345fc03 100644 --- a/src/math/modf.rs +++ b/src/math/modf.rs @@ -1,3 +1,5 @@ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn modf(x: f64) -> (f64, f64) { let rv2: f64; let mut u = x.to_bits(); diff --git a/src/math/modff.rs b/src/math/modff.rs index 56ece12e3..f6e5f3806 100644 --- a/src/math/modff.rs +++ b/src/math/modff.rs @@ -1,3 +1,5 @@ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn modff(x: f32) -> (f32, f32) { let rv2: f32; let mut u: u32 = x.to_bits(); 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..098f489bd 100644 --- a/src/math/tgamma.rs +++ b/src/math/tgamma.rs @@ -130,6 +130,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 }