use slatec_sys::special::elementary as raw;
use super::{SpecialFunctionError, runtime};
pub fn log1p(x: f64) -> Result<f64, SpecialFunctionError> {
if !(x.is_finite() && x > -1.0) {
return Err(SpecialFunctionError::Domain {
function: "log1p",
argument: "x",
value: x,
});
}
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::dlnrel(&mut x) })
}
pub fn exprel(x: f64) -> Result<f64, SpecialFunctionError> {
runtime::finite("exprel", "x", x)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::dexprl(&mut x) })
}
pub fn cbrt(x: f64) -> Result<f64, SpecialFunctionError> {
runtime::finite("cbrt", "x", x)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::dcbrt(&mut x) })
}
pub fn sin_degrees(x: f64) -> Result<f64, SpecialFunctionError> {
runtime::finite("sin_degrees", "degrees", x)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::dsindg(&mut x) })
}
pub fn cos_degrees(x: f64) -> Result<f64, SpecialFunctionError> {
runtime::finite("cos_degrees", "degrees", x)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::dcosdg(&mut x) })
}
pub fn dawson(x: f64) -> Result<f64, SpecialFunctionError> {
runtime::bounded("dawson", "x", x, 1.0e6)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::ddaws(&mut x) })
}
#[cfg(feature = "special-f32")]
pub fn log1p_f32(x: f32) -> Result<f32, SpecialFunctionError> {
if !(x.is_finite() && x > -1.0) {
return Err(SpecialFunctionError::Domain {
function: "log1p_f32",
argument: "x",
value: f64::from(x),
});
}
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::alnrel(&mut x) })
}
#[cfg(feature = "special-f32")]
pub fn exprel_f32(x: f32) -> Result<f32, SpecialFunctionError> {
runtime::finite_f32("exprel_f32", "x", x)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::exprel(&mut x) })
}
#[cfg(feature = "special-f32")]
pub fn cbrt_f32(x: f32) -> Result<f32, SpecialFunctionError> {
runtime::finite_f32("cbrt_f32", "x", x)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::cbrt(&mut x) })
}
#[cfg(feature = "special-f32")]
pub fn sin_degrees_f32(x: f32) -> Result<f32, SpecialFunctionError> {
runtime::finite_f32("sin_degrees_f32", "degrees", x)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::sindg(&mut x) })
}
#[cfg(feature = "special-f32")]
pub fn cos_degrees_f32(x: f32) -> Result<f32, SpecialFunctionError> {
runtime::finite_f32("cos_degrees_f32", "degrees", x)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::cosdg(&mut x) })
}
#[cfg(feature = "special-f32")]
pub fn dawson_f32(x: f32) -> Result<f32, SpecialFunctionError> {
runtime::bounded_f32("dawson_f32", "x", x, 1.0e3)?;
let _guard = runtime::lock_fnlib();
let mut x = x;
Ok(unsafe { raw::daws(&mut x) })
}