Skip to content

Commit 9f38d8d

Browse files
committed
Add cr_hypot from core-math
1 parent c344b66 commit 9f38d8d

File tree

3 files changed

+313
-60
lines changed

3 files changed

+313
-60
lines changed

libm-test/src/generate/case_list.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub struct TestCase<Op: MathOp> {
1818
}
1919

2020
impl<Op: MathOp> TestCase<Op> {
21-
#[expect(dead_code)]
2221
fn append_inputs(v: &mut Vec<Self>, l: &[Op::RustArgs]) {
2322
v.extend(l.iter().copied().map(|input| Self {
2423
input,
@@ -479,7 +478,27 @@ fn frexpf128_cases() -> Vec<TestCase<op::frexpf128::Routine>> {
479478
}
480479

481480
fn hypot_cases() -> Vec<TestCase<op::hypot::Routine>> {
482-
vec![]
481+
let mut v = vec![];
482+
TestCase::append_inputs(
483+
&mut v,
484+
&[
485+
// Cases that can overflow exponent if wrapping arithmetic is not used
486+
(
487+
hf64!("-0x1.800f800f80100p+1023"),
488+
hf64!("0x1.8354835473720p+996"),
489+
),
490+
(hf64!("0x1.201b201b201c0p+0"), hf64!("0x1.b028b028b02a0p-1")),
491+
(
492+
hf64!("-0x1.e538e538e564p+980"),
493+
hf64!("-0x1.c4dfc4dfc508p+983"),
494+
),
495+
(
496+
hf64!("-0x1.2f22e4f77aa58p+983"),
497+
hf64!("-0x1.44c9f5524c8ccp+980"),
498+
),
499+
],
500+
);
501+
v
483502
}
484503

485504
fn hypotf_cases() -> Vec<TestCase<op::hypotf::Routine>> {

libm-test/src/precision.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
4646

4747
// Operations that aren't required to be exact, but our implementations are.
4848
Bn::Cbrt => 0,
49+
Bn::Hypot if ctx.fn_ident == Id::Hypot => 0,
4950

5051
// Bessel functions have large inaccuracies.
5152
Bn::J0 | Bn::J1 | Bn::Y0 | Bn::Y1 | Bn::Jn | Bn::Yn => 8_000_000,
@@ -112,6 +113,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
112113
Id::Fdim => ulp = 2,
113114
Id::Exp2f => ulp = 1,
114115
Id::Expf => ulp = 1,
116+
Id::Hypot => ulp = 1,
115117
Id::Sincosf => ulp = 500,
116118
Id::Tgamma => ulp = 20,
117119
_ => (),

0 commit comments

Comments
 (0)