Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Add cr_log from core-math #326

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions crates/libm-test/src/gen/case_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub struct TestCase<Op: MathOp> {
}

impl<Op: MathOp> TestCase<Op> {
#[expect(dead_code)]
fn append_inputs(v: &mut Vec<Self>, l: &[Op::RustArgs]) {
v.extend(l.iter().copied().map(|input| Self { input, output: None }));
}
Expand Down Expand Up @@ -503,7 +502,17 @@ fn lgammaf_r_cases() -> Vec<TestCase<op::lgammaf_r::Routine>> {
}

fn log_cases() -> Vec<TestCase<op::log::Routine>> {
vec![]
let mut v = vec![];
TestCase::append_inputs(
&mut v,
&[
// Cases that showed up during extensive tests and proved problematic
(hf64!("0x1.ffffffffffff9p-1"),),
(hf64!("0x1.4b649a5ce2720p-235"),),
(hf64!("0x1.b028b028b02a0p-1"),),
],
);
v
}

fn log10_cases() -> Vec<TestCase<op::log10::Routine>> {
Expand Down
2 changes: 2 additions & 0 deletions crates/libm-test/src/precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {

// Operations that aren't required to be exact, but our implementations are.
Bn::Cbrt => 0,
Bn::Log if ctx.fn_ident == Id::Log => 0,

// Bessel functions have large inaccuracies.
Bn::J0 | Bn::J1 | Bn::Y0 | Bn::Y1 | Bn::Jn | Bn::Yn => 8_000_000,
Expand Down Expand Up @@ -97,6 +98,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {

match ctx.fn_ident {
Id::Cbrt => ulp = 2,
Id::Log => ulp = 2,
// FIXME(#401): musl has an incorrect result here.
Id::Fdim => ulp = 2,
Id::Sincosf => ulp = 500,
Expand Down
Loading
Loading