-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc++][NFC] Rearrange functions in the synopsis comments of <cmath>
#100862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Currently, it's a bit hard to parse the `// C++17` comments nested in the `// C99` group. This patch attempts to sort functions into 4 groups. - C90: functions with names introduced in C89/90. - C99: functions with names introduced C99, including `f` and `l` variants of C89/90 functions, except for 3D `hypot`. - C++17: 3D `hypot` and C++17 math special functions. - C++20: C++20 `lerp`. The next group is expected to be C23, which will be added when C++ starts to merge C23 math functions. More `arithmetic` and `floating_point` are used for simplification.
|
@llvm/pr-subscribers-libcxx Author: A. Jiang (frederick-vs-ja) ChangesCurrently, it's a bit hard to parse the
The next group is expected to be C23, which will be added when C++ starts to merge C23 math functions. More Full diff: https://github.com/llvm/llvm-project/pull/100862.diff 1 Files Affected:
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index 3c22604a683c3..32b8ccdf4e698 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -46,112 +46,134 @@ Types:
floating_point abs(floating_point x);
-floating_point acos (arithmetic x);
+floating_point acos(arithmetic x);
+
+floating_point asin(arithmetic x);
+
+floating_point atan(arithmetic x);
+
+floating_point atan2(arithmetic y, arithmetic x);
+
+floating_point ceil(arithmetic x);
+
+floating_point cos(arithmetic x);
+
+floating_point cosh(arithmetic x);
+
+floating_point exp(arithmetic x);
+
+floating_point fabs(arithmetic x);
+
+floating_point floor(arithmetic x);
+
+floating_point fmod(arithmetic x, arithmetic y);
+
+floating_point frexp(arithmetic value, int* exp);
+
+floating_point ldexp(arithmetic value, int exp);
+
+floating_point log(arithmetic x);
+
+floating_point modf(floating_point value, floating_point* iptr);
+
+floating_point log10(arithmetic x);
+
+floating_point pow(arithmetic x, arithmetic y);
+
+floating_point sin(arithmetic x);
+
+floating_point sinh(arithmetic x);
+
+floating_point sqrt(arithmetic x);
+
+floating_point tan(arithmetic x);
+
+floating_point tanh(arithmetic x);
+
+// C99
+
+bool signbit(arithmetic x);
+
+int fpclassify(arithmetic x);
+
+bool isfinite(arithmetic x);
+bool isinf(arithmetic x);
+bool isnan(arithmetic x);
+bool isnormal(arithmetic x);
+
+bool isgreater(arithmetic x, arithmetic y);
+bool isgreaterequal(arithmetic x, arithmetic y);
+bool isless(arithmetic x, arithmetic y);
+bool islessequal(arithmetic x, arithmetic y);
+bool islessgreater(arithmetic x, arithmetic y);
+bool isunordered(arithmetic x, arithmetic y);
+
float acosf(float x);
long double acosl(long double x);
-floating_point asin (arithmetic x);
float asinf(float x);
long double asinl(long double x);
-floating_point atan (arithmetic x);
float atanf(float x);
long double atanl(long double x);
-floating_point atan2 (arithmetic y, arithmetic x);
float atan2f(float y, float x);
long double atan2l(long double y, long double x);
-floating_point ceil (arithmetic x);
float ceilf(float x);
long double ceill(long double x);
-floating_point cos (arithmetic x);
float cosf(float x);
long double cosl(long double x);
-floating_point cosh (arithmetic x);
float coshf(float x);
long double coshl(long double x);
-floating_point exp (arithmetic x);
float expf(float x);
long double expl(long double x);
-floating_point fabs (arithmetic x);
float fabsf(float x);
long double fabsl(long double x);
-floating_point floor (arithmetic x);
float floorf(float x);
long double floorl(long double x);
-floating_point fmod (arithmetic x, arithmetic y);
float fmodf(float x, float y);
long double fmodl(long double x, long double y);
-floating_point frexp (arithmetic value, int* exp);
float frexpf(float value, int* exp);
long double frexpl(long double value, int* exp);
-floating_point ldexp (arithmetic value, int exp);
float ldexpf(float value, int exp);
long double ldexpl(long double value, int exp);
-floating_point log (arithmetic x);
float logf(float x);
long double logl(long double x);
-floating_point log10 (arithmetic x);
float log10f(float x);
long double log10l(long double x);
-floating_point modf (floating_point value, floating_point* iptr);
float modff(float value, float* iptr);
long double modfl(long double value, long double* iptr);
-floating_point pow (arithmetic x, arithmetic y);
float powf(float x, float y);
long double powl(long double x, long double y);
-floating_point sin (arithmetic x);
float sinf(float x);
long double sinl(long double x);
-floating_point sinh (arithmetic x);
float sinhf(float x);
long double sinhl(long double x);
-floating_point sqrt (arithmetic x);
float sqrtf(float x);
long double sqrtl(long double x);
-floating_point tan (arithmetic x);
float tanf(float x);
long double tanl(long double x);
-floating_point tanh (arithmetic x);
float tanhf(float x);
long double tanhl(long double x);
-// C99
-
-bool signbit(arithmetic x);
-
-int fpclassify(arithmetic x);
-
-bool isfinite(arithmetic x);
-bool isinf(arithmetic x);
-bool isnan(arithmetic x);
-bool isnormal(arithmetic x);
-
-bool isgreater(arithmetic x, arithmetic y);
-bool isgreaterequal(arithmetic x, arithmetic y);
-bool isless(arithmetic x, arithmetic y);
-bool islessequal(arithmetic x, arithmetic y);
-bool islessgreater(arithmetic x, arithmetic y);
-bool isunordered(arithmetic x, arithmetic y);
-
floating_point acosh (arithmetic x);
float acoshf(float x);
long double acoshl(long double x);
@@ -204,22 +226,10 @@ floating_point fmin (arithmetic x, arithmetic y);
float fminf(float x, float y);
long double fminl(long double x, long double y);
-double hermite(unsigned n, double x); // C++17
-float hermite(unsigned n, float x); // C++17
-long double hermite(unsigned n, long double x); // C++17
-float hermitef(unsigned n, float x); // C++17
-long double hermitel(unsigned n, long double x); // C++17
-template <class Integer>
-double hermite(unsigned n, Integer x); // C++17
-
floating_point hypot (arithmetic x, arithmetic y);
float hypotf(float x, float y);
long double hypotl(long double x, long double y);
-double hypot(double x, double y, double z); // C++17
-float hypot(float x, float y, float z); // C++17
-long double hypot(long double x, long double y, long double z); // C++17
-
int ilogb (arithmetic x);
int ilogbf(float x);
int ilogbl(long double x);
@@ -304,9 +314,17 @@ floating_point trunc (arithmetic x);
float truncf(float x);
long double truncl(long double x);
-constexpr float lerp(float a, float b, float t) noexcept; // C++20
-constexpr double lerp(double a, double b, double t) noexcept; // C++20
-constexpr long double lerp(long double a, long double b, long double t) noexcept; // C++20
+// C++17
+
+floating_point hypot(arithmetic x, arithmetic y, arithmetic z);
+
+floating_point hermite (unsigned n, arithmetic x);
+float hermitef(unsigned n, float x);
+long double hermitel(unsigned n, long double x);
+
+// C++20
+
+constexpr floating_point lerp(arithmetic a, arithmetic b, arithmetic t) noexcept;
} // std
|
| floating_point hermite (unsigned n, arithmetic x); | ||
| float hermitef(unsigned n, float x); | ||
| long double hermitel(unsigned n, long double x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will affect the convention of math special functions in synopsis comments. I think it will be better to show them consistently with most other functions.
@PaulXiCao Would you mind to follow this (probably pre-existing) convention?
|
The previous order was (almost?) an exact copy of the standard I believe (e.g. see https://eel.is/c++draft/c.math.syn). I see benefits to sticking to that order instead of defining a new one which might not be adhered to by new contributors. Nonetheless, there are things to update, e.g. //
// from main
//
floating_point hypot (arithmetic x, arithmetic y);
float hypotf(float x, float y);
long double hypotl(long double x, long double y);
double hypot(double x, double y, double z); // C++17
float hypot(float x, float y, float z); // C++17
long double hypot(long double x, long double y, long double z); // C++17
//
// from the standard
//
constexpr floating-point-type hypot(floating-point-type x, floating-point-type y);
constexpr float hypotf(float x, float y);
constexpr long double hypotl(long double x, long double y);
// [[c.math.hypot3]](https://eel.is/c++draft/c.math.hypot3), three-dimensional hypotenuse
constexpr floating-point-type hypot(floating-point-type x, floating-point-type y,
floating-point-type z);I would also include I do not have an opinion yet what to do about the comments and links therein (e.g. |
The goal is indeed to match the synopsis in the Standard to validate what we have and have not implemented.
Since we have not implemented Side note: This may not be the best way, but it's the best we got. We discussed other ideas in the past, but haven't found a better solution. |
|
Gentle ping on this -- do we want to move forward with some version of this, or close the PR? |
|
I'm going to tentatively close this since it's fairly old, please reopen if you still want to pursue this. |
|
Sorry for the late response. I won't pursue this PR, but I think the I'll make a larger cleanup for synopsis comments later. |
Currently, it's a bit hard to parse the
// C++17comments nested in the// C99group. This patch attempts to sort functions into 4 groups.fandlvariants of C89/90 functions, except for 3Dhypot.hypotand C++17 math special functions.lerp.The next group is expected to be C23, which will be added when C++ starts to merge C23 math functions.
More
arithmeticandfloating_pointare used for simplification.