12size_t hash<mpq_class>::operator()(
const mpq_class &val)
const {
13 mp_limb_t result = 2166136261;
14 size_t num_size = mpz_size(val.get_num_mpz_t());
15 size_t den_size = mpz_size(val.get_den_mpz_t());
16 const mp_limb_t *num_limbs = mpz_limbs_read(val.get_num_mpz_t());
17 const mp_limb_t *den_limbs = mpz_limbs_read(val.get_den_mpz_t());
18 for (
size_t i = 0; i < num_size; i++) {
19 result = (result * 16777619) ^ num_limbs[i];
21 for (
size_t i = 0; i < den_size; i++) {
22 result = (result * 16777619) ^ den_limbs[i];
24 return static_cast<size_t>(result);
31std::strong_ordering operator<=>(
const mpq_class &lhs,
const mpq_t &rhs) {
32 const mpq_class &rhs_class = gmp::ToMpqClass(rhs);
33 return lhs < rhs_class ? std::strong_ordering::less
34 : lhs > rhs_class ? std::strong_ordering::greater
35 : std::strong_ordering::equal;
37std::strong_ordering operator<=>(
const mpq_t &lhs,
const mpq_class &rhs) {
38 const mpq_class &lhs_class = gmp::ToMpqClass(lhs);
39 return lhs_class < rhs ? std::strong_ordering::less
40 : lhs_class > rhs ? std::strong_ordering::greater
41 : std::strong_ordering::equal;
46mpz_class floor(
const mpq_class &val) {
49 if (t == val || val > 0) {
57mpz_class ceil(
const mpq_class &val) {
60 if (t == val || val < 0) {
Global namespace for the dlinear library.