Skip to content

Commit 4a3d4c0

Browse files
committed
changes post review
1 parent 7f59e4c commit 4a3d4c0

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

libc/src/math/atanf16.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//===-- Implementation header for atanf16 -----------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4-
// See https://llvm.org/LICENSE.txt for license information. //
5-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception. //
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
6+
//
67
//===----------------------------------------------------------------------===//
78

89
#ifndef LLVM_LIBC_SRC_MATH_ATANF16_H

libc/src/math/generic/atanf16.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,24 @@ LLVM_LIBC_FUNCTION(float16, atanf16, (float16 x)) {
7878
}
7979

8080
// Degree-14 minimax odd polynomial of atan(x) generated by Sollya with:
81-
// > P = fpminimax(atan(x)/x, [|0, 2, 4, 6, 8, 10, 12, 14|], [|SG...|], [0,
82-
// 1]);
81+
// > P = fpminimax(atan(x)/x, [|0, 2, 4, 6, 8, 10, 12, 14|], [|SG...|],
82+
// [0, 1]);
8383
float result = fputil::polyeval(
8484
xsq, 0x1.fffffcp-1f, -0x1.55519ep-2f, 0x1.98f6a8p-3f, -0x1.1f0a92p-3f,
8585
0x1.95b654p-4f, -0x1.e65492p-5f, 0x1.8c0c36p-6f, -0x1.32316ep-8f);
8686
return fputil::cast<float16>(xf * result);
8787
}
8888

8989
// If |x| > 1
90-
// y = atan(x)
91-
// y = atan(|x|) = pi/2 - atan(1/|x|)
90+
// y = atan(x) = sign(x) * atan(|x|)
91+
// atan(|x|) = pi/2 - atan(1/|x|)
9292
// Recall, 1/|x| < 1
9393
float x_inv_sq = 1 / xsq;
9494
float x_inv = fputil::sqrt<float>(x_inv_sq);
95+
96+
// Degree-14 minimax odd polynomial of atan(x) generated by Sollya with:
97+
// > P = fpminimax(atan(x)/x, [|0, 2, 4, 6, 8, 10, 12, 14|], [|SG...|],
98+
// [0, 1]);
9599
float interm =
96100
fputil::polyeval(x_inv_sq, 0x1.fffffcp-1f, -0x1.55519ep-2f,
97101
0x1.98f6a8p-3f, -0x1.1f0a92p-3f, 0x1.95b654p-4f,

libc/test/src/math/atanf16_test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//===-- Exhaustive test for atanf16 ---------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
19
#include "src/math/atanf16.h"
210
#include "test/UnitTest/FPMatcher.h"
311
#include "test/UnitTest/Test.h"

libc/test/src/math/smoke/atanf16_test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//===-- Unittests for atanf16 ---------------------------------------------===//
22
//
3-
//
43
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
54
// See https://llvm.org/LICENSE.txt for license information.
65
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.

0 commit comments

Comments
 (0)