Skip to content

Commit 1c6298c

Browse files
committed
Add cr_hypot from core-math
1 parent 0bdef05 commit 1c6298c

File tree

4 files changed

+321
-61
lines changed

4 files changed

+321
-61
lines changed

libm-test/src/generate/case_list.rs

+21-2
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,
@@ -458,7 +457,27 @@ fn frexpf_cases() -> Vec<TestCase<op::frexpf::Routine>> {
458457
}
459458

460459
fn hypot_cases() -> Vec<TestCase<op::hypot::Routine>> {
461-
vec![]
460+
let mut v = vec![];
461+
TestCase::append_inputs(
462+
&mut v,
463+
&[
464+
// Cases that can overflow exponent if wrapping arithmetic is not used
465+
(
466+
hf64!("-0x1.800f800f80100p+1023"),
467+
hf64!("0x1.8354835473720p+996"),
468+
),
469+
(hf64!("0x1.201b201b201c0p+0"), hf64!("0x1.b028b028b02a0p-1")),
470+
(
471+
hf64!("-0x1.e538e538e564p+980"),
472+
hf64!("-0x1.c4dfc4dfc508p+983"),
473+
),
474+
(
475+
hf64!("-0x1.2f22e4f77aa58p+983"),
476+
hf64!("-0x1.44c9f5524c8ccp+980"),
477+
),
478+
],
479+
);
480+
v
462481
}
463482

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

libm-test/src/precision.rs

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
4848

4949
// Operations that aren't required to be exact, but our implementations are.
5050
Bn::Cbrt => 0,
51+
Bn::Hypot if ctx.fn_ident == Id::Hypot => 0,
5152

5253
// Bessel functions have large inaccuracies.
5354
Bn::J0 | Bn::J1 | Bn::Y0 | Bn::Y1 | Bn::Jn | Bn::Yn => 8_000_000,
@@ -100,6 +101,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
100101
Id::Cbrt => ulp = 2,
101102
// FIXME(#401): musl has an incorrect result here.
102103
Id::Fdim => ulp = 2,
104+
Id::Hypot => ulp = 1,
103105
Id::Sincosf => ulp = 500,
104106
Id::Tgamma => ulp = 20,
105107
_ => (),

libm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
)]
99
#![cfg_attr(f128_enabled, feature(f128))]
1010
#![cfg_attr(f16_enabled, feature(f16))]
11+
#![allow(internal_features)]
1112
#![allow(clippy::assign_op_pattern)]
1213
#![allow(clippy::deprecated_cfg_attr)]
1314
#![allow(clippy::eq_op)]

0 commit comments

Comments
 (0)