Skip to content

Commit c57f5d9

Browse files
committed
wip: Generic cbrt
1 parent 6675cd1 commit c57f5d9

File tree

6 files changed

+243
-99
lines changed

6 files changed

+243
-99
lines changed

etc/consts-cbrt.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
using Printf
3+
using Remez
4+
5+
function main()
6+
run_one("f64", "hf64!", 53)
7+
end
8+
9+
function run_one(name::String, hf::String, precision::Integer)
10+
setprecision(precision)
11+
12+
println("Constants for ", name)
13+
14+
println("const ESCALE: [Self; 3] = [")
15+
for n in 0:2
16+
val = big(2) ^ (n / 3)
17+
@printf " %s(\"%a\"),\n" hf val
18+
end
19+
print("];")
20+
21+
end
22+
23+
main()

etc/update-api-list.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
# These files do not trigger a retest.
2424
IGNORED_SOURCES = ["libm/src/libm_helper.rs", "libm/src/math/support/float_traits.rs"]
25+
# Same as above, limited to specific functions
26+
IGNORED_SOURCES_MAP = {"fma": ["libm/src/math/cbrt.rs"]}
2527

2628
IndexTy: TypeAlias = dict[str, dict[str, Any]]
2729
"""Type of the `index` item in rustdoc's JSON output"""
@@ -137,6 +139,8 @@ def _init_defs(self, index: IndexTy) -> None:
137139

138140
for src in IGNORED_SOURCES:
139141
sources.discard(src)
142+
for src in IGNORED_SOURCES_MAP.get(name, []):
143+
sources.discard(src)
140144

141145
# Sort the set
142146
self.defs = {k: sorted(v) for (k, v) in defs.items()}

libm-test/src/domain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<F: Float, I: Int> EitherPrim<Domain<F>, Domain<I>> {
196196
Box::new((0..u8::MAX).map(|scale| {
197197
let mut base = F::ZERO;
198198
for _ in 0..scale {
199-
base = base - F::ONE;
199+
base -= F::ONE;
200200
}
201201
base
202202
}))

libm-test/src/f8_impl.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ impl Float for f8 {
3838
const NEG_PI: Self = Self::ZERO;
3939
const FRAC_PI_2: Self = Self::ZERO;
4040

41+
/// `2^sig_bits`
42+
const TWO_POW_SIG_BITS: Self =
43+
Self(((Self::SIG_BITS + Self::EXP_BIAS) as Self::Int) << Self::SIG_BITS);
44+
/// `2^-sig_bits`
45+
const TWO_POW_NEG_SIG_BITS: Self =
46+
Self(((-(Self::SIG_BITS as i32) + Self::EXP_BIAS as i32) as Self::Int) << Self::SIG_BITS);
47+
4148
const BITS: u32 = 8;
4249
const SIG_BITS: u32 = 3;
4350
const SIGN_MASK: Self::Int = 0b1_0000_000;

0 commit comments

Comments
 (0)