carl
24.04
Computer ARithmetic Library
|
The higher-level datastructures in CArL are templated with respect to their underlying number type and can therefore be used with any number type that fulfills some common requirements. This is the case, for example, for carl::Term, carl::MultivariatePolynomial, carl::UnivariatePolynomial or carl::Interval objects.
Everything related to number types resides in the /carl/numbers/ directory. For each group of supported number types T
, a folder adaption_T
exists that contains the following:
From the outside, that is also the rest of the CArL library, only the central numbers/numbers.h shall be included. This file includes all available adaptions and takes care of disabling adaptions if the respective library is unavailable.
As of now, we provide adaptions of the following types:
Note that these adaptions may not fully implement all methods described below, but only to some extend that is used. Finishing these adaptions is work in progress.
The following interface should be implemented for every number type T
.
carl::constant_zero<T>
and carl::constant_one<T>
if the generic definition from carl/numbers/constants.h does not fit.std::hash<T>
T operator+(const T&, const T&)
and T& operator+=(const T&, const T&)
T operator-(const T&, const T&)
and T& operator-=(const T&, const T&)
T operator-(const T&)
T operator*(const T&, const T&)
and T& operator*=(const T&, const T&)
T& operator=(const T&)
bool carl::is_zero(const T&)
and bool carl::is_one(const T&)
carl::is_rational_type<T>::value
:carl::get_num(const T&)
and carl::get_denom(const T&)
T carl::rationalize(double)
bool carl::is_integer(const T&)
std::size_t carl::bitsize(const T&)
double carl::to_double(const T&)
and I carl::to_int<I>(const T&)
for some integer types I
.T carl::abs(const T&)
T carl::floor(const T&)
and T carl::ceil(const T&)
carl::is_integer_type<T>::value
:T carl::gcd(const T&, const T&)
and T carl::lcm(const T&, const T&)
T carl::mod(const T&, const T&)
T carl::pow(const T&, unsigned)
std::pair<T,T> carl::sqrt(const T&)
where the result represents an interval containing the exact result.T carl::div(const T&, const T&)
asserting that exact division is possible.T carl::quotient(const T&, const T&)
and T carl::remainder(const T&, const T&)