diff options
Diffstat (limited to 'libc/utils/MPFRWrapper')
| -rw-r--r-- | libc/utils/MPFRWrapper/MPCommon.cpp | 15 | ||||
| -rw-r--r-- | libc/utils/MPFRWrapper/MPCommon.h | 1 | ||||
| -rw-r--r-- | libc/utils/MPFRWrapper/MPFRUtils.cpp | 9 | ||||
| -rw-r--r-- | libc/utils/MPFRWrapper/MPFRUtils.h | 1 |
4 files changed, 26 insertions, 0 deletions
diff --git a/libc/utils/MPFRWrapper/MPCommon.cpp b/libc/utils/MPFRWrapper/MPCommon.cpp index 77039d4bf7df..c25522077411 100644 --- a/libc/utils/MPFRWrapper/MPCommon.cpp +++ b/libc/utils/MPFRWrapper/MPCommon.cpp @@ -138,6 +138,21 @@ MPFRNumber MPFRNumber::atanh() const { return result; } +MPFRNumber MPFRNumber::atanpi() const { + MPFRNumber result(*this); +#if MPFR_VERSION >= MPFR_VERSION_NUM(4, 2, 0) + mpfr_atanpi(result.value, value, mpfr_rounding); + return result; +#else + MPFRNumber value_atan(0.0, mpfr_precision * 3); + mpfr_atan(value_atan.value, value, MPFR_RNDN); + MPFRNumber value_pi(0.0, mpfr_precision * 3); + mpfr_const_pi(value_pi.value, MPFR_RNDN); + mpfr_div(result.value, value_atan.value, value_pi.value, mpfr_rounding); + return result; +#endif +} + MPFRNumber MPFRNumber::cbrt() const { MPFRNumber result(*this); mpfr_cbrt(result.value, value, mpfr_rounding); diff --git a/libc/utils/MPFRWrapper/MPCommon.h b/libc/utils/MPFRWrapper/MPCommon.h index 47d6293c06af..25bdc9bc0025 100644 --- a/libc/utils/MPFRWrapper/MPCommon.h +++ b/libc/utils/MPFRWrapper/MPCommon.h @@ -193,6 +193,7 @@ public: MPFRNumber atan() const; MPFRNumber atan2(const MPFRNumber &b); MPFRNumber atanh() const; + MPFRNumber atanpi() const; MPFRNumber cbrt() const; MPFRNumber ceil() const; MPFRNumber cos() const; diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp index 2155f324aa8a..144a4ec25d21 100644 --- a/libc/utils/MPFRWrapper/MPFRUtils.cpp +++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp @@ -45,6 +45,8 @@ unary_operation(Operation op, InputType input, unsigned int precision, return mpfrInput.atan(); case Operation::Atanh: return mpfrInput.atanh(); + case Operation::Atanpi: + return mpfrInput.atanpi(); case Operation::Cbrt: return mpfrInput.cbrt(); case Operation::Ceil: @@ -272,6 +274,10 @@ template void explain_unary_operation_single_output_error(Operation op, double, RoundingMode); #endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE +template void explain_unary_operation_single_output_error(Operation op, + bfloat16, bfloat16, + double, RoundingMode); + template <typename T> void explain_unary_operation_two_outputs_error( Operation op, T input, const BinaryOutput<T> &libc_result, @@ -559,6 +565,9 @@ template bool compare_unary_operation_single_output(Operation, float128, long double, double, RoundingMode); #endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE +template bool compare_unary_operation_single_output(Operation, bfloat16, + bfloat16, double, + RoundingMode); template <typename T> bool compare_unary_operation_two_outputs(Operation op, T input, diff --git a/libc/utils/MPFRWrapper/MPFRUtils.h b/libc/utils/MPFRWrapper/MPFRUtils.h index e805607328f6..35d7942a2620 100644 --- a/libc/utils/MPFRWrapper/MPFRUtils.h +++ b/libc/utils/MPFRWrapper/MPFRUtils.h @@ -33,6 +33,7 @@ enum class Operation : int { Asinpi, Atan, Atanh, + Atanpi, Cbrt, Ceil, Cos, |
