3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

Add API for extracting numerator/denominator of RCF numerals. Add field to store the original isolating interval before refinement.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-01-14 14:20:52 -08:00
parent 991a1528cd
commit 799fe073db
4 changed files with 101 additions and 47 deletions

View file

@ -290,4 +290,17 @@ extern "C" {
Z3_CATCH_RETURN("");
}
void Z3_API Z3_rcf_get_numerator_denominator(Z3_context c, Z3_rcf_num a, Z3_rcf_num * n, Z3_rcf_num * d) {
Z3_TRY;
LOG_Z3_rcf_get_numerator_denominator(c, a, n, d);
RESET_ERROR_CODE();
reset_rcf_cancel(c);
rcnumeral _n, _d;
rcfm(c).clean_denominators(to_rcnumeral(a), _n, _d);
*n = from_rcnumeral(_n);
*d = from_rcnumeral(_d);
RETURN_Z3_rcf_get_numerator_denominator;
Z3_CATCH;
}
};

View file

@ -154,3 +154,8 @@ class RCFNum:
v = _to_rcfnum(other, self.ctx)
return Z3_rcf_neq(self.ctx_ref(), self.num, v.num)
def split(self):
n = (RCFNumObj * 1)()
d = (RCFNumObj * 1)()
Z3_rcf_get_numerator_denominator(self.ctx_ref(), self.num, n, d)
return (RCFNum(n[0], self.ctx), RCFNum(d[0], self.ctx))

View file

@ -184,6 +184,14 @@ extern "C" {
*/
Z3_string Z3_API Z3_rcf_num_to_decimal_string(__in Z3_context c, __in Z3_rcf_num a, __in unsigned prec);
/**
\brief Extract the "numerator" and "denominator" of the given RCF numeral.
We have that a = n/d, moreover n and d are not represented using rational functions.
def_API('Z3_rcf_get_numerator_denominator', VOID, (_in(CONTEXT), _in(RCF_NUM), _out(RCF_NUM), _out(RCF_NUM)))
*/
void Z3_API Z3_rcf_get_numerator_denominator(__in Z3_context c, __in Z3_rcf_num a, __out Z3_rcf_num * n, __out Z3_rcf_num * d);
#ifdef __cplusplus
};
#endif // __cplusplus