Shared Rust kernels
ported/tanh
All modules · quoted at commit 9e1884369a67 of DnaCalc/DnaCalc. Comments are the source's own.
tanh_kernel · 17 lines · calc-func/src/ported/tanh.rs on GitHubpub fn tanh_kernel(n: f64) -> f64 {
// W111: small arguments reuse the cancellation-safe expm1 pair for the
// denominator too. The public COSH result is observably different there.
let denominator = if n.abs() < 1.0 {
let sum = crate::ported::excel_numeric::excel_x87_add(
crate::ported::excel_numeric::excel_expm1_internal(n),
crate::ported::excel_numeric::excel_expm1_internal(-n),
);
crate::ported::excel_numeric::excel_x87_add(sum, 2.0) / 2.0
} else {
crate::ported::cosh::cosh_kernel(n)
};
crate::ported::excel_numeric::excel_x87_div(
crate::ported::sinh::sinh_kernel(n),
denominator,
)
}
Used by 2 functions.