Skip to content

Commit 774fd60

Browse files
committed
Addressed the feedback:
- Moved comments about polynomial in line 55 to remove redundancy - Renamed constexpr array with capital letters - Added file that was missed in initial commit - Ran clang-format on files
1 parent 34af544 commit 774fd60

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

libc/src/math/generic/acospif16.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ LLVM_LIBC_FUNCTION(float16, acospif16, (float16 x)) {
5151

5252
float xf = x;
5353
float xsq = xf * xf;
54-
constexpr float poly_coeffs[5] = {0x1.45f308p-2f, 0x1.b2900cp-5f,
54+
55+
// Degree-6 minimax polynomial coefficients of asin(x) generated by Sollya
56+
// with: > P = fpminimax(asin(x)/(pi * x), [|0, 2, 4, 6, 8|], [|SG...|], [0,
57+
// 0.5]);
58+
constexpr float POLY_COEFFS[5] = {0x1.45f308p-2f, 0x1.b2900cp-5f,
5559
0x1.897e36p-6f, 0x1.9efafcp-7f,
5660
0x1.06d884p-6f};
5761
// |x| <= 0x1p-1, |x| <= 0.5
@@ -62,12 +66,9 @@ LLVM_LIBC_FUNCTION(float16, acospif16, (float16 x)) {
6266

6367
// Note that: acos(x) = pi/2 + asin(-x) = pi/2 - asin(x), then
6468
// acospi(x) = 0.5 - asin(x)/pi
65-
// Degree-6 minimax polynomial of asin(x) generated by Sollya with:
66-
// > P = fpminimax(asin(x)/(pi * x), [|0, 2, 4, 6, 8|], [|SG...|], [0,
67-
// 0.5]);
6869
float interm =
69-
fputil::polyeval(xsq, poly_coeffs[0], poly_coeffs[1], poly_coeffs[2],
70-
poly_coeffs[3], poly_coeffs[4]);
70+
fputil::polyeval(xsq, POLY_COEFFS[0], POLY_COEFFS[1], POLY_COEFFS[2],
71+
POLY_COEFFS[3], POLY_COEFFS[4]);
7172

7273
return fputil::cast<float16>(fputil::multiply_add(-xf, interm, 0.5f));
7374
}
@@ -118,11 +119,9 @@ LLVM_LIBC_FUNCTION(float16, acospif16, (float16 x)) {
118119
float u = fputil::multiply_add(-0.5f, xf_abs, 0.5f);
119120
float sqrt_u = fputil::sqrt<float>(u);
120121

121-
// Degree-6 minimax polynomial of asin(x) generated by Sollya with:
122-
// > P = fpminimax(asin(x)/(pi * x), [|0, 2, 4, 6, 8|], [|SG...|], [0, 0.5]);
123122
float asin_sqrt_u =
124-
sqrt_u * fputil::polyeval(u, poly_coeffs[0], poly_coeffs[1],
125-
poly_coeffs[2], poly_coeffs[3], poly_coeffs[4]);
123+
sqrt_u * fputil::polyeval(u, POLY_COEFFS[0], POLY_COEFFS[1],
124+
POLY_COEFFS[2], POLY_COEFFS[3], POLY_COEFFS[4]);
126125

127126
// Same as acos(x), but devided the expression with pi
128127
return fputil::cast<float16>(

libc/utils/MPFRWrapper/MPCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class MPFRNumber {
180180
bool is_nan() const;
181181
MPFRNumber abs() const;
182182
MPFRNumber acos() const;
183+
MPFRNumber acospi() const;
183184
MPFRNumber acosh() const;
184185
MPFRNumber add(const MPFRNumber &b) const;
185186
MPFRNumber asin() const;

libc/utils/MPFRWrapper/MPFRUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ unary_operation(Operation op, InputType input, unsigned int precision,
3333
case Operation::Acosh:
3434
return mpfrInput.acosh();
3535
case Operation::Acospi:
36-
return mpfrInput.acospi();
36+
return mpfrInput.acospi();
3737
case Operation::Asin:
3838
return mpfrInput.asin();
3939
case Operation::Asinh:

0 commit comments

Comments
 (0)