Math functions

template<precision_t P>
auto mpfr::abs(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

The absolute value of the argument.

template<precision_t P>
auto mpfr::fabs(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

The absolute value of the argument.

template<typename U, typename V>
sfinae_common_return_type mpfr::fmod(U const &a, U const &b, long *quotient_ptr = nullptr) noexcept

Return

The remainder of a divided by b, when the quotient is rounded toward zero. If quotient_ptr is not null, the least significant bits of the quotient are stored in *quotient_ptr.

template<typename U, typename V>
sfinae_common_return_type mpfr::remainder(U const &a, V const &b, long *quotient_ptr = nullptr) noexcept

Return

The remainder of a divided by b, when the quotient is rounded to the nearest integer. If quotient_ptr is not null, the least significant bits of the quotient are stored in *quotient_ptr.

template<typename U, typename V>
sfinae_common_return_type mpfr::remquo(U const &a, U const &b, long *quotient_ptr) noexcept

Return

The remainder of a divided by b, when the quotient is rounded to the nearest integer. If quotient_ptr is not null, the least significant bits of the quotient are stored in *quotient_ptr.

template<precision_t P>
auto mpfr::fma(mp_float_t<P> const &a, mp_float_t<P> const &b, mp_float_t<P> const &c) noexcept -> mp_float_t<P>

Return

Fused multiply add operation. a * b + c

template<typename U, typename V>
sfinae_common_return_type mpfr::fmax(U const &a, V const &b) noexcept

Return

Larger of the two arguments. If one of the arguments is NaN, returns the other argument.

template<typename U, typename V>
sfinae_common_return_type mpfr::fmin(U const &a, V const &b) noexcept

Return

Smaller of the two arguments. If one of the arguments is NaN, returns the other argument.

template<typename U, typename V>
sfinae_common_return_type mpfr::fdim(U const &a, V const &b) noexcept

Return

Positive difference of the two arguments. If one of the arguments is NaN, returns NaN.

template<precision_t P>
auto mpfr::exp(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Exponential of the argument with base \(e := e^{\text{arg}}\).

template<precision_t P>
auto mpfr::exp2(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Exponential of the argument with base \(2 := 2^{\text{arg}}\).

template<precision_t P>
auto mpfr::exp10(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Exponential of the argument with base \(10 := 10^{\text{arg}}\).

template<precision_t P>
auto mpfr::expm1(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Exponential of the argument with base \(e\) minus 1 \(:= e^{\text{arg}} - 1\).

template<precision_t P>
auto mpfr::log(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Logarithm of the argument to base \(e := \log_e(\text{arg})\).

template<precision_t P>
auto mpfr::log10(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Logarithm of the argument to base \(10 := \log_10(\text{arg})\).

template<precision_t P>
auto mpfr::log2(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Logarithm of the argument to base \(2 := \log_2(\text{arg})\).

template<precision_t P>
auto mpfr::log1p(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Logarithm to base \(e\) of \(1\) plus the argument \(:=\log_e(1 + \text{arg})\).

template<typename U, typename V>
sfinae_common_return_type mpfr::pow(U const &base, V const &exponent) noexcept

Return

The base to the power of the exponent.

template<precision_t P>
auto mpfr::sqrt(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Square root of the argument.

template<precision_t P>
auto mpfr::cbrt(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Cubic root of the argument.

template<typename U, typename V>
sfinae_common_return_type mpfr::hypot(U const &x, V const &y) noexcept

Return

Square root of the sum of the squares of the arguments.

template<precision_t P>
auto mpfr::sin(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Sine of the argument.

template<precision_t P>
auto mpfr::cos(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Cosine of the argument.

template<precision_t P>
auto mpfr::tan(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Tangent of the argument.

template<precision_t P>
auto mpfr::asin(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Inverse of the sine of the argument.

template<precision_t P>
auto mpfr::acos(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Inverse of the cosine of the argument.

template<precision_t P>
auto mpfr::atan(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Inverse of the tangent of the argument.

template<typename U, typename V>
sfinae_common_return_type mpfr::atan2(U const &y, V const &x) noexcept

Return

Arc tangent of y/x in the correct quadrant depending on the signs of the arguments.

template<precision_t P>
auto mpfr::sinh(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Hyperbolic sine of the argument.

template<precision_t P>
auto mpfr::cosh(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Hyperbolic cosine of the argument.

template<precision_t P>
auto mpfr::tanh(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Hyperbolic tangent of the argument.

template<precision_t P>
auto mpfr::asinh(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Inverse of the hyperbolic sine of the argument.

template<precision_t P>
auto mpfr::acosh(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Inverse of the hyperbolic cosine of the argument.

template<precision_t P>
auto mpfr::atanh(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Inverse of the hyperbolic tangent of the argument.

template<precision_t P>
auto mpfr::erf(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Error function. [{erf}(x) = {2}{}^x e^{-t^2}{d}t]

template<precision_t P>
auto mpfr::erfc(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Complementary error function. [{erfc}(x) = 1 - {2}{}^x e^{-t^2}{d}t]

template<precision_t P>
auto mpfr::tgamma(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Gamma function. [(x) = ^ t^{x-1}e^{-t}{d}t]

template<precision_t P>
auto mpfr::lgamma(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Natural log of the absolute value of the gamma function.

template<typename U, typename V>
sfinae_common_return_type mpfr::beta(U const &x, V const &y) noexcept

Return

Beta function. [{B}(x, y) = ^1 t^{x-1}(1-t)^{y-1} {d}t]

template<precision_t P>
auto mpfr::expint(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Exponential integral. [{Ei}(x) = {-x}^ {e^{-t}}{t}{d}t]

template<precision_t P>
auto mpfr::riemann_zeta(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Zeta function.

template<precision_t P>
auto mpfr::ceil(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Next higher or equal representable integer.

template<precision_t P>
auto mpfr::floor(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Next lower or equal representable integer.

template<precision_t P>
auto mpfr::trunc(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Nearest representable integer, rounding toward zero.

template<precision_t P>
auto mpfr::round(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Nearest representable integer, rounding away from zero.

template<precision_t P>
auto mpfr::nearbyint(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Nearby int using the current rounding mode.

template<precision_t P>
auto mpfr::rint(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

Nearby int using the current rounding mode.

template<precision_t P>
auto mpfr::frexp(mp_float_t<P> const &arg, mpfr_prec_t *exp) noexcept -> mp_float_t<P>

Decomposes arg into a normalized fraction and a power of two.

Return

Normalized fraction. The power of two exponent is stored in *exp.

template<precision_t P>
auto mpfr::ldexp(mp_float_t<P> const &arg, long exp) noexcept -> mp_float_t<P>

Return

arg multiplied by two to the power of exp

template<precision_t P>
auto mpfr::modf(mp_float_t<P> const &arg, mp_float_t<P> *iptr) noexcept -> mp_float_t<P>

Return

The fractional part of the argument. The value of the integral part is stored in *iptr.

template<precision_t P>
auto mpfr::scalbn(mp_float_t<P> const &arg, long exp) noexcept -> mp_float_t<P>

Return

arg multiplied by two to the power of exp

template<precision_t P>
auto mpfr::scalbln(mp_float_t<P> const &arg, long exp) noexcept -> mp_float_t<P>

Return

arg multiplied by two to the power of exp

template<precision_t P>
auto mpfr::ilogb(mp_float_t<P> const &arg) noexcept -> mpfr_exp_t

Return

The unbiased exponent of the argument. \(\log_2(\lvert\text{arg}\rvert)\)

template<precision_t P>
auto mpfr::logb(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

The unbiased exponent of the argument. \(\log_2(\lvert\text{arg}\rvert)\)

template<typename U, typename V>
sfinae_common_return_type mpfr::nextafter(U const &from, V const &to) noexcept

Return

The next representable number of from in the direction of to.

template<typename U, typename V>
sfinae_common_return_type mpfr::nexttoward(U const &from, V const &to) noexcept

Return

The next representable number of from in the direction of to.

template<precision_t P>
auto mpfr::nextabove(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

The next representable number of from in the direction of \(+\infty\).

template<precision_t P>
auto mpfr::nextbelow(mp_float_t<P> const &arg) noexcept -> mp_float_t<P>

Return

The next representable number of from in the direction of \(-\infty\).

template<typename U, typename V>
sfinae_first_param_type mpfr::copysign(U const &a, V const &b) noexcept

Return

a with the sign copied from b.

template<precision_t P>
auto mpfr::fpclassify(mp_float_t<P> const &arg) noexcept -> fp_class_e

Return

Category of the argument.

template<precision_t P>
auto mpfr::iszero(mp_float_t<P> const &arg) noexcept -> bool

Return

true if the argument is zero, false otherwise.

template<precision_t P>
auto mpfr::isfinite(mp_float_t<P> const &arg) noexcept -> bool

Return

true if the argument is finite, false otherwise.

template<precision_t P>
auto mpfr::isinf(mp_float_t<P> const &arg) noexcept -> bool

Return

true if the argument is infinite, false otherwise.

template<precision_t P>
auto mpfr::isnan(mp_float_t<P> const &arg) noexcept -> bool

Return

true if the argument is a NaN, false, otherwise.

template<precision_t P>
auto mpfr::isnormal(mp_float_t<P> const &arg) noexcept -> bool

Return

true if the argument is normal. (always true)

template<precision_t P>
auto mpfr::signbit(mp_float_t<P> const &arg) noexcept -> bool

Return

true if the argument is negative, false otherwise.

If the argument is a NaN, detects whether the sign bit is set.

template<typename U, typename V>
sfinae_bool mpfr::isgreater(U const &a, U const &b)

Return

true if \(a > b\), false otherwise.

template<typename U, typename V>
sfinae_bool mpfr::isgreaterequal(U const &a, V const &b) noexcept

Return

true if \(a \geq b\), false otherwise.

template<typename U, typename V>
sfinae_bool mpfr::isless(U const &a, V const &b) noexcept

Return

true if \(a < b\), false otherwise.

template<typename U, typename V>
sfinae_bool mpfr::islessequal(U const &a, V const &b) noexcept

Return

true if \(a \leq b\), false otherwise.

template<typename U, typename V>
sfinae_bool mpfr::islessgreater(U const &a, V const &b) noexcept

Return

true if \(a < b\) or \(a > b\), false otherwise.

template<typename U, typename V>
sfinae_bool mpfr::isunordered(U const &a, V const &b) noexcept

Return

true if a or b is NaN, false otherwise.

template<precision_t P>
struct mpfr::sin_cos_result_t

Pair of the sine and cosine.

Public Members

mp_float_t<P> sin
mp_float_t<P> cos
template<precision_t P>
struct mpfr::sinh_cosh_result_t

Pair of the hyperbolic sine and cosine.

Public Members

mp_float_t<P> sinh
mp_float_t<P> cosh
template<precision_t P>
auto mpfr::sin_cos(mp_float_t<P> const &arg) noexcept -> sin_cos_result_t<P>

Return

Sine and cosine of the argument.

template<precision_t P>
auto mpfr::sinh_cosh(mp_float_t<P> const &arg) noexcept -> sinh_cosh_result_t<P>

Return

Hyperbolic sine and cosine of the argument.

template<precision_t P>
auto mpfr::pi_c() noexcept -> mp_float_t<P> const&

Return

\(\pi\) constant.