Skip to content

Commit b6e0457

Browse files
committed
clang format
1 parent 0d59443 commit b6e0457

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

libc/docs/math/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ Higher Math Functions
280280
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
281281
| cosh | |check| | | | |check| | | 7.12.5.4 | F.10.2.4 |
282282
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
283-
| cospi | |check| | | | | | 7.12.4.12 | F.10.1.12 |
283+
| cospi | |check| | | | |check| | | 7.12.4.12 | F.10.1.12 |
284284
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
285285
| dsqrt | N/A | N/A | |check| | N/A | |check|\* | 7.12.14.6 | F.10.11 |
286286
+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+

libc/src/math/generic/cospif16.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,28 @@ LLVM_LIBC_FUNCTION(float16, cospif16, (float16 x)) {
7575
// polynomials generated by Sollya.
7676

7777
// For signed zeros
78-
if (LIBC_UNLIKELY(x_abs == 0U)) return fputil::cast<float16>(1.0f);
78+
if (LIBC_UNLIKELY(x_abs == 0U))
79+
return fputil::cast<float16>(1.0f);
7980

8081
// Numbers greater or equal to 2^10 are integers, or infinity, or NaN
8182
if (LIBC_UNLIKELY(x_abs >= 0x6400)) {
8283
if (LIBC_UNLIKELY(x_abs <= 0x67FF)) {
83-
return fputil::cast<float16>((x_abs & 0x1) ? -1.0f : 1.0f);
84+
return fputil::cast<float16>((x_abs & 0x1) ? -1.0f : 1.0f);
8485
}
85-
86+
8687
// Check for NaN or infintiy values
8788
if (LIBC_UNLIKELY(x_abs >= 0x7c00)) {
8889
// If value is equal to infinity
8990
if (x_abs == 0x7c00) {
9091
fputil::set_errno_if_required(EDOM);
91-
fputil::raise_except_if_required(FE_INVALID);
92+
fputil::raise_except_if_required(FE_INVALID);
9293
}
9394

9495
return x + FPBits::quiet_nan().get_val();
9596
}
96-
97-
return fputil::cast<float16>(1.0f);
97+
98+
return fputil::cast<float16>(1.0f);
9899
}
99-
100100

101101
float f32 = x;
102102
float y;
@@ -107,16 +107,16 @@ LLVM_LIBC_FUNCTION(float16, cospif16, (float16 x)) {
107107

108108
// Recall;
109109
// cos(x * pi/32) = cos((k + y) * pi/32)
110-
// = cos(y * pi/32) * cos(k * pi/32)
111-
// - sin(y * pi/32) * sin(k * pi/32)
110+
// = cos(y * pi/32) * cos(k * pi/32)
111+
// - sin(y * pi/32) * sin(k * pi/32)
112112
// Recall, after range reduction, -0.5 <= y <= 0.5. For very small
113113
// values of y, calculating sin(y * p/32) can be inaccurate. Generating a
114114
// polynomial for sin(y * p/32)/y instead significantly reduces the relative
115115
// errors.
116116
float ysq = y * y;
117117

118118
// Degree-6 minimax even polynomial for sin(y*pi/32)/y generated by Sollya
119-
// with:
119+
// with:
120120
// > Q = fpminimax(sin(y*pi/32)/y, [|0, 2, 4, 6|], [|SG...|], [0, 0.5]);
121121
float sin_y = y * fputil::polyeval(ysq, 0x1.921fb6p-4f, -0x1.4aeabcp-13f,
122122
0x1.a03354p-21f, -0x1.ad02d2p-20f);
@@ -136,6 +136,7 @@ LLVM_LIBC_FUNCTION(float16, cospif16, (float16 x)) {
136136

137137
// Since, cosm1_y = cos_y - 1, therefore:
138138
// cos(x * pi) = cos_k(cosm1_y) + cos_k - sin_k * sin_y
139-
return fputil::cast<float16>(fputil::multiply_add(cos_k, cosm1_y, fputil::multiply_add(-sin_k, sin_y, cos_k)));
139+
return fputil::cast<float16>(fputil::multiply_add(
140+
cos_k, cosm1_y, fputil::multiply_add(-sin_k, sin_y, cos_k)));
140141
}
141142
} // namespace LIBC_NAMESPACE_DECL

libc/test/src/math/cospif16_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ static constexpr uint16_t NEG_STOP = 0xfc00U;
2626
TEST_F(LlvmLibcCospif16Test, PositiveRange) {
2727
for (uint16_t v = POS_START; v <= POS_STOP; ++v) {
2828
float16 x = FPBits(v).get_val();
29-
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cospi, x, LIBC_NAMESPACE::cospif16(x), 0.5);
29+
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cospi, x,
30+
LIBC_NAMESPACE::cospif16(x), 0.5);
3031
}
3132
}
3233

3334
TEST_F(LlvmLibcCospif16Test, NegativeRange) {
3435
for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {
3536
float16 x = FPBits(v).get_val();
36-
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cospi, x, LIBC_NAMESPACE::cospif16(x), 0.5);
37+
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cospi, x,
38+
LIBC_NAMESPACE::cospif16(x), 0.5);
3739
}
3840
}

0 commit comments

Comments
 (0)