Skip to content

Commit 0c0c911

Browse files
Nikhil0250copybara-github
authored andcommitted
Update accuracy comments and tighten bounds for FastPow
PiperOrigin-RevId: 909544721
1 parent 8d45d98 commit 0c0c911

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

hwy/contrib/math/fast_math-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ HWY_INLINE V FastLog1p(const D d, V x) {
18821882
* Valid Lane Types: float32, float64
18831883
* Valid Range: float32: base in (0, +FLT_MAX], exp * log(base) in [-25.0,
18841884
* +25.0] float64: base in (0, +DBL_MAX], exp * log(base) in [-25.0, +25.0] Max
1885-
* Relative Error for Valid Range: float32 : 0.27%, float64 : 0.22%
1885+
* Relative Error for Valid Range: float32 : 0.03%, float64 : 0.03%
18861886
* @return base^exp
18871887
*/
18881888
// If false, subnormals are treated as zero.

hwy/contrib/math/math_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ struct TestFastPow {
581581
max_error_base = static_cast<double>(base);
582582
max_error_exp = static_cast<double>(exp_val);
583583
}
584-
if (rel > 0.006) {
584+
if (rel > 0.0003) {
585585
static int print_count = 0;
586586
if (print_count < 10) {
587587
fprintf(stderr,
@@ -590,7 +590,7 @@ struct TestFastPow {
590590
hwy::TypeName(T(), Lanes(d)).c_str(),
591591
static_cast<double>(base), static_cast<double>(exp_val),
592592
static_cast<double>(expected),
593-
static_cast<double>(actual), rel, 0.006);
593+
static_cast<double>(actual), rel, 0.0003);
594594
print_count++;
595595
}
596596
}
@@ -601,7 +601,7 @@ struct TestFastPow {
601601
fprintf(stderr, "%s: FastPow max_rel_error %E at base=%E exp=%E\n",
602602
hwy::TypeName(T(), Lanes(d)).c_str(), max_actual_rel_error,
603603
max_error_base, max_error_exp);
604-
HWY_ASSERT(max_actual_rel_error <= 0.006);
604+
HWY_ASSERT(max_actual_rel_error <= 0.0003);
605605
}
606606
};
607607

0 commit comments

Comments
 (0)