mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 10:55:50 +00:00
Extract defining components of algebraic number via C and C++ API (#3321)
* First steps toward adding Julia bindings * Simplifications * Streamlining * Friends of tactic and probe * Add missing functions * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Changes for CxxWrap v0.9.0 * Wrap enumeration and tuple sort * Wrap z3::fixedpoint * Wrap z3::optimize * Wrap missing functions * Fix aux types * Add some missing functions * Revert "Update azure-pipelines.yml for Azure Pipelines" This reverts commit5aab9f9240
. * Revert "Update azure-pipelines.yml for Azure Pipelines" This reverts commitcfccd7ca2c
. * Revert "Update azure-pipelines.yml for Azure Pipelines" This reverts commitf24740c595
. * Revert "Update azure-pipelines.yml for Azure Pipelines" This reverts commit592499eaa0
. * Checkout current version of pipeline * Build Julia bindings on macOS * Extract components of algebraic number * Add type to C API function name * Remove blank line * Typo in doc * Return Z3_ast_vector containing coefficients
This commit is contained in:
parent
1c5283f3a4
commit
de9bc930e9
6 changed files with 160 additions and 72 deletions
|
@ -418,4 +418,36 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast_vector Z3_API Z3_algebraic_get_poly(Z3_context c, Z3_ast a) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_algebraic_get_poly(c, a);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_IS_ALGEBRAIC(a, 0);
|
||||
algebraic_numbers::manager & _am = am(c);
|
||||
algebraic_numbers::anum const & av = get_irrational(c, a);
|
||||
scoped_mpz_vector coeffs(_am.qm());
|
||||
_am.get_polynomial(av, coeffs);
|
||||
api::context * _c = mk_c(c);
|
||||
sort * s = _c->m().mk_sort(_c->get_arith_fid(), REAL_SORT);
|
||||
Z3_ast_vector_ref* result = alloc(Z3_ast_vector_ref, *_c, _c->m());
|
||||
mk_c(c)->save_object(result);
|
||||
for (unsigned i = 0; i < coeffs.size(); i++) {
|
||||
rational r(coeffs[i]);
|
||||
expr * a = _c->mk_numeral_core(r, s);
|
||||
result->m_ast_vector.push_back(a);
|
||||
}
|
||||
RETURN_Z3(of_ast_vector(result));
|
||||
Z3_CATCH_RETURN(nullptr);
|
||||
}
|
||||
|
||||
unsigned Z3_API Z3_algebraic_get_i(Z3_context c, Z3_ast a) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_algebraic_get_i(c, a);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_IS_ALGEBRAIC(a, 0);
|
||||
algebraic_numbers::manager & _am = am(c);
|
||||
algebraic_numbers::anum const & av = get_irrational(c, a);
|
||||
return _am.get_i(av);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue