LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
number.h File Reference

Number-type abstraction for the templated API port. More...

#include <cmath>
#include <string>
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
Include dependency graph for number.h:

Go to the source code of this file.

Classes

struct  line::num_traits< double >
struct  line::num_traits< Rational >
struct  line::num_traits< Real< D > >

Namespaces

namespace  line

Typedefs

using line::Rational
using line::BigInt = boost::multiprecision::cpp_int
template<unsigned Digits10>
using line::Real = boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits10>>
using line::Real50 = Real<50>
 Precision tiers offered by the CLI's –arith real:<digits> flag.
using line::Real100 = Real<100>
using line::Real200 = Real<200>

Functions

double line::log_bigint (const BigInt &v)
 log(v) for a positive arbitrary-precision integer.
template<class T>
line::num_abs (const T &v)
template<>
double line::num_abs< double > (const double &v)
template<class T>
line::num_factorial (unsigned n)
 Factorial as a value of T.
template<class T>
line::num_pow_int (const T &base, unsigned e)
 Integer power, valid in any field (no transcendental requirement).

Detailed Description

Number-type abstraction for the templated API port.

Three arithmetic modes are exposed to callers: double - IEEE 754, what MATLAB / the JAR / native Python use today exact - arbitrary-precision rationals, no rounding at all real - fixed high-precision binary floating point

The default backends are header-only Boost.Multiprecision types (Boost Software License 1.0), so the default build carries no LGPL obligation and a redistributable Python wheel remains possible. Defining LINE_MP_USE_GMP switches the exact and real backends to GMP mpq and MPFR, which are faster but LGPL; the algorithms are unchanged, only the typedef.

Every algorithm is a template on the number type T and consults num_traits<T> for what T can do. Algorithms that need log/exp/pow assert num_traits<T>::has_transcendental at compile time, so instantiating an inherently inexact algorithm at exact arithmetic is a build error rather than a silent fallback.

Definition in file number.h.