The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

62 lines
2.8 KiB

4 weeks ago
  1. Numbers {#numbers}
  2. ====================
  3. 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.
  4. This is the case, for example, for carl::Term, carl::MultivariatePolynomial, carl::UnivariatePolynomial or carl::Interval objects.
  5. Everything related to number types resides in the /carl/numbers/ directory.
  6. For each group of supported number types `T`, a folder `adaption_T` exists that contains the following:
  7. - Include of the library (if necessary)
  8. - Type traits according to @ref typetraits.
  9. - Static constants for zero and one.
  10. - Operations to fulfill our common interface.
  11. From the outside, that is also the rest of the CArL library, only the central numbers/numbers.h shall be included.
  12. This file includes all available adaptions and takes care of disabling adaptions if the respective library is unavailable.
  13. Adaptions
  14. ---------
  15. As of now, we provide adaptions of the following types:
  16. - CLN (cln::cl_I and cln::cl_RA).
  17. - FLOAT_T<mpfr_t>, our own wrapper for mpfr_t
  18. - GMPxx, the C++ interface of GMP.
  19. - Native datatypes as defined by @cite C++Standard
  20. - Z3 rationals.
  21. Note that these adaptions may not fully implement all methods described below, but only to some extend that is used.
  22. Finishing these adaptions is work in progress.
  23. Interface
  24. ---------
  25. The following interface should be implemented for every number type `T`.
  26. - @ref typetraits if applicable.
  27. - `carl::constant_zero<T>` and `carl::constant_one<T>` if the generic definition from carl/numbers/constants.h does not fit.
  28. - Specialization of `std::hash<T>`
  29. - Arithmetic operators:
  30. - `T operator+(const T&, const T&)` and `T& operator+=(const T&, const T&)`
  31. - `T operator-(const T&, const T&)` and `T& operator-=(const T&, const T&)`
  32. - `T operator-(const T&)`
  33. - `T operator*(const T&, const T&)` and `T& operator*=(const T&, const T&)`
  34. - `T& operator=(const T&)`
  35. - `bool carl::isZero(const T&)` and `bool carl::isOne(const T&)`
  36. - If `carl::is_rational<T>::value`:
  37. - `carl::getNum(const T&)` and `carl::getDenom(const T&)`
  38. - `T carl::rationalize(double)`
  39. - `bool carl::isInteger(const T&)`
  40. - `std::size_t carl::bitsize(const T&)`
  41. - `double carl::toDouble(const T&)` and `I carl::toInt<I>(const T&)` for some integer types `I`.
  42. - `T carl::abs(const T&)`
  43. - `T carl::floor(const T&)` and `T carl::ceil(const T&)`
  44. - If `carl::is_integer<T>::value`:
  45. - `T carl::gcd(const T&, const T&)` and `T carl::lcm(const T&, const T&)`
  46. - `T carl::mod(const T&, const T&)`
  47. - `T carl::pow(const T&, unsigned)`
  48. - `std::pair<T,T> carl::sqrt(const T&)` where the result represents an interval containing the exact result.
  49. - `T carl::div(const T&, const T&)` asserting that exact division is possible.
  50. - `T carl::quotient(const T&, const T&)` and `T carl::remainder(const T&, const T&)`