5#ifndef LINE_NUM_NUMBER_H
6#define LINE_NUM_NUMBER_H
34#include <boost/multiprecision/cpp_bin_float.hpp>
35#include <boost/multiprecision/cpp_int.hpp>
38#include <boost/multiprecision/gmp.hpp>
39#include <boost/multiprecision/mpfr.hpp>
42#include <boost/math/special_functions/zeta.hpp>
60template <
class Backend, boost::multiprecision::expression_
template_option ET,
class Policy,
class Tag>
61struct zeta_initializer<boost::multiprecision::number<Backend, ET>, Policy, Tag> {
62 static void force_instantiate() {}
97 boost::multiprecision::number<boost::multiprecision::gmp_rational, boost::multiprecision::et_off>;
98using BigInt = boost::multiprecision::mpz_int;
99template <
unsigned Digits10>
100using Real = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10>>;
102using Rational = boost::multiprecision::number<boost::multiprecision::cpp_rational_backend,
103 boost::multiprecision::et_off>;
104using BigInt = boost::multiprecision::cpp_int;
105template <
unsigned Digits10>
106using Real = boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits10>>;
124 if (v == 0)
return -std::numeric_limits<double>::infinity();
126 long bits =
static_cast<long>(boost::multiprecision::msb(a)) + 1;
127 long shift = bits > 53 ? bits - 53 : 0;
129 return std::log(
static_cast<double>(mant)) +
static_cast<double>(shift) * std::log(2.0);
144 static const char*
name() {
return "double"; }
146 static double from_int(
long v) {
return static_cast<double>(v); }
148 return static_cast<double>(num) /
static_cast<double>(den);
154 static std::string
to_string(
const double& v) {
return std::to_string(v); }
162 static const char*
name() {
return "exact"; }
183 static const char*
name() {
return "real"; }
212 for (
unsigned k = 2; k <= n; ++k) f *= num_traits<T>::from_int(
static_cast<long>(k));
Conservation laws of a layered queueing network, enumerated from its structure.
T num_factorial(unsigned n)
Factorial as a value of T.
Real< 50 > Real50
Precision tiers offered by the CLI's –arith real:<digits> flag.
T num_pow_int(const T &base, unsigned e)
Integer power, valid in any field (no transcendental requirement).
boost::multiprecision::cpp_int BigInt
boost::multiprecision::number< boost::multiprecision::cpp_rational_backend, boost::multiprecision::et_off > Rational
boost::multiprecision::number< boost::multiprecision::cpp_bin_float< Digits10 > > Real
double log_bigint(const BigInt &v)
log(v) for a positive arbitrary-precision integer.
static const char * name()
static std::string numerator_str(const Rational &v)
static Rational from_int(long v)
static constexpr bool has_transcendental
static std::string to_string(const Rational &v)
static double to_double(const Rational &v)
static Rational from_rational(long num, long den)
static Rational from_double(double v)
Exact: a double is a dyadic rational, so this conversion loses nothing.
static std::string denominator_str(const Rational &v)
static double log_as_double(const Rational &v)
static constexpr bool is_exact
static std::string to_string(const Real< D > &v)
static const char * name()
static constexpr unsigned digits10
static Real< D > from_int(long v)
static Real< D > from_rational(long num, long den)
static Real< D > from_double(double v)
static constexpr bool has_transcendental
static double log_as_double(const Real< D > &v)
static constexpr bool is_exact
static double to_double(const Real< D > &v)
static double from_double(double v)
static std::string to_string(const double &v)
static constexpr bool is_exact
static double log_as_double(const double &v)
log of the value, always returned as a double.
static const char * name()
static double from_int(long v)
static double from_rational(long num, long den)
static constexpr bool has_transcendental
static double to_double(const double &v)