1 #include <isl/val_gmp.h>
2 #include <isl_val_private.h>
4 /* Return a reference to an isl_val representing the integer "z".
6 __isl_give isl_val
*isl_val_int_from_gmp(isl_ctx
*ctx
, mpz_t z
)
10 v
= isl_val_alloc(ctx
);
15 isl_int_set_si(v
->d
, 1);
20 /* Return a reference to an isl_val representing the rational value "n"/"d".
22 __isl_give isl_val
*isl_val_from_gmp(isl_ctx
*ctx
, const mpz_t n
, const mpz_t d
)
26 v
= isl_val_alloc(ctx
);
33 return isl_val_normalize(v
);
36 /* Extract the numerator of a rational value "v" in "z".
38 * If "v" is not a rational value, then the result is undefined.
40 int isl_val_get_num_gmp(__isl_keep isl_val
*v
, mpz_t z
)
44 if (!isl_val_is_rat(v
))
45 isl_die(isl_val_get_ctx(v
), isl_error_invalid
,
46 "expecting rational value", return -1);
51 /* Extract the denominator of a rational value "v" in "z".
53 * If "v" is not a rational value, then the result is undefined.
55 int isl_val_get_den_gmp(__isl_keep isl_val
*v
, mpz_t z
)
59 if (!isl_val_is_rat(v
))
60 isl_die(isl_val_get_ctx(v
), isl_error_invalid
,
61 "expecting rational value", return -1);