mirror of
https://github.com/Z3Prover/z3
synced 2025-05-01 21:05:52 +00:00
Merge branch 'master' of https://github.com/z3prover/z3 into polysat
This commit is contained in:
commit
21baa2a70a
462 changed files with 2877 additions and 2908 deletions
|
@ -40,7 +40,7 @@ typename symbolic_automata<T, M>::automaton_t* symbolic_automata<T, M>::mk_total
|
|||
for (unsigned j = 0; j < mvs.size(); ++j) {
|
||||
vs.push_back(mvs[j].t());
|
||||
}
|
||||
ref_t cond(m_ba.mk_not(m_ba.mk_or(vs.size(), vs.c_ptr())), m);
|
||||
ref_t cond(m_ba.mk_not(m_ba.mk_or(vs.size(), vs.data())), m);
|
||||
lbool is_sat = m_ba.is_sat(cond);
|
||||
if (is_sat == l_undef) {
|
||||
return nullptr;
|
||||
|
|
|
@ -175,7 +175,7 @@ void grobner::display_monomials(std::ostream & out, unsigned num_monomials, mono
|
|||
}
|
||||
|
||||
void grobner::display_equation(std::ostream & out, equation const & eq) const {
|
||||
display_monomials(out, eq.m_monomials.size(), eq.m_monomials.c_ptr());
|
||||
display_monomials(out, eq.m_monomials.size(), eq.m_monomials.data());
|
||||
out << " = 0\n";
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ void grobner::assert_eq(expr * eq, v_dependency * ex) {
|
|||
new_c = m_util.mk_numeral(c, is_int);
|
||||
monomials.push_back(new_c);
|
||||
}
|
||||
assert_eq_0(monomials.size(), monomials.c_ptr(), ex);
|
||||
assert_eq_0(monomials.size(), monomials.data(), ex);
|
||||
}
|
||||
|
||||
void grobner::assert_monomial_tautology(expr * m) {
|
||||
|
@ -424,7 +424,7 @@ bool grobner::is_eq_monomial_body(monomial const * m1, monomial const * m2) {
|
|||
\remark This method assumes the monomials are sorted.
|
||||
*/
|
||||
void grobner::merge_monomials(ptr_vector<monomial> & monomials) {
|
||||
TRACE("grobner", tout << "before merging monomials:\n"; display_monomials(tout, monomials.size(), monomials.c_ptr()); tout << "\n";);
|
||||
TRACE("grobner", tout << "before merging monomials:\n"; display_monomials(tout, monomials.size(), monomials.data()); tout << "\n";);
|
||||
unsigned j = 0;
|
||||
unsigned sz = monomials.size();
|
||||
if (sz == 0)
|
||||
|
@ -456,7 +456,7 @@ void grobner::merge_monomials(ptr_vector<monomial> & monomials) {
|
|||
j++;
|
||||
monomials.shrink(j);
|
||||
del_monomials(to_delete);
|
||||
TRACE("grobner", tout << "after merging monomials:\n"; display_monomials(tout, monomials.size(), monomials.c_ptr()); tout << "\n";);
|
||||
TRACE("grobner", tout << "after merging monomials:\n"; display_monomials(tout, monomials.size(), monomials.data()); tout << "\n";);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -527,7 +527,7 @@ bool grobner::is_subset(monomial const * m1, monomial const * m2, ptr_vector<exp
|
|||
TRACE("grobner",
|
||||
tout << "monomail: "; display_monomial(tout, *m1); tout << " is a subset of ";
|
||||
display_monomial(tout, *m2); tout << "\n";
|
||||
tout << "rest: "; display_vars(tout, rest.size(), rest.c_ptr()); tout << "\n";);
|
||||
tout << "rest: "; display_vars(tout, rest.size(), rest.data()); tout << "\n";);
|
||||
return true;
|
||||
}
|
||||
if (i2 >= sz2)
|
||||
|
@ -565,8 +565,8 @@ void grobner::mul_append(unsigned start_idx, equation const * source, rational c
|
|||
monomial * new_m = alloc(monomial);
|
||||
new_m->m_coeff = m->m_coeff;
|
||||
new_m->m_coeff *= coeff;
|
||||
new_m->m_vars.append(m->m_vars.size(), m->m_vars.c_ptr());
|
||||
new_m->m_vars.append(vars.size(), vars.c_ptr());
|
||||
new_m->m_vars.append(m->m_vars.size(), m->m_vars.data());
|
||||
new_m->m_vars.append(vars.size(), vars.data());
|
||||
for (expr* e : new_m->m_vars)
|
||||
m_manager.inc_ref(e);
|
||||
std::stable_sort(new_m->m_vars.begin(), new_m->m_vars.end(), m_var_lt);
|
||||
|
@ -652,7 +652,7 @@ grobner::equation * grobner::simplify(equation const * source, equation * target
|
|||
}
|
||||
if (simplified) {
|
||||
target->m_monomials.shrink(j);
|
||||
target->m_monomials.append(new_monomials.size(), new_monomials.c_ptr());
|
||||
target->m_monomials.append(new_monomials.size(), new_monomials.data());
|
||||
simplify(target);
|
||||
}
|
||||
}
|
||||
|
@ -857,8 +857,8 @@ void grobner::superpose(equation * eq1, equation * eq2) {
|
|||
rest2.reset();
|
||||
if (unify(eq1->m_monomials[0], eq2->m_monomials[0], rest1, rest2)) {
|
||||
TRACE("grobner", tout << "superposing:\n"; display_equation(tout, *eq1); display_equation(tout, *eq2);
|
||||
tout << "rest1: "; display_vars(tout, rest1.size(), rest1.c_ptr()); tout << "\n";
|
||||
tout << "rest2: "; display_vars(tout, rest2.size(), rest2.c_ptr()); tout << "\n";);
|
||||
tout << "rest1: "; display_vars(tout, rest1.size(), rest1.data()); tout << "\n";
|
||||
tout << "rest2: "; display_vars(tout, rest2.size(), rest2.data()); tout << "\n";);
|
||||
ptr_vector<monomial> & new_monomials = m_tmp_monomials;
|
||||
new_monomials.reset();
|
||||
mul_append(1, eq1, eq2->m_monomials[0]->m_coeff, rest2, new_monomials);
|
||||
|
@ -866,7 +866,7 @@ void grobner::superpose(equation * eq1, equation * eq2) {
|
|||
c.neg();
|
||||
mul_append(1, eq2, c, rest1, new_monomials);
|
||||
simplify(new_monomials);
|
||||
TRACE("grobner", tout << "resulting monomials: "; display_monomials(tout, new_monomials.size(), new_monomials.c_ptr()); tout << "\n";);
|
||||
TRACE("grobner", tout << "resulting monomials: "; display_monomials(tout, new_monomials.size(), new_monomials.data()); tout << "\n";);
|
||||
if (new_monomials.empty())
|
||||
return;
|
||||
m_num_new_equations++;
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
public:
|
||||
unsigned get_num_monomials() const { return m_monomials.size(); }
|
||||
monomial const * get_monomial(unsigned idx) const { return m_monomials[idx]; }
|
||||
monomial * const * get_monomials() const { return m_monomials.c_ptr(); }
|
||||
monomial * const * get_monomials() const { return m_monomials.data(); }
|
||||
v_dependency * get_dependency() const { return m_dep; }
|
||||
unsigned hash() const { return m_bidx; }
|
||||
bool is_linear_combination() const { return m_lc; }
|
||||
|
|
|
@ -502,7 +502,7 @@ namespace dd {
|
|||
unsigned_vector& vars;
|
||||
hash(unsigned_vector& vars):vars(vars) {}
|
||||
bool operator()(mon const& m) const {
|
||||
return unsigned_ptr_hash(vars.c_ptr() + m.offset, m.sz, 1);
|
||||
return unsigned_ptr_hash(vars.data() + m.offset, m.sz, 1);
|
||||
};
|
||||
};
|
||||
struct eq {
|
||||
|
@ -539,7 +539,7 @@ namespace dd {
|
|||
for (pdd const& p : eqs) {
|
||||
for (auto const& m : p) {
|
||||
if (m.vars.size() <= 1) continue;
|
||||
insert_mon(m.vars.size(), m.vars.c_ptr());
|
||||
insert_mon(m.vars.size(), m.vars.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -572,7 +572,7 @@ namespace dd {
|
|||
}
|
||||
unsigned n = m.vars.size();
|
||||
mon mm(n, vars.size());
|
||||
vars.append(n, m.vars.c_ptr());
|
||||
vars.append(n, m.vars.data());
|
||||
VERIFY(mon2idx.find(mm, mm));
|
||||
vars.shrink(vars.size() - n);
|
||||
row.set(mm.index);
|
||||
|
|
|
@ -225,7 +225,7 @@ public:
|
|||
|
||||
void insert(Key const* keys, Value const& val) {
|
||||
++m_stats.m_num_inserts;
|
||||
insert(m_root, num_keys(), keys, m_keys.c_ptr(), val);
|
||||
insert(m_root, num_keys(), keys, m_keys.data(), val);
|
||||
#if 0
|
||||
if (m_stats.m_num_inserts == (1 << m_do_reshuffle)) {
|
||||
m_do_reshuffle++;
|
||||
|
@ -364,7 +364,7 @@ public:
|
|||
}
|
||||
}
|
||||
Key const* keys() {
|
||||
return m_keys.c_ptr();
|
||||
return m_keys.data();
|
||||
}
|
||||
|
||||
Value const& value() const {
|
||||
|
@ -532,7 +532,7 @@ private:
|
|||
}
|
||||
verbose_stream() << " |-> " << it.value() << "\n";);
|
||||
|
||||
insert(new_root, num_keys(), it.keys(), sorted_keys.c_ptr(), it.value());
|
||||
insert(new_root, num_keys(), it.keys(), sorted_keys.data(), it.value());
|
||||
}
|
||||
del_node(m_root);
|
||||
m_root = new_root;
|
||||
|
|
|
@ -773,7 +773,7 @@ unsigned hilbert_basis::get_num_vars() const {
|
|||
}
|
||||
|
||||
hilbert_basis::values hilbert_basis::vec(offset_t offs) const {
|
||||
return values(m_ineqs.size(), m_store.c_ptr() + offs.m_offset);
|
||||
return values(m_ineqs.size(), m_store.data() + offs.m_offset);
|
||||
}
|
||||
|
||||
void hilbert_basis::init_basis() {
|
||||
|
|
|
@ -61,7 +61,7 @@ class emonics {
|
|||
|
||||
unsigned operator()(lpvar v) const {
|
||||
auto const& vec = v != UINT_MAX? em.m_monics[em.m_var2index[v]].rvars() : em.m_find_key;
|
||||
return string_hash(reinterpret_cast<char const*>(vec.c_ptr()), sizeof(lpvar)*vec.size(), 10);
|
||||
return string_hash(reinterpret_cast<char const*>(vec.data()), sizeof(lpvar)*vec.size(), 10);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
\brief create a monic from an equality v := vs
|
||||
*/
|
||||
void add(lpvar v, unsigned sz, lpvar const* vs);
|
||||
void add(lpvar v, svector<lpvar> const& vs) { add(v, vs.size(), vs.c_ptr()); }
|
||||
void add(lpvar v, svector<lpvar> const& vs) { add(v, vs.size(), vs.data()); }
|
||||
void add(lpvar v, lpvar x, lpvar y) { lpvar vs[2] = { x, y }; add(v, 2, vs); }
|
||||
void add(lpvar v, lpvar x, lpvar y, lpvar z) { lpvar vs[3] = { x, y, z }; add(v, 3, vs); }
|
||||
|
||||
|
|
|
@ -345,8 +345,8 @@ public:
|
|||
return degree;
|
||||
}
|
||||
nex const* operator[](unsigned j) const { return m_children[j]; }
|
||||
const nex * const* begin() const { return m_children.c_ptr(); }
|
||||
const nex * const* end() const { return m_children.c_ptr() + m_children.size(); }
|
||||
const nex * const* begin() const { return m_children.data(); }
|
||||
const nex * const* end() const { return m_children.data() + m_children.size(); }
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
void sort() override {
|
||||
|
|
|
@ -120,13 +120,13 @@ struct solver::imp {
|
|||
for (auto v : m.vars()) {
|
||||
vars.push_back(lp2nl(v));
|
||||
}
|
||||
polynomial::monomial_ref m1(pm.mk_monomial(vars.size(), vars.c_ptr()), pm);
|
||||
polynomial::monomial_ref m1(pm.mk_monomial(vars.size(), vars.data()), pm);
|
||||
polynomial::monomial_ref m2(pm.mk_monomial(lp2nl(m.var()), 1), pm);
|
||||
polynomial::monomial * mls[2] = { m1, m2 };
|
||||
polynomial::scoped_numeral_vector coeffs(pm.m());
|
||||
coeffs.push_back(mpz(1));
|
||||
coeffs.push_back(mpz(-1));
|
||||
polynomial::polynomial_ref p(pm.mk_polynomial(2, coeffs.c_ptr(), mls), pm);
|
||||
polynomial::polynomial_ref p(pm.mk_polynomial(2, coeffs.data(), mls), pm);
|
||||
polynomial::polynomial* ps[1] = { p };
|
||||
bool even[1] = { false };
|
||||
nlsat::literal lit = m_nlsat->mk_ineq_literal(nlsat::atom::kind::EQ, 1, ps, even);
|
||||
|
@ -151,7 +151,7 @@ struct solver::imp {
|
|||
coeffs.push_back(den * kv.first);
|
||||
}
|
||||
rhs *= den;
|
||||
polynomial::polynomial_ref p(pm.mk_linear(sz, coeffs.c_ptr(), vars.c_ptr(), -rhs), pm);
|
||||
polynomial::polynomial_ref p(pm.mk_linear(sz, coeffs.data(), vars.data(), -rhs), pm);
|
||||
polynomial::polynomial* ps[1] = { p };
|
||||
bool is_even[1] = { false };
|
||||
nlsat::literal lit;
|
||||
|
@ -216,7 +216,7 @@ struct solver::imp {
|
|||
}
|
||||
coeffs.push_back(-den);
|
||||
polynomial::manager& pm = m_nlsat->pm();
|
||||
polynomial::polynomial_ref p(pm.mk_linear(coeffs.size(), coeffs.c_ptr(), vars.c_ptr(), rational(0)), pm);
|
||||
polynomial::polynomial_ref p(pm.mk_linear(coeffs.size(), coeffs.data(), vars.data(), rational(0)), pm);
|
||||
polynomial::polynomial* ps[1] = { p };
|
||||
bool is_even[1] = { false };
|
||||
nlsat::literal lit = m_nlsat->mk_ineq_literal(nlsat::atom::kind::EQ, 1, ps, is_even);
|
||||
|
|
|
@ -554,8 +554,8 @@ namespace algebraic_numbers {
|
|||
else {
|
||||
scoped_upoly & up_sqf = m_isolate_tmp3;
|
||||
up_sqf.reset();
|
||||
upm().square_free(up.size(), up.c_ptr(), up_sqf);
|
||||
TRACE("algebraic", upm().display(tout, up_sqf.size(), up_sqf.c_ptr()); tout << "\n";);
|
||||
upm().square_free(up.size(), up.data(), up_sqf);
|
||||
TRACE("algebraic", upm().display(tout, up_sqf.size(), up_sqf.data()); tout << "\n";);
|
||||
r.push_back(up_sqf, 1);
|
||||
return false;
|
||||
}
|
||||
|
@ -610,10 +610,10 @@ namespace algebraic_numbers {
|
|||
factors & fs = m_isolate_factors;
|
||||
fs.reset();
|
||||
bool full_fact;
|
||||
if (upm().has_zero_roots(up.size(), up.c_ptr())) {
|
||||
if (upm().has_zero_roots(up.size(), up.data())) {
|
||||
roots.push_back(numeral());
|
||||
scoped_upoly & nz_up = m_isolate_tmp2;
|
||||
upm().remove_zero_roots(up.size(), up.c_ptr(), nz_up);
|
||||
upm().remove_zero_roots(up.size(), up.data(), nz_up);
|
||||
full_fact = factor(nz_up, fs);
|
||||
}
|
||||
else {
|
||||
|
@ -640,7 +640,7 @@ namespace algebraic_numbers {
|
|||
continue;
|
||||
}
|
||||
SASSERT(m_isolate_roots.empty() && m_isolate_lowers.empty() && m_isolate_uppers.empty());
|
||||
upm().sqf_isolate_roots(f.size(), f.c_ptr(), bqm(), m_isolate_roots, m_isolate_lowers, m_isolate_uppers);
|
||||
upm().sqf_isolate_roots(f.size(), f.data(), bqm(), m_isolate_roots, m_isolate_lowers, m_isolate_uppers);
|
||||
// collect rational/basic roots
|
||||
unsigned sz = m_isolate_roots.size();
|
||||
TRACE("algebraic", tout << "isolated roots: " << sz << "\n";);
|
||||
|
@ -654,13 +654,13 @@ namespace algebraic_numbers {
|
|||
for (unsigned i = 0; i < sz; i++) {
|
||||
mpbq & lower = m_isolate_lowers[i];
|
||||
mpbq & upper = m_isolate_uppers[i];
|
||||
if (!upm().isolating2refinable(f.size(), f.c_ptr(), bqm(), lower, upper)) {
|
||||
if (!upm().isolating2refinable(f.size(), f.data(), bqm(), lower, upper)) {
|
||||
// found rational root... it is stored in lower
|
||||
to_mpq(qm(), lower, r);
|
||||
roots.push_back(numeral(mk_basic_cell(r)));
|
||||
}
|
||||
else {
|
||||
algebraic_cell * c = mk_algebraic_cell(f.size(), f.c_ptr(), lower, upper, full_fact);
|
||||
algebraic_cell * c = mk_algebraic_cell(f.size(), f.data(), lower, upper, full_fact);
|
||||
roots.push_back(numeral(c));
|
||||
}
|
||||
}
|
||||
|
@ -990,7 +990,7 @@ namespace algebraic_numbers {
|
|||
void set_core(numeral & c, scoped_upoly & p, mpbqi & r_i, upolynomial::scoped_upolynomial_sequence & seq, int lV, int uV, bool minimal) {
|
||||
TRACE("algebraic", tout << "set_core p: "; upm().display(tout, p); tout << "\n";);
|
||||
if (bqim().contains_zero(r_i)) {
|
||||
if (upm().has_zero_roots(p.size(), p.c_ptr())) {
|
||||
if (upm().has_zero_roots(p.size(), p.data())) {
|
||||
// zero is a root of p, and r_i is an isolating interval containing zero,
|
||||
// then c is zero
|
||||
reset(c);
|
||||
|
@ -1012,15 +1012,15 @@ namespace algebraic_numbers {
|
|||
|
||||
// make sure 0 is not a root of p
|
||||
scoped_upoly & nz_p = m_add_tmp;
|
||||
if (upm().has_zero_roots(p.size(), p.c_ptr())) {
|
||||
if (upm().has_zero_roots(p.size(), p.data())) {
|
||||
// remove zero root
|
||||
upm().remove_zero_roots(p.size(), p.c_ptr(), nz_p);
|
||||
upm().remove_zero_roots(p.size(), p.data(), nz_p);
|
||||
}
|
||||
else {
|
||||
p.swap(nz_p);
|
||||
}
|
||||
|
||||
if (!upm().isolating2refinable(nz_p.size(), nz_p.c_ptr(), bqm(), r_i.lower(), r_i.upper())) {
|
||||
if (!upm().isolating2refinable(nz_p.size(), nz_p.data(), bqm(), r_i.lower(), r_i.upper())) {
|
||||
// found actual root
|
||||
scoped_mpq r(qm());
|
||||
to_mpq(qm(), r_i.lower(), r);
|
||||
|
@ -1028,7 +1028,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
else {
|
||||
TRACE("algebraic", tout << "set_core...\n";);
|
||||
set(c, nz_p.size(), nz_p.c_ptr(), r_i.lower(), r_i.upper(), minimal);
|
||||
set(c, nz_p.size(), nz_p.data(), r_i.lower(), r_i.upper(), minimal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1064,7 +1064,7 @@ namespace algebraic_numbers {
|
|||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
TRACE("anum_mk_binary", tout << "factor " << i << "\n"; upm().display(tout, fs[i]); tout << "\n";);
|
||||
typename upolynomial::scoped_upolynomial_sequence * seq = alloc(typename upolynomial::scoped_upolynomial_sequence, upm());
|
||||
upm().sturm_seq(fs[i].size(), fs[i].c_ptr(), *seq);
|
||||
upm().sturm_seq(fs[i].size(), fs[i].data(), *seq);
|
||||
seqs.push_back(seq);
|
||||
}
|
||||
SASSERT(seqs.size() == num_fs);
|
||||
|
@ -1114,7 +1114,7 @@ namespace algebraic_numbers {
|
|||
TRACE("anum_mk_binary", tout << "target_i: " << target_i << "\n";);
|
||||
saved_a.restore_if_too_small();
|
||||
saved_b.restore_if_too_small();
|
||||
upm().set(fs[target_i].size(), fs[target_i].c_ptr(), f);
|
||||
upm().set(fs[target_i].size(), fs[target_i].data(), f);
|
||||
set_core(c, f, r_i, *(seqs[target_i]), target_lV, target_uV, full_fact);
|
||||
return;
|
||||
}
|
||||
|
@ -1144,7 +1144,7 @@ namespace algebraic_numbers {
|
|||
scoped_ptr_vector<typename upolynomial::scoped_upolynomial_sequence> seqs;
|
||||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
typename upolynomial::scoped_upolynomial_sequence * seq = alloc(typename upolynomial::scoped_upolynomial_sequence, upm());
|
||||
upm().sturm_seq(fs[i].size(), fs[i].c_ptr(), *seq);
|
||||
upm().sturm_seq(fs[i].size(), fs[i].data(), *seq);
|
||||
seqs.push_back(seq);
|
||||
}
|
||||
SASSERT(seqs.size() == num_fs);
|
||||
|
@ -1188,7 +1188,7 @@ namespace algebraic_numbers {
|
|||
if (num_rem == 1 && target_i != UINT_MAX) {
|
||||
// found isolating interval
|
||||
saved_a.restore_if_too_small();
|
||||
upm().set(fs[target_i].size(), fs[target_i].c_ptr(), f);
|
||||
upm().set(fs[target_i].size(), fs[target_i].data(), f);
|
||||
set_core(b, f, r_i, *(seqs[target_i]), target_lV, target_uV, full_fact);
|
||||
return;
|
||||
}
|
||||
|
@ -1363,10 +1363,10 @@ namespace algebraic_numbers {
|
|||
bqm().add(upper, mpz(1), upper); // make sure (a_val)^{1/k} < upper
|
||||
}
|
||||
SASSERT(bqm().lt(lower, upper));
|
||||
TRACE("algebraic", tout << "root_core:\n"; upm().display(tout, p.size(), p.c_ptr()); tout << "\n";);
|
||||
TRACE("algebraic", tout << "root_core:\n"; upm().display(tout, p.size(), p.data()); tout << "\n";);
|
||||
// p is not necessarily a minimal polynomial.
|
||||
// So, we set the m_minimal flag to false. TODO: try to factor.
|
||||
set(b, p.size(), p.c_ptr(), lower, upper, false);
|
||||
set(b, p.size(), p.data(), lower, upper, false);
|
||||
}
|
||||
|
||||
void root(numeral & a, unsigned k, numeral & b) {
|
||||
|
@ -1466,15 +1466,15 @@ namespace algebraic_numbers {
|
|||
qm().add(il, nbv, il);
|
||||
qm().add(iu, nbv, iu);
|
||||
// (il, iu) is an isolating refinable (rational) interval for the new polynomial.
|
||||
upm().convert_q2bq_interval(m_add_tmp.size(), m_add_tmp.c_ptr(), il, iu, bqm(), l, u);
|
||||
upm().convert_q2bq_interval(m_add_tmp.size(), m_add_tmp.data(), il, iu, bqm(), l, u);
|
||||
}
|
||||
TRACE("algebraic",
|
||||
upm().display(tout, m_add_tmp.size(), m_add_tmp.c_ptr());
|
||||
upm().display(tout, m_add_tmp.size(), m_add_tmp.data());
|
||||
tout << ", l: " << l << ", u: " << u << "\n";
|
||||
tout << "l_sign: " << upm().eval_sign_at(m_add_tmp.size(), m_add_tmp.c_ptr(), l) << "\n";
|
||||
tout << "u_sign: " << upm().eval_sign_at(m_add_tmp.size(), m_add_tmp.c_ptr(), u) << "\n";
|
||||
tout << "l_sign: " << upm().eval_sign_at(m_add_tmp.size(), m_add_tmp.data(), l) << "\n";
|
||||
tout << "u_sign: " << upm().eval_sign_at(m_add_tmp.size(), m_add_tmp.data(), u) << "\n";
|
||||
);
|
||||
set(c, m_add_tmp.size(), m_add_tmp.c_ptr(), l, u, a->m_minimal /* minimality is preserved */);
|
||||
set(c, m_add_tmp.size(), m_add_tmp.data(), l, u, a->m_minimal /* minimality is preserved */);
|
||||
normalize(c);
|
||||
}
|
||||
|
||||
|
@ -1550,7 +1550,7 @@ namespace algebraic_numbers {
|
|||
qm().inv(nbv);
|
||||
scoped_upoly & mulp = m_add_tmp;
|
||||
upm().set(a->m_p_sz, a->m_p, mulp);
|
||||
upm().compose_p_q_x(mulp.size(), mulp.c_ptr(), nbv);
|
||||
upm().compose_p_q_x(mulp.size(), mulp.data(), nbv);
|
||||
mpbqi const & i = a->m_interval;
|
||||
scoped_mpbq l(bqm());
|
||||
scoped_mpbq u(bqm());
|
||||
|
@ -1576,15 +1576,15 @@ namespace algebraic_numbers {
|
|||
if (is_neg)
|
||||
qm().swap(il, iu);
|
||||
// (il, iu) is an isolating refinable (rational) interval for the new polynomial.
|
||||
upm().convert_q2bq_interval(mulp.size(), mulp.c_ptr(), il, iu, bqm(), l, u);
|
||||
upm().convert_q2bq_interval(mulp.size(), mulp.data(), il, iu, bqm(), l, u);
|
||||
}
|
||||
TRACE("algebraic",
|
||||
upm().display(tout, mulp.size(), mulp.c_ptr());
|
||||
upm().display(tout, mulp.size(), mulp.data());
|
||||
tout << ", l: " << l << ", u: " << u << "\n";
|
||||
tout << "l_sign: " << upm().eval_sign_at(mulp.size(), mulp.c_ptr(), l) << "\n";
|
||||
tout << "u_sign: " << upm().eval_sign_at(mulp.size(), mulp.c_ptr(), u) << "\n";
|
||||
tout << "l_sign: " << upm().eval_sign_at(mulp.size(), mulp.data(), l) << "\n";
|
||||
tout << "u_sign: " << upm().eval_sign_at(mulp.size(), mulp.data(), u) << "\n";
|
||||
);
|
||||
set(c, mulp.size(), mulp.c_ptr(), l, u, a->m_minimal /* minimality is preserved */);
|
||||
set(c, mulp.size(), mulp.data(), l, u, a->m_minimal /* minimality is preserved */);
|
||||
normalize(c);
|
||||
}
|
||||
|
||||
|
@ -2223,7 +2223,7 @@ namespace algebraic_numbers {
|
|||
SASSERT(pm().is_univariate(R));
|
||||
scoped_upoly & _R = m_eval_sign_tmp;
|
||||
upm().to_numeral_vector(R, _R);
|
||||
unsigned k = upm().nonzero_root_lower_bound(_R.size(), _R.c_ptr());
|
||||
unsigned k = upm().nonzero_root_lower_bound(_R.size(), _R.data());
|
||||
TRACE("anum_eval_sign", tout << "R: " << R << "\nk: " << k << "\nri: "<< ri << "\n";);
|
||||
scoped_mpbq mL(bqm()), L(bqm());
|
||||
bqm().set(mL, -1);
|
||||
|
|
|
@ -917,7 +917,7 @@ namespace polynomial {
|
|||
else
|
||||
m_powers_tmp.push_back(power(x, 1));
|
||||
}
|
||||
return mk_monomial(m_powers_tmp.size(), m_powers_tmp.c_ptr());
|
||||
return mk_monomial(m_powers_tmp.size(), m_powers_tmp.data());
|
||||
}
|
||||
|
||||
monomial * mul(unsigned sz1, power const * pws1, unsigned sz2, power const * pws2) {
|
||||
|
@ -1335,8 +1335,8 @@ namespace polynomial {
|
|||
buckets[i].reset();
|
||||
}
|
||||
SASSERT(p.size() == end - start);
|
||||
apply_permutation(p.size(), m_as + start, p.c_ptr());
|
||||
apply_permutation_core(p.size(), m_ms + start, p.c_ptr()); // p is not needed anymore after this command
|
||||
apply_permutation(p.size(), m_as + start, p.data());
|
||||
apply_permutation_core(p.size(), m_ms + start, p.data()); // p is not needed anymore after this command
|
||||
i = start;
|
||||
while (i < end) {
|
||||
monomial * m = m_ms[i];
|
||||
|
@ -1878,7 +1878,7 @@ namespace polynomial {
|
|||
if (sz == 0)
|
||||
return false;
|
||||
scoped_numeral g(m);
|
||||
m.gcd(as.size(), as.c_ptr(), g);
|
||||
m.gcd(as.size(), as.data(), g);
|
||||
if (m.is_one(g))
|
||||
return false;
|
||||
SASSERT(m.is_pos(g));
|
||||
|
@ -2152,7 +2152,7 @@ namespace polynomial {
|
|||
|
||||
polynomial * mk(bool normalize = false) {
|
||||
remove_zeros(normalize);
|
||||
polynomial * p = m_owner->mk_polynomial_core(m_tmp_as.size(), m_tmp_as.c_ptr(), m_tmp_ms.c_ptr());
|
||||
polynomial * p = m_owner->mk_polynomial_core(m_tmp_as.size(), m_tmp_as.data(), m_tmp_ms.data());
|
||||
m_tmp_as.reset();
|
||||
m_tmp_ms.reset();
|
||||
return p;
|
||||
|
@ -2312,7 +2312,7 @@ namespace polynomial {
|
|||
}
|
||||
|
||||
polynomial * mk() {
|
||||
polynomial * new_p = m_owner->mk_polynomial_core(m_tmp_as.size(), m_tmp_as.c_ptr(), m_tmp_ms.c_ptr());
|
||||
polynomial * new_p = m_owner->mk_polynomial_core(m_tmp_as.size(), m_tmp_as.data(), m_tmp_ms.data());
|
||||
m_tmp_as.reset();
|
||||
m_tmp_ms.reset();
|
||||
return new_p;
|
||||
|
@ -2614,7 +2614,7 @@ namespace polynomial {
|
|||
|
||||
polynomial * mk_polynomial(unsigned sz, rational const * as, monomial * const * ms) {
|
||||
rational2numeral(sz, as);
|
||||
polynomial * p = mk_polynomial(sz, m_rat2numeral.c_ptr(), ms);
|
||||
polynomial * p = mk_polynomial(sz, m_rat2numeral.data(), ms);
|
||||
reset_tmp_as2();
|
||||
return p;
|
||||
}
|
||||
|
@ -2636,7 +2636,7 @@ namespace polynomial {
|
|||
polynomial * mk_univariate(var x, unsigned n, rational const * as) {
|
||||
SASSERT(is_valid(x));
|
||||
rational2numeral(n+1, as);
|
||||
polynomial * p = mk_univariate(x, n, m_rat2numeral.c_ptr());
|
||||
polynomial * p = mk_univariate(x, n, m_rat2numeral.data());
|
||||
reset_tmp_as2();
|
||||
return p;
|
||||
}
|
||||
|
@ -2656,7 +2656,7 @@ namespace polynomial {
|
|||
swap(m_tmp_linear_as.back(), c);
|
||||
m_tmp_linear_ms.push_back(mk_unit());
|
||||
}
|
||||
polynomial * p = mk_polynomial(m_tmp_linear_as.size(), m_tmp_linear_as.c_ptr(), m_tmp_linear_ms.c_ptr());
|
||||
polynomial * p = mk_polynomial(m_tmp_linear_as.size(), m_tmp_linear_as.data(), m_tmp_linear_ms.data());
|
||||
for (auto& a : m_tmp_linear_as) {
|
||||
m_manager.del(a);
|
||||
}
|
||||
|
@ -2670,7 +2670,7 @@ namespace polynomial {
|
|||
rational2numeral(sz, as);
|
||||
numeral tmp_c;
|
||||
m_manager.set(tmp_c, c.to_mpq().numerator());
|
||||
polynomial * p = mk_linear(sz, m_rat2numeral.c_ptr(), xs, tmp_c);
|
||||
polynomial * p = mk_linear(sz, m_rat2numeral.data(), xs, tmp_c);
|
||||
SASSERT(m_manager.is_zero(tmp_c));
|
||||
reset_tmp_as2();
|
||||
return p;
|
||||
|
@ -3202,7 +3202,7 @@ namespace polynomial {
|
|||
tout << m.to_string(cs[i]) << " ";
|
||||
}
|
||||
tout << "\n";);
|
||||
solver.add(i, cs.c_ptr(), m_outputs[output_idx]);
|
||||
solver.add(i, cs.data(), m_outputs[output_idx]);
|
||||
}
|
||||
TRACE("sparse_interpolator",
|
||||
tout << "find coefficients of:\n";
|
||||
|
@ -3211,7 +3211,7 @@ namespace polynomial {
|
|||
}
|
||||
tout << "system of equations:\n";
|
||||
solver.display(tout););
|
||||
if (!solver.solve(new_as.c_ptr()))
|
||||
if (!solver.solve(new_as.data()))
|
||||
return false;
|
||||
for (unsigned i = 0; i < num_pws; i++) {
|
||||
if (!m.is_zero(new_as[i])) {
|
||||
|
@ -3220,7 +3220,7 @@ namespace polynomial {
|
|||
}
|
||||
}
|
||||
}
|
||||
r = m_skeleton->pm.mk_polynomial(as.size(), as.c_ptr(), mons.c_ptr());
|
||||
r = m_skeleton->pm.mk_polynomial(as.size(), as.data(), mons.data());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -4737,7 +4737,7 @@ namespace polynomial {
|
|||
push_power(pws, y, n - k);
|
||||
push_power(pws, x, k);
|
||||
}
|
||||
monomial * new_m = mk_monomial(pws.size(), pws.c_ptr());
|
||||
monomial * new_m = mk_monomial(pws.size(), pws.data());
|
||||
m_cheap_som_buffer.add(p->a(i), new_m);
|
||||
}
|
||||
return m_cheap_som_buffer.mk();
|
||||
|
@ -5668,7 +5668,7 @@ namespace polynomial {
|
|||
h1 = exact_div(h1, hs0);
|
||||
S.push_back(h1);
|
||||
if (is_zero(G2)) {
|
||||
std::reverse(S.c_ptr(), S.c_ptr() + S.size());
|
||||
std::reverse(S.data(), S.data() + S.size());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -5855,7 +5855,7 @@ namespace polynomial {
|
|||
psc_chain_optimized_core(Q, P, x, S);
|
||||
if (S.empty())
|
||||
S.push_back(mk_zero());
|
||||
std::reverse(S.c_ptr(), S.c_ptr() + S.size());
|
||||
std::reverse(S.data(), S.data() + S.size());
|
||||
}
|
||||
|
||||
void psc_chain_classic_core(polynomial const * P, polynomial const * Q, var x, polynomial_ref_vector & S) {
|
||||
|
@ -5935,7 +5935,7 @@ namespace polynomial {
|
|||
psc_chain_classic_core(Q, P, x, S);
|
||||
if (S.empty())
|
||||
S.push_back(mk_zero());
|
||||
std::reverse(S.c_ptr(), S.c_ptr() + S.size());
|
||||
std::reverse(S.data(), S.data() + S.size());
|
||||
}
|
||||
|
||||
void psc_chain(polynomial const * A, polynomial const * B, var x, polynomial_ref_vector & S) {
|
||||
|
@ -6253,7 +6253,7 @@ namespace polynomial {
|
|||
|
||||
unsigned num_vars() const { return m_xs.size(); }
|
||||
|
||||
var const * vars() const { return m_xs.c_ptr(); }
|
||||
var const * vars() const { return m_xs.data(); }
|
||||
};
|
||||
|
||||
struct scoped_var_max_degree {
|
||||
|
@ -6752,7 +6752,7 @@ namespace polynomial {
|
|||
for (unsigned i = 0; i < num_factors; i++) {
|
||||
numeral_vector const & f1 = fs[i];
|
||||
unsigned k1 = fs.get_degree(i);
|
||||
f = to_polynomial(f1.size(), f1.c_ptr(), x);
|
||||
f = to_polynomial(f1.size(), f1.data(), x);
|
||||
TRACE("factor_bug",
|
||||
tout << "uni-factor:\n"; upm().display(tout, f1); tout << "\n";
|
||||
tout << "factor:\n" << f << "\n";);
|
||||
|
@ -6878,7 +6878,7 @@ namespace polynomial {
|
|||
coeffs.push_back(numeral());
|
||||
m_manager.set(coeffs.back(), p[i]);
|
||||
}
|
||||
return mk_univariate(x, sz-1, coeffs.c_ptr());
|
||||
return mk_univariate(x, sz-1, coeffs.data());
|
||||
}
|
||||
|
||||
polynomial * mk_glex_monic(polynomial const * p) {
|
||||
|
@ -7510,7 +7510,7 @@ polynomial::polynomial * convert(polynomial::manager & sm, polynomial::polynomia
|
|||
}
|
||||
}
|
||||
}
|
||||
return tm.mk_polynomial(as.size(), as.c_ptr(), ms.c_ptr());
|
||||
return tm.mk_polynomial(as.size(), as.data(), ms.data());
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, polynomial_ref_vector const & seq) {
|
||||
|
|
|
@ -981,7 +981,7 @@ namespace polynomial {
|
|||
*/
|
||||
polynomial * to_polynomial(unsigned sz, numeral const * p, var x);
|
||||
polynomial * to_polynomial(numeral_vector const & p, var x) {
|
||||
return to_polynomial(p.size(), p.c_ptr(), x);
|
||||
return to_polynomial(p.size(), p.data(), x);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1003,7 +1003,7 @@ namespace polynomial {
|
|||
void translate(polynomial const * p, unsigned xs_sz, var const * xs, numeral const * vs, polynomial_ref & r);
|
||||
void translate(polynomial const * p, var_vector const & xs, numeral_vector const & vs, polynomial_ref & r) {
|
||||
SASSERT(xs.size() == vs.size());
|
||||
translate(p, xs.size(), xs.c_ptr(), vs.c_ptr(), r);
|
||||
translate(p, xs.size(), xs.data(), vs.data(), r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -318,7 +318,7 @@ namespace rpolynomial {
|
|||
numeral * new_arg = mk_numeral();
|
||||
m_manager.set(*new_arg, 1);
|
||||
new_args.push_back(to_poly_or_num(new_arg));
|
||||
return mk_poly(new_args.size(), new_args.c_ptr(), x);
|
||||
return mk_poly(new_args.size(), new_args.data(), x);
|
||||
}
|
||||
|
||||
poly_or_num * unpack(polynomial const * p) {
|
||||
|
@ -361,7 +361,7 @@ namespace rpolynomial {
|
|||
for (unsigned i = 0; i < sz; i++) {
|
||||
new_args.push_back(mul_core(c, _p->arg(i)));
|
||||
}
|
||||
return mk_poly_core(new_args.size(), new_args.c_ptr(), _p->max_var());
|
||||
return mk_poly_core(new_args.size(), new_args.data(), _p->max_var());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ namespace rpolynomial {
|
|||
new_args.push_back(add_core(c, _p->arg(0)));
|
||||
for (unsigned i = 1; i < sz; i++)
|
||||
new_args.push_back(_p->arg(1));
|
||||
return mk_poly_core(new_args.size(), new_args.c_ptr(), _p->max_var());
|
||||
return mk_poly_core(new_args.size(), new_args.data(), _p->max_var());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void sexpr2upolynomial(upolynomial::manager & m, sexpr const * s, upolynomial::n
|
|||
for (unsigned i = 2; i < num; i++) {
|
||||
m.reset(arg);
|
||||
sexpr2upolynomial(m, s->get_child(i), arg, depth+1);
|
||||
m.add(arg.size(), arg.c_ptr(), p.size(), p.c_ptr(), p);
|
||||
m.add(arg.size(), arg.data(), p.size(), p.data(), p);
|
||||
}
|
||||
}
|
||||
else if (op == "-") {
|
||||
|
@ -60,7 +60,7 @@ void sexpr2upolynomial(upolynomial::manager & m, sexpr const * s, upolynomial::n
|
|||
for (unsigned i = 2; i < num; i++) {
|
||||
m.reset(arg);
|
||||
sexpr2upolynomial(m, s->get_child(i), arg, depth+1);
|
||||
m.sub(p.size(), p.c_ptr(), arg.size(), arg.c_ptr(), p);
|
||||
m.sub(p.size(), p.data(), arg.size(), arg.data(), p);
|
||||
}
|
||||
}
|
||||
else if (op == "*") {
|
||||
|
@ -71,7 +71,7 @@ void sexpr2upolynomial(upolynomial::manager & m, sexpr const * s, upolynomial::n
|
|||
for (unsigned i = 2; i < num; i++) {
|
||||
m.reset(arg);
|
||||
sexpr2upolynomial(m, s->get_child(i), arg, depth+1);
|
||||
m.mul(arg.size(), arg.c_ptr(), p.size(), p.c_ptr(), p);
|
||||
m.mul(arg.size(), arg.data(), p.size(), p.data(), p);
|
||||
}
|
||||
}
|
||||
else if (op == "^") {
|
||||
|
@ -82,7 +82,7 @@ void sexpr2upolynomial(upolynomial::manager & m, sexpr const * s, upolynomial::n
|
|||
if (!arg2->is_numeral() || !arg2->get_numeral().is_unsigned())
|
||||
throw sexpr2upolynomial_exception("invalid univariate polynomial, exponent must be an unsigned integer", arg2);
|
||||
unsigned k = arg2->get_numeral().get_unsigned();
|
||||
m.pw(p.size(), p.c_ptr(), k, p);
|
||||
m.pw(p.size(), p.data(), k, p);
|
||||
}
|
||||
else {
|
||||
throw sexpr2upolynomial_exception("invalid univariate polynomial, '+', '-', '^' or '*' expected", s);
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace upolynomial {
|
|||
SASSERT(degree > 0);
|
||||
m_factors.push_back(numeral_vector());
|
||||
m_degrees.push_back(degree);
|
||||
m_upm.set(p.size(), p.c_ptr(), m_factors.back());
|
||||
m_upm.set(p.size(), p.data(), m_factors.back());
|
||||
m_total_factors += degree;
|
||||
m_total_degree += m_upm.degree(p)*degree;
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ namespace upolynomial {
|
|||
for (unsigned i = 0; i < m_factors.size(); ++ i) {
|
||||
if (m_degrees[i] > 1) {
|
||||
numeral_vector power;
|
||||
m_upm.pw(m_factors[i].size(), m_factors[i].c_ptr(), m_degrees[i], power);
|
||||
m_upm.mul(out.size(), out.c_ptr(), power.size(), power.c_ptr(), out);
|
||||
m_upm.pw(m_factors[i].size(), m_factors[i].data(), m_degrees[i], power);
|
||||
m_upm.mul(out.size(), out.data(), power.size(), power.data(), out);
|
||||
m_upm.reset(power);
|
||||
} else {
|
||||
m_upm.mul(out.size(), out.c_ptr(), m_factors[i].size(), m_factors[i].c_ptr(), out);
|
||||
m_upm.mul(out.size(), out.data(), m_factors[i].size(), m_factors[i].data(), out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ namespace upolynomial {
|
|||
|
||||
// Copy elements from p to buffer.
|
||||
void core_manager::set(unsigned sz, numeral const * p, numeral_vector & buffer) {
|
||||
if (p != nullptr && buffer.c_ptr() == p) {
|
||||
if (p != nullptr && buffer.data() == p) {
|
||||
SASSERT(buffer.size() == sz);
|
||||
return;
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ namespace upolynomial {
|
|||
|
||||
// Divide coefficients of p by their GCD
|
||||
void core_manager::normalize(numeral_vector & p) {
|
||||
normalize(p.size(), p.c_ptr());
|
||||
normalize(p.size(), p.data());
|
||||
}
|
||||
|
||||
void core_manager::div(unsigned sz, numeral * p, numeral const & b) {
|
||||
|
@ -423,7 +423,7 @@ namespace upolynomial {
|
|||
reset(p);
|
||||
return;
|
||||
}
|
||||
mul(p.size(), p.c_ptr(), b);
|
||||
mul(p.size(), p.data(), b);
|
||||
}
|
||||
|
||||
// Pseudo division
|
||||
|
@ -568,7 +568,7 @@ namespace upolynomial {
|
|||
rem(sz1, p1, sz2, p2, d, buffer);
|
||||
// We don't need to flip the sign if d is odd and leading coefficient of p2 is negative
|
||||
if (d % 2 == 0 || (sz2 > 0 && m().is_pos(p2[sz2-1])))
|
||||
neg(buffer.size(), buffer.c_ptr());
|
||||
neg(buffer.size(), buffer.data());
|
||||
}
|
||||
|
||||
|
||||
|
@ -619,7 +619,7 @@ namespace upolynomial {
|
|||
_r.reserve(deg+1);
|
||||
numeral_vector & _p1 = m_div_tmp1;
|
||||
// std::cerr << "dividing with "; display(std::cerr, _p1); std::cerr << std::endl;
|
||||
TRACE("factor_bug", tout << "sz1: " << sz1 << " p1: " << p1 << ", _p1.c_ptr(): " << _p1.c_ptr() << ", _p1.size(): " << _p1.size() << "\n";);
|
||||
TRACE("factor_bug", tout << "sz1: " << sz1 << " p1: " << p1 << ", _p1.c_ptr(): " << _p1.data() << ", _p1.size(): " << _p1.size() << "\n";);
|
||||
set(sz1, p1, _p1);
|
||||
SASSERT(_p1.size() == sz1);
|
||||
while (true) {
|
||||
|
@ -750,8 +750,8 @@ namespace upolynomial {
|
|||
TRACE("mgcd", tout << "trying prime: " << p << "\n";);
|
||||
{
|
||||
scoped_set_zp setZp(*this, p);
|
||||
set(pp_u.size(), pp_u.c_ptr(), u_Zp);
|
||||
set(pp_v.size(), pp_v.c_ptr(), v_Zp);
|
||||
set(pp_u.size(), pp_u.data(), u_Zp);
|
||||
set(pp_v.size(), pp_v.data(), v_Zp);
|
||||
if (degree(u_Zp) < d_u) {
|
||||
TRACE("mgcd", tout << "bad prime, leading coefficient vanished\n";);
|
||||
continue; // bad prime
|
||||
|
@ -760,9 +760,9 @@ namespace upolynomial {
|
|||
TRACE("mgcd", tout << "bad prime, leading coefficient vanished\n";);
|
||||
continue; // bad prime
|
||||
}
|
||||
euclid_gcd(u_Zp.size(), u_Zp.c_ptr(), v_Zp.size(), v_Zp.c_ptr(), q);
|
||||
euclid_gcd(u_Zp.size(), u_Zp.data(), v_Zp.size(), v_Zp.data(), q);
|
||||
// normalize so that lc_g is leading coefficient of q
|
||||
mk_monic(q.size(), q.c_ptr());
|
||||
mk_monic(q.size(), q.data());
|
||||
scoped_numeral c(m());
|
||||
m().set(c, lc_g);
|
||||
mul(q, c);
|
||||
|
@ -776,13 +776,13 @@ namespace upolynomial {
|
|||
return;
|
||||
}
|
||||
if (i == 0) {
|
||||
set(q.size(), q.c_ptr(), C);
|
||||
set(q.size(), q.data(), C);
|
||||
m().set(bound, p);
|
||||
}
|
||||
else if (q.size() < C.size() || m().m().is_even(p) || m().m().is_even(bound)) {
|
||||
// discard accumulated image, it was affected by unlucky primes
|
||||
TRACE("mgcd", tout << "discarding image\n";);
|
||||
set(q.size(), q.c_ptr(), C);
|
||||
set(q.size(), q.data(), C);
|
||||
m().set(bound, p);
|
||||
}
|
||||
else {
|
||||
|
@ -829,7 +829,7 @@ namespace upolynomial {
|
|||
set(sz1, p1, A);
|
||||
set(sz2, p2, B);
|
||||
TRACE("upolynomial", tout << "sz1: " << sz1 << ", p1: " << p1 << ", sz2: " << sz2 << ", p2: " << p2 << "\nB.size(): " << B.size() <<
|
||||
", B.c_ptr(): " << B.c_ptr() << "\n";);
|
||||
", B.c_ptr(): " << B.data() << "\n";);
|
||||
while (m_limit.inc()) {
|
||||
TRACE("upolynomial", tout << "A: "; display(tout, A); tout <<"\nB: "; display(tout, B); tout << "\n";);
|
||||
if (B.empty()) {
|
||||
|
@ -837,7 +837,7 @@ namespace upolynomial {
|
|||
buffer.swap(A);
|
||||
// to be consistent, if in a field, we make gcd monic
|
||||
if (is_field) {
|
||||
mk_monic(buffer.size(), buffer.c_ptr());
|
||||
mk_monic(buffer.size(), buffer.data());
|
||||
}
|
||||
else {
|
||||
flip_sign_if_lm_neg(buffer);
|
||||
|
@ -846,7 +846,7 @@ namespace upolynomial {
|
|||
display(tout, buffer); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
rem(A.size(), A.c_ptr(), B.size(), B.c_ptr(), R);
|
||||
rem(A.size(), A.data(), B.size(), B.data(), R);
|
||||
normalize(R);
|
||||
A.swap(B);
|
||||
B.swap(R);
|
||||
|
@ -906,7 +906,7 @@ namespace upolynomial {
|
|||
buffer.swap(A);
|
||||
// to be consistent, if in a field, we make gcd monic
|
||||
if (field()) {
|
||||
mk_monic(buffer.size(), buffer.c_ptr());
|
||||
mk_monic(buffer.size(), buffer.data());
|
||||
}
|
||||
else {
|
||||
flip_sign_if_lm_neg(buffer);
|
||||
|
@ -915,7 +915,7 @@ namespace upolynomial {
|
|||
display(tout, buffer); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
rem(A.size(), A.c_ptr(), B.size(), B.c_ptr(), d, R);
|
||||
rem(A.size(), A.data(), B.size(), B.data(), d, R);
|
||||
unsigned pseudo_div_d = A.size() - B.size();
|
||||
if (d < pseudo_div_d + 1) {
|
||||
// I used a standard subresultant implementation.
|
||||
|
@ -967,13 +967,13 @@ namespace upolynomial {
|
|||
numeral_vector & p_prime = m_sqf_tmp1;
|
||||
numeral_vector & g = m_sqf_tmp2;
|
||||
derivative(sz, p, p_prime);
|
||||
gcd(sz, p, p_prime.size(), p_prime.c_ptr(), g);
|
||||
gcd(sz, p, p_prime.size(), p_prime.data(), g);
|
||||
// subresultant_gcd(sz, p, p_prime.size(), p_prime.c_ptr(), g);
|
||||
if (g.size() <= 1) {
|
||||
set(sz, p, buffer);
|
||||
}
|
||||
else {
|
||||
div(sz, p, g.size(), g.c_ptr(), buffer);
|
||||
div(sz, p, g.size(), g.data(), buffer);
|
||||
normalize(buffer);
|
||||
}
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ namespace upolynomial {
|
|||
numeral_vector & p_prime = m_sqf_tmp1;
|
||||
numeral_vector & g = m_sqf_tmp2;
|
||||
derivative(sz, p, p_prime);
|
||||
gcd(sz, p, p_prime.size(), p_prime.c_ptr(), g);
|
||||
gcd(sz, p, p_prime.size(), p_prime.data(), g);
|
||||
return g.size() <= 1;
|
||||
}
|
||||
|
||||
|
@ -1006,7 +1006,7 @@ namespace upolynomial {
|
|||
numeral_vector & result = m_pw_tmp;
|
||||
set(sz, p, result);
|
||||
for (unsigned i = 1; i < k; i++)
|
||||
mul(m_pw_tmp.size(), m_pw_tmp.c_ptr(), sz, p, m_pw_tmp);
|
||||
mul(m_pw_tmp.size(), m_pw_tmp.data(), sz, p, m_pw_tmp);
|
||||
r.swap(result);
|
||||
#if 0
|
||||
unsigned mask = 1;
|
||||
|
@ -1057,7 +1057,7 @@ namespace upolynomial {
|
|||
reset(U); U.push_back(numeral()); m().set(U.back(), 1);
|
||||
// D <- A
|
||||
set(szA, A, D);
|
||||
mk_monic(szA, D.c_ptr());
|
||||
mk_monic(szA, D.data());
|
||||
// V1 <- 0
|
||||
reset(V1);
|
||||
// V3 <- B
|
||||
|
@ -1069,30 +1069,30 @@ namespace upolynomial {
|
|||
numeral_vector & AU = V1;
|
||||
numeral_vector & D_AU = V3;
|
||||
// V <- (D - AU)/B
|
||||
mul(szA, A, U.size(), U.c_ptr(), AU);
|
||||
sub(D.size(), D.c_ptr(), AU.size(), AU.c_ptr(), D_AU);
|
||||
div(D_AU.size(), D_AU.c_ptr(), szB, B, V);
|
||||
mul(szA, A, U.size(), U.data(), AU);
|
||||
sub(D.size(), D.data(), AU.size(), AU.data(), D_AU);
|
||||
div(D_AU.size(), D_AU.data(), szB, B, V);
|
||||
DEBUG_CODE({
|
||||
scoped_numeral_vector BV(m());
|
||||
scoped_numeral_vector expected_D(m());
|
||||
mul(szB, B, V.size(), V.c_ptr(), BV);
|
||||
add(AU.size(), AU.c_ptr(), BV.size(), BV.c_ptr(), expected_D);
|
||||
mul(szB, B, V.size(), V.data(), BV);
|
||||
add(AU.size(), AU.data(), BV.size(), BV.data(), expected_D);
|
||||
SASSERT(eq(expected_D, D));
|
||||
});
|
||||
// if D is not monic, make it monic
|
||||
scoped_numeral lc_inv(m()), lc(m());
|
||||
mk_monic(D.size(), D.c_ptr(), lc, lc_inv);
|
||||
mk_monic(D.size(), D.data(), lc, lc_inv);
|
||||
mul(U, lc_inv);
|
||||
mul(V, lc_inv);
|
||||
return;
|
||||
}
|
||||
|
||||
// D = QV3 + R
|
||||
div_rem(D.size(), D.c_ptr(), V3.size(), V3.c_ptr(), Q, R);
|
||||
div_rem(D.size(), D.data(), V3.size(), V3.data(), Q, R);
|
||||
|
||||
// T <- U - V1Q
|
||||
mul(V1.size(), V1.c_ptr(), Q.size(), Q.c_ptr(), V1Q);
|
||||
sub(U.size(), U.c_ptr(), V1Q.size(), V1Q.c_ptr(), T);
|
||||
mul(V1.size(), V1.data(), Q.size(), Q.data(), V1Q);
|
||||
sub(U.size(), U.data(), V1Q.size(), V1Q.data(), T);
|
||||
// U <- V1
|
||||
U.swap(V1);
|
||||
// D <- V3
|
||||
|
@ -1413,21 +1413,21 @@ namespace upolynomial {
|
|||
TRACE("upolynomial", tout << "after translation\n"; display(tout, p_aux); tout << "\n";);
|
||||
scoped_mpbq b_a(bqm);
|
||||
bqm.sub(b, a, b_a);
|
||||
compose_p_b_x(p_aux.size(), p_aux.c_ptr(), b_a);
|
||||
compose_p_b_x(p_aux.size(), p_aux.data(), b_a);
|
||||
TRACE("upolynomial", tout << "after composition: " << bqm.to_string(b_a) << "\n"; display(tout, p_aux); tout << "\n";);
|
||||
unsigned result = descartes_bound_0_1(p_aux.size(), p_aux.c_ptr());
|
||||
unsigned result = descartes_bound_0_1(p_aux.size(), p_aux.data());
|
||||
return result;
|
||||
}
|
||||
else if (bqm.is_nonpos(b)) {
|
||||
// Basic idea: apply descartes_bound_a_b to p(-x) with intervals (-b, -a)
|
||||
numeral_vector & p_aux = m_dbab_tmp2;
|
||||
set(sz, p, p_aux);
|
||||
p_minus_x(p_aux.size(), p_aux.c_ptr());
|
||||
p_minus_x(p_aux.size(), p_aux.data());
|
||||
scoped_mpbq mb(bqm);
|
||||
scoped_mpbq ma(bqm);
|
||||
bqm.set(mb, b); bqm.neg(mb);
|
||||
bqm.set(ma, a); bqm.neg(ma);
|
||||
unsigned result = descartes_bound_a_b(p_aux.size(), p_aux.c_ptr(), bqm, mb, ma);
|
||||
unsigned result = descartes_bound_a_b(p_aux.size(), p_aux.data(), bqm, mb, ma);
|
||||
return result;
|
||||
}
|
||||
else if (!has_zero_roots(sz, p)) {
|
||||
|
@ -2118,7 +2118,7 @@ namespace upolynomial {
|
|||
|
||||
// left child
|
||||
set(sz, p, p_aux);
|
||||
compose_2n_p_x_div_2(p_aux.size(), p_aux.c_ptr());
|
||||
compose_2n_p_x_div_2(p_aux.size(), p_aux.data());
|
||||
normalize(p_aux);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
p_stack.push_back(numeral());
|
||||
|
@ -2215,7 +2215,7 @@ namespace upolynomial {
|
|||
TRACE("upolynomial", tout << "polynomial has a 1/2 root\n";);
|
||||
roots.push_back(mpbq(1, 1));
|
||||
remove_one_half_root(sz, p, q);
|
||||
push_child_frames(q.size(), q.c_ptr(), p_stack, frame_stack);
|
||||
push_child_frames(q.size(), q.data(), p_stack, frame_stack);
|
||||
}
|
||||
else {
|
||||
push_child_frames(sz, p, p_stack, frame_stack);
|
||||
|
@ -2253,7 +2253,7 @@ namespace upolynomial {
|
|||
TRACE("upolynomial", tout << "1/2 is a root\n";);
|
||||
add_root(frame_stack, bqm, roots);
|
||||
remove_one_half_root(sz, p, q);
|
||||
push_child_frames(q.size(), q.c_ptr(), p_stack, frame_stack);
|
||||
push_child_frames(q.size(), q.data(), p_stack, frame_stack);
|
||||
}
|
||||
else {
|
||||
push_child_frames(sz, p, p_stack, frame_stack);
|
||||
|
@ -2291,14 +2291,14 @@ namespace upolynomial {
|
|||
scoped_numeral_vector aux_p(m());
|
||||
set(sz, p, aux_p);
|
||||
pos_k = std::max(neg_k, pos_k);
|
||||
compose_p_2k_x(sz, aux_p.c_ptr(), pos_k);
|
||||
compose_p_2k_x(sz, aux_p.data(), pos_k);
|
||||
|
||||
// p(x) := p(2^{pos_k} * x)
|
||||
// Since the desired positive roots of p(x) are in (0, 2^pos_k),
|
||||
TRACE("upolynomial", tout << "searching at (0, 1)\n";);
|
||||
unsigned old_roots_sz = roots.size();
|
||||
unsigned old_lowers_sz = lowers.size();
|
||||
drs_isolate_0_1_roots(sz, aux_p.c_ptr(), bqm, roots, lowers, uppers);
|
||||
drs_isolate_0_1_roots(sz, aux_p.data(), bqm, roots, lowers, uppers);
|
||||
SASSERT(lowers.size() == uppers.size());
|
||||
adjust_pos(bqm, roots, old_roots_sz, pos_k);
|
||||
adjust_pos(bqm, lowers, old_lowers_sz, pos_k);
|
||||
|
@ -2330,7 +2330,7 @@ namespace upolynomial {
|
|||
|
||||
TRACE("upolynomial",
|
||||
scoped_numeral U(m());
|
||||
root_upper_bound(p1.size(), p1.c_ptr(), U);
|
||||
root_upper_bound(p1.size(), p1.data(), U);
|
||||
unsigned U_k = m().log2(U) + 1;
|
||||
tout << "Cauchy U: 2^" << U_k << "\n";
|
||||
tout << "Knuth pos U: 2^" << knuth_positive_root_upper_bound(sz, p) << "\n";
|
||||
|
@ -2345,7 +2345,7 @@ namespace upolynomial {
|
|||
unsigned pos_k = m().log2(U) + 1;
|
||||
unsigned neg_k = pos_k;
|
||||
#endif
|
||||
drs_isolate_roots(p1.size(), p1.c_ptr(), neg_k, pos_k, bqm, roots, lowers, uppers);
|
||||
drs_isolate_roots(p1.size(), p1.data(), neg_k, pos_k, bqm, roots, lowers, uppers);
|
||||
}
|
||||
|
||||
// Frame for root isolation in sturm_isolate_roots.
|
||||
|
@ -2477,7 +2477,7 @@ namespace upolynomial {
|
|||
unsigned pos_k = m().log2(U) + 1;
|
||||
unsigned neg_k = pos_k;
|
||||
#endif
|
||||
sturm_isolate_roots_core(p1.size(), p1.c_ptr(), neg_k, pos_k, bqm, roots, lowers, uppers);
|
||||
sturm_isolate_roots_core(p1.size(), p1.data(), neg_k, pos_k, bqm, roots, lowers, uppers);
|
||||
}
|
||||
|
||||
// Isolate roots of a square free polynomial that does not have zero roots
|
||||
|
@ -2496,8 +2496,8 @@ namespace upolynomial {
|
|||
scoped_numeral_vector nz_p(m());
|
||||
remove_zero_roots(sz, p, nz_p);
|
||||
TRACE("upolynomial", tout << "after removing zero root:\n"; display(tout, nz_p); tout << "\n";);
|
||||
SASSERT(!has_zero_roots(nz_p.size(), nz_p.c_ptr()));
|
||||
sqf_nz_isolate_roots(nz_p.size(), nz_p.c_ptr(), bqm, roots, lowers, uppers);
|
||||
SASSERT(!has_zero_roots(nz_p.size(), nz_p.data()));
|
||||
sqf_nz_isolate_roots(nz_p.size(), nz_p.data(), bqm, roots, lowers, uppers);
|
||||
}
|
||||
else {
|
||||
sqf_nz_isolate_roots(sz, p, bqm, roots, lowers, uppers);
|
||||
|
@ -2510,7 +2510,7 @@ namespace upolynomial {
|
|||
scoped_numeral_vector sqf_p(m());
|
||||
square_free(sz, p, sqf_p);
|
||||
TRACE("upolynomial", tout << "square free part:\n"; display(tout, sqf_p); tout << "\n";);
|
||||
sqf_isolate_roots(sqf_p.size(), sqf_p.c_ptr(), bqm, roots, lowers, uppers);
|
||||
sqf_isolate_roots(sqf_p.size(), sqf_p.data(), bqm, roots, lowers, uppers);
|
||||
}
|
||||
|
||||
// Keep expanding the Sturm sequence starting at seq
|
||||
|
@ -2522,7 +2522,7 @@ namespace upolynomial {
|
|||
if (is_zero(r))
|
||||
return;
|
||||
normalize(r);
|
||||
seq.push(r.size(), r.c_ptr());
|
||||
seq.push(r.size(), r.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2538,7 +2538,7 @@ namespace upolynomial {
|
|||
scoped_numeral_vector p_prime(m());
|
||||
seq.push(m(), sz, p);
|
||||
derivative(sz, p, p_prime);
|
||||
seq.push(p_prime.size(), p_prime.c_ptr());
|
||||
seq.push(p_prime.size(), p_prime.data());
|
||||
sturm_seq_core(seq);
|
||||
}
|
||||
|
||||
|
@ -2547,8 +2547,8 @@ namespace upolynomial {
|
|||
scoped_numeral_vector p1p2(m());
|
||||
seq.push(m(), sz1, p1);
|
||||
derivative(sz1, p1, p1p2);
|
||||
mul(p1p2.size(), p1p2.c_ptr(), sz2, p2, p1p2);
|
||||
seq.push(p1p2.size(), p1p2.c_ptr());
|
||||
mul(p1p2.size(), p1p2.data(), sz2, p2, p1p2);
|
||||
seq.push(p1p2.size(), p1p2.data());
|
||||
sturm_seq_core(seq);
|
||||
}
|
||||
|
||||
|
@ -2563,7 +2563,7 @@ namespace upolynomial {
|
|||
unsigned sz = seq.size();
|
||||
derivative(seq.size(sz-1), seq.coeffs(sz-1), p_prime);
|
||||
normalize(p_prime);
|
||||
seq.push(p_prime.size(), p_prime.c_ptr());
|
||||
seq.push(p_prime.size(), p_prime.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace upolynomial {
|
|||
numeral_vector m_sqf_tmp2;
|
||||
numeral_vector m_pw_tmp;
|
||||
|
||||
static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.c_ptr() != nullptr && buffer.c_ptr() == p; }
|
||||
static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.data() != nullptr && buffer.data() == p; }
|
||||
void neg_core(unsigned sz1, numeral const * p1, numeral_vector & buffer);
|
||||
void add_core(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);
|
||||
void sub_core(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);
|
||||
|
@ -192,7 +192,7 @@ namespace upolynomial {
|
|||
\brief Copy p to buffer.
|
||||
*/
|
||||
void set(unsigned sz, numeral const * p, numeral_vector & buffer);
|
||||
void set(numeral_vector & target, numeral_vector const & source) { set(source.size(), source.c_ptr(), target); }
|
||||
void set(numeral_vector & target, numeral_vector const & source) { set(source.size(), source.data(), target); }
|
||||
|
||||
/**
|
||||
\brief Copy p to buffer.
|
||||
|
@ -206,42 +206,42 @@ namespace upolynomial {
|
|||
*/
|
||||
void get_primitive_and_content(unsigned f_sz, numeral const * f, numeral_vector & pp, numeral & cont);
|
||||
void get_primitive_and_content(numeral_vector const & f, numeral_vector & pp, numeral & cont) {
|
||||
get_primitive_and_content(f.size(), f.c_ptr(), pp, cont);
|
||||
get_primitive_and_content(f.size(), f.data(), pp, cont);
|
||||
}
|
||||
void get_primitive(numeral_vector const & f, numeral_vector & pp) {
|
||||
scoped_numeral cont(m());
|
||||
get_primitive_and_content(f.size(), f.c_ptr(), pp, cont);
|
||||
get_primitive_and_content(f.size(), f.data(), pp, cont);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief p := -p
|
||||
*/
|
||||
void neg(unsigned sz, numeral * p);
|
||||
void neg(numeral_vector & p) { neg(p.size(), p.c_ptr()); }
|
||||
void neg(numeral_vector & p) { neg(p.size(), p.data()); }
|
||||
|
||||
/**
|
||||
\brief buffer := -p
|
||||
*/
|
||||
void neg(unsigned sz, numeral const * p, numeral_vector & buffer);
|
||||
void neg(numeral_vector const & p, numeral_vector & p_neg) { neg(p.size(), p.c_ptr(), p_neg); }
|
||||
void neg(numeral_vector const & p, numeral_vector & p_neg) { neg(p.size(), p.data(), p_neg); }
|
||||
|
||||
/**
|
||||
\brief buffer := p1 + p2
|
||||
*/
|
||||
void add(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);
|
||||
void add(numeral_vector const & a, numeral_vector const & b, numeral_vector & c) { add(a.size(), a.c_ptr(), b.size(), b.c_ptr(), c); }
|
||||
void add(numeral_vector const & a, numeral_vector const & b, numeral_vector & c) { add(a.size(), a.data(), b.size(), b.data(), c); }
|
||||
|
||||
/**
|
||||
\brief buffer := p1 - p2
|
||||
*/
|
||||
void sub(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);
|
||||
void sub(numeral_vector const & a, numeral_vector const & b, numeral_vector & c) { sub(a.size(), a.c_ptr(), b.size(), b.c_ptr(), c); }
|
||||
void sub(numeral_vector const & a, numeral_vector const & b, numeral_vector & c) { sub(a.size(), a.data(), b.size(), b.data(), c); }
|
||||
|
||||
/**
|
||||
\brief buffer := p1 * p2
|
||||
*/
|
||||
void mul(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer);
|
||||
void mul(numeral_vector const & a, numeral_vector const & b, numeral_vector & c) { mul(a.size(), a.c_ptr(), b.size(), b.c_ptr(), c); }
|
||||
void mul(numeral_vector const & a, numeral_vector const & b, numeral_vector & c) { mul(a.size(), a.data(), b.size(), b.data(), c); }
|
||||
|
||||
/**
|
||||
\brief r := p^k
|
||||
|
@ -252,7 +252,7 @@ namespace upolynomial {
|
|||
\brief buffer := dp/dx
|
||||
*/
|
||||
void derivative(unsigned sz1, numeral const * p, numeral_vector & buffer);
|
||||
void derivative(numeral_vector const & p, numeral_vector & d_p) { derivative(p.size(), p.c_ptr(), d_p); }
|
||||
void derivative(numeral_vector const & p, numeral_vector & d_p) { derivative(p.size(), p.data(), d_p); }
|
||||
|
||||
/**
|
||||
\brief Divide coefficients of p by their GCD
|
||||
|
@ -269,7 +269,7 @@ namespace upolynomial {
|
|||
This method assumes that every coefficient of p is a multiple of b, and b != 0.
|
||||
*/
|
||||
void div(unsigned sz, numeral * p, numeral const & b);
|
||||
void div(numeral_vector & p, numeral const & b) { div(p.size(), p.c_ptr(), b); }
|
||||
void div(numeral_vector & p, numeral const & b) { div(p.size(), p.data(), b); }
|
||||
|
||||
/**
|
||||
\brief Multiply the coefficients of p by b.
|
||||
|
@ -312,7 +312,7 @@ namespace upolynomial {
|
|||
}
|
||||
|
||||
void div_rem(numeral_vector const & p1, numeral_vector const & p2, numeral_vector & q, numeral_vector & r) {
|
||||
div_rem(p1.size(), p1.c_ptr(), p2.size(), p2.c_ptr(), q, r);
|
||||
div_rem(p1.size(), p1.data(), p2.size(), p2.data(), q, r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -343,14 +343,14 @@ namespace upolynomial {
|
|||
\brief Return true if p2 divides p1.
|
||||
*/
|
||||
bool divides(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2);
|
||||
bool divides(numeral_vector const & p1, numeral_vector const & p2) { return divides(p1.size(), p1.c_ptr(), p2.size(), p2.c_ptr()); }
|
||||
bool divides(numeral_vector const & p1, numeral_vector const & p2) { return divides(p1.size(), p1.data(), p2.size(), p2.data()); }
|
||||
|
||||
/**
|
||||
\brief Return true if p2 divides p1, and store the quotient in q.
|
||||
*/
|
||||
bool exact_div(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & q);
|
||||
bool exact_div(numeral_vector const & p1, numeral_vector const & p2, numeral_vector & q) {
|
||||
return exact_div(p1.size(), p1.c_ptr(), p2.size(), p2.c_ptr(), q);
|
||||
return exact_div(p1.size(), p1.data(), p2.size(), p2.data(), q);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,7 +360,7 @@ namespace upolynomial {
|
|||
void mk_monic(unsigned sz, numeral * p, numeral & lc, numeral & lc_inv);
|
||||
void mk_monic(unsigned sz, numeral * p, numeral & lc) { numeral lc_inv; mk_monic(sz, p, lc, lc_inv); m().del(lc_inv); }
|
||||
void mk_monic(unsigned sz, numeral * p) { numeral lc, lc_inv; mk_monic(sz, p, lc, lc_inv); m().del(lc); m().del(lc_inv); }
|
||||
void mk_monic(numeral_vector & p) { mk_monic(p.size(), p.c_ptr()); }
|
||||
void mk_monic(numeral_vector & p) { mk_monic(p.size(), p.data()); }
|
||||
|
||||
/**
|
||||
\brief g := gcd(p1, p2)
|
||||
|
@ -370,10 +370,10 @@ namespace upolynomial {
|
|||
void euclid_gcd(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & g);
|
||||
void subresultant_gcd(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & g);
|
||||
void gcd(numeral_vector const & p1, numeral_vector const & p2, numeral_vector & g) {
|
||||
gcd(p1.size(), p1.c_ptr(), p2.size(), p2.c_ptr(), g);
|
||||
gcd(p1.size(), p1.data(), p2.size(), p2.data(), g);
|
||||
}
|
||||
void subresultant_gcd(numeral_vector const & p1, numeral_vector const & p2, numeral_vector & g) {
|
||||
subresultant_gcd(p1.size(), p1.c_ptr(), p2.size(), p2.c_ptr(), g);
|
||||
subresultant_gcd(p1.size(), p1.data(), p2.size(), p2.data(), g);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,7 +390,7 @@ namespace upolynomial {
|
|||
\brief Return true if p is a square-free polynomial.
|
||||
*/
|
||||
bool is_square_free(numeral_vector const & p) {
|
||||
return is_square_free(p.size(), p.c_ptr());
|
||||
return is_square_free(p.size(), p.data());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -453,20 +453,20 @@ namespace upolynomial {
|
|||
*/
|
||||
void ext_gcd(unsigned szA, numeral const * A, unsigned szB, numeral const * B, numeral_vector & U, numeral_vector & V, numeral_vector & D);
|
||||
void ext_gcd(numeral_vector const & A, numeral_vector const & B, numeral_vector & U, numeral_vector & V, numeral_vector & D) {
|
||||
ext_gcd(A.size(), A.c_ptr(), B.size(), B.c_ptr(), U, V, D);
|
||||
ext_gcd(A.size(), A.data(), B.size(), B.data(), U, V, D);
|
||||
}
|
||||
|
||||
bool eq(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2);
|
||||
bool eq(numeral_vector const & p1, numeral_vector const & p2) { return eq(p1.size(), p1.c_ptr(), p2.size(), p2.c_ptr()); }
|
||||
bool eq(numeral_vector const & p1, numeral_vector const & p2) { return eq(p1.size(), p1.data(), p2.size(), p2.data()); }
|
||||
|
||||
std::ostream& display(std::ostream & out, unsigned sz, numeral const * p, char const * var_name = "x", bool use_star = false) const;
|
||||
std::ostream& display(std::ostream & out, numeral_vector const & p, char const * var_name = "x") const { return display(out, p.size(), p.c_ptr(), var_name); }
|
||||
std::ostream& display(std::ostream & out, numeral_vector const & p, char const * var_name = "x") const { return display(out, p.size(), p.data(), var_name); }
|
||||
std::ostream& display_star(std::ostream & out, unsigned sz, numeral const * p) { return display(out, sz, p, "x", true); }
|
||||
std::ostream& display_star(std::ostream & out, numeral_vector const & p) { return display_star(out, p.size(), p.c_ptr()); }
|
||||
std::ostream& display_star(std::ostream & out, numeral_vector const & p) { return display_star(out, p.size(), p.data()); }
|
||||
|
||||
std::ostream& display_smt2(std::ostream & out, unsigned sz, numeral const * p, char const * var_name = "x") const;
|
||||
std::ostream& display_smt2(std::ostream & out, numeral_vector const & p, char const * var_name = "x") const {
|
||||
return display_smt2(out, p.size(), p.c_ptr(), var_name);
|
||||
return display_smt2(out, p.size(), p.data(), var_name);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -531,7 +531,7 @@ namespace upolynomial {
|
|||
/**
|
||||
\brief Return the vector of coefficients for the i-th polynomial in the sequence.
|
||||
*/
|
||||
numeral const * coeffs(unsigned i) const { return m_seq_coeffs.c_ptr() + m_begins[i]; }
|
||||
numeral const * coeffs(unsigned i) const { return m_seq_coeffs.data() + m_begins[i]; }
|
||||
|
||||
/**
|
||||
\brief Return the size of the i-th polynomial in the sequence.
|
||||
|
@ -643,33 +643,33 @@ namespace upolynomial {
|
|||
\brief p(x) := p(x+1)
|
||||
*/
|
||||
void translate(unsigned sz, numeral * p);
|
||||
void translate(unsigned sz, numeral const * p, numeral_vector & buffer) { set(sz, p, buffer); translate(sz, buffer.c_ptr()); }
|
||||
void translate(unsigned sz, numeral const * p, numeral_vector & buffer) { set(sz, p, buffer); translate(sz, buffer.data()); }
|
||||
|
||||
/**
|
||||
\brief p(x) := p(x+2^k)
|
||||
*/
|
||||
void translate_k(unsigned sz, numeral * p, unsigned k);
|
||||
void translate_k(unsigned sz, numeral const * p, unsigned k, numeral_vector & buffer) { set(sz, p, buffer); translate_k(sz, buffer.c_ptr(), k); }
|
||||
void translate_k(unsigned sz, numeral const * p, unsigned k, numeral_vector & buffer) { set(sz, p, buffer); translate_k(sz, buffer.data(), k); }
|
||||
|
||||
/**
|
||||
\brief p(x) := p(x+c)
|
||||
*/
|
||||
void translate_z(unsigned sz, numeral * p, numeral const & c);
|
||||
void translate_z(unsigned sz, numeral const * p, numeral const & c, numeral_vector & buffer) { set(sz, p, buffer); translate_z(sz, buffer.c_ptr(), c); }
|
||||
void translate_z(unsigned sz, numeral const * p, numeral const & c, numeral_vector & buffer) { set(sz, p, buffer); translate_z(sz, buffer.data(), c); }
|
||||
|
||||
/**
|
||||
\brief p(x) := p(x+b) where b = c/2^k
|
||||
buffer := (2^k)^n * p(x + c/(2^k))
|
||||
*/
|
||||
void translate_bq(unsigned sz, numeral * p, mpbq const & b);
|
||||
void translate_bq(unsigned sz, numeral const * p, mpbq const & b, numeral_vector & buffer) { set(sz, p, buffer); translate_bq(sz, buffer.c_ptr(), b); }
|
||||
void translate_bq(unsigned sz, numeral const * p, mpbq const & b, numeral_vector & buffer) { set(sz, p, buffer); translate_bq(sz, buffer.data(), b); }
|
||||
|
||||
/**
|
||||
\brief p(x) := p(x+b) where b = c/d
|
||||
buffer := d^n * p(x + c/d)
|
||||
*/
|
||||
void translate_q(unsigned sz, numeral * p, mpq const & b);
|
||||
void translate_q(unsigned sz, numeral const * p, mpq const & b, numeral_vector & buffer) { set(sz, p, buffer); translate_q(sz, buffer.c_ptr(), b); }
|
||||
void translate_q(unsigned sz, numeral const * p, mpq const & b, numeral_vector & buffer) { set(sz, p, buffer); translate_q(sz, buffer.data(), b); }
|
||||
|
||||
/**
|
||||
\brief p(x) := 2^n*p(x/2) where n = sz-1
|
||||
|
@ -905,7 +905,7 @@ namespace upolynomial {
|
|||
This can happen when limits (e.g., on the search space size) are set in params.
|
||||
*/
|
||||
bool factor(unsigned sz, numeral const * p, factors & r, factor_params const & params = factor_params());
|
||||
bool factor(numeral_vector const & p, factors & r, factor_params const & params = factor_params()) { return factor(p.size(), p.c_ptr(), r, params); }
|
||||
bool factor(numeral_vector const & p, factors & r, factor_params const & params = factor_params()) { return factor(p.size(), p.data(), r, params); }
|
||||
|
||||
std::ostream& display(std::ostream & out, unsigned sz, numeral const * p, char const * var_name = "x", bool use_star = false) const {
|
||||
return core_manager::display(out, sz, p, var_name);
|
||||
|
|
|
@ -261,9 +261,9 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
// trim and get the make it monic if not already
|
||||
SASSERT(f.size() > 1);
|
||||
scoped_numeral_vector T_0(nm);
|
||||
upm.set(f.size(), f.c_ptr(), T_0);
|
||||
upm.set(f.size(), f.data(), T_0);
|
||||
scoped_numeral constant(nm);
|
||||
upm.mk_monic(T_0.size(), T_0.c_ptr(), constant);
|
||||
upm.mk_monic(T_0.size(), T_0.data(), constant);
|
||||
sq_free_factors.set_constant(constant);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "Initial factors: " << sq_free_factors << endl;
|
||||
|
@ -285,21 +285,21 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
TRACE("polynomial::factorization::bughunt", tout << "k = 0" << endl;);
|
||||
|
||||
// T_0_d = T_0'
|
||||
upm.derivative(T_0.size(), T_0.c_ptr(), T_0_d);
|
||||
upm.derivative(T_0.size(), T_0.data(), T_0_d);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "T_0_d = T_0.derivative(x)" << endl;
|
||||
tout << "T_0_d == "; upm.display(tout, T_0_d); tout << endl;
|
||||
);
|
||||
|
||||
// T = gcd(T_0, T_0')
|
||||
upm.gcd(T_0.size(), T_0.c_ptr(), T_0_d.size(), T_0_d.c_ptr(), T);
|
||||
upm.gcd(T_0.size(), T_0.data(), T_0_d.size(), T_0_d.data(), T);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "T = T_0.gcd(T_0_d)" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
);
|
||||
|
||||
// V = T_0 / T
|
||||
upm.div(T_0.size(), T_0.c_ptr(), T.size(), T.c_ptr(), V);
|
||||
upm.div(T_0.size(), T_0.data(), T.size(), T.data(), V);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "V = T_0.quo_rem(T)[0]" << endl;
|
||||
tout << "V == "; upm.display(tout, V); tout << endl;
|
||||
|
@ -310,7 +310,7 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
if ((++k) % p == 0) {
|
||||
++ k;
|
||||
// T = T/V
|
||||
upm.div(T.size(), T.c_ptr(), V.size(), V.c_ptr(), T);
|
||||
upm.div(T.size(), T.data(), V.size(), V.data(), T);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "T = T.quo_rem(V)[0]" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
|
@ -320,14 +320,14 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
// [compute A_ek]
|
||||
|
||||
// W = gcd(T, V)
|
||||
upm.gcd(T.size(), T.c_ptr(), V.size(), V.c_ptr(), W);
|
||||
upm.gcd(T.size(), T.data(), V.size(), V.data(), W);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "W = T.gcd(V)" << endl;
|
||||
upm.display(tout, W); tout << endl;
|
||||
);
|
||||
|
||||
// A_ek = V/W
|
||||
upm.div(V.size(), V.c_ptr(), W.size(), W.c_ptr(), A_ek);
|
||||
upm.div(V.size(), V.data(), W.size(), W.data(), A_ek);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "A_ek = V.quo_rem(W)[0]" << endl;
|
||||
tout << "A_ek == "; upm.display(tout, A_ek); tout << endl;
|
||||
|
@ -341,7 +341,7 @@ void zp_square_free_factor(zp_manager & upm, numeral_vector const & f, zp_factor
|
|||
);
|
||||
|
||||
// T = T/V
|
||||
upm.div(T.size(), T.c_ptr(), V.size(), V.c_ptr(), T);
|
||||
upm.div(T.size(), T.data(), V.size(), V.data(), T);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "T = T.quo_rem(V)[0]" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
|
@ -471,13 +471,13 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f,
|
|||
zpm.dec(v_k[0]);
|
||||
|
||||
// get the gcd
|
||||
upm.gcd(v_k.size(), v_k.c_ptr(), current_factor.size(), current_factor.c_ptr(), gcd);
|
||||
upm.gcd(v_k.size(), v_k.data(), current_factor.size(), current_factor.data(), gcd);
|
||||
|
||||
// if the gcd is 1, or the gcd is f, we just ignore it
|
||||
if (gcd.size() != 1 && gcd.size() != current_factor.size()) {
|
||||
|
||||
// get the divisor also (no need to normalize the div, both are monic)
|
||||
upm.div(current_factor.size(), current_factor.c_ptr(), gcd.size(), gcd.c_ptr(), div);
|
||||
upm.div(current_factor.size(), current_factor.data(), gcd.size(), gcd.data(), div);
|
||||
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "current_factor = "; upm.display(tout, current_factor); tout << endl;
|
||||
|
@ -529,8 +529,8 @@ bool check_hansel_lift(z_manager & upm, numeral_vector const & C,
|
|||
|
||||
// test1: check that C = A_lifted * B_lifted (mod b*r)
|
||||
scoped_mpz_vector test1(nm);
|
||||
upm.mul(A_lifted.size(), A_lifted.c_ptr(), B_lifted.size(), B_lifted.c_ptr(), test1);
|
||||
upm.sub(C.size(), C.c_ptr(), test1.size(), test1.c_ptr(), test1);
|
||||
upm.mul(A_lifted.size(), A_lifted.data(), B_lifted.size(), B_lifted.data(), test1);
|
||||
upm.sub(C.size(), C.data(), test1.size(), test1.data(), test1);
|
||||
to_zp_manager(br_upm, test1);
|
||||
if (!test1.empty()) {
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
|
@ -607,8 +607,8 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral
|
|||
// by (2) C = AB (mod b), hence (C - AB) is divisible by b
|
||||
// define thus let f = (C - AB)/b in Z_r
|
||||
scoped_numeral_vector f(upm.m());
|
||||
upm.mul(A.size(), A.c_ptr(), B.size(), B.c_ptr(), f);
|
||||
upm.sub(C.size(), C.c_ptr(), f.size(), f.c_ptr(), f);
|
||||
upm.mul(A.size(), A.data(), B.size(), B.data(), f);
|
||||
upm.sub(C.size(), C.data(), f.size(), f.data(), f);
|
||||
upm.div(f, b);
|
||||
to_zp_manager(r_upm, f);
|
||||
TRACE("polynomial::factorization",
|
||||
|
@ -637,29 +637,29 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral
|
|||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "V == "; upm.display(tout, V); tout << endl;
|
||||
);
|
||||
r_upm.mul(V.size(), V.c_ptr(), f.size(), f.c_ptr(), Vf);
|
||||
r_upm.mul(V.size(), V.data(), f.size(), f.data(), Vf);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "Vf = V*f" << endl;
|
||||
tout << "Vf == "; upm.display(tout, Vf); tout << endl;
|
||||
);
|
||||
r_upm.div_rem(Vf.size(), Vf.c_ptr(), A.size(), A.c_ptr(), t, S);
|
||||
r_upm.div_rem(Vf.size(), Vf.data(), A.size(), A.data(), t, S);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "[t, S] = Vf.quo_rem(A)" << endl;
|
||||
tout << "t == "; upm.display(tout, t); tout << endl;
|
||||
tout << "S == "; upm.display(tout, S); tout << endl;
|
||||
);
|
||||
scoped_numeral_vector T(r_upm.m()), tmp(r_upm.m());
|
||||
r_upm.mul(U.size(), U.c_ptr(), f.size(), f.c_ptr(), T); // T = fU
|
||||
r_upm.mul(U.size(), U.data(), f.size(), f.data(), T); // T = fU
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "T == U*f" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
);
|
||||
r_upm.mul(B.size(), B.c_ptr(), t.size(), t.c_ptr(), tmp); // tmp = Bt
|
||||
r_upm.mul(B.size(), B.data(), t.size(), t.data(), tmp); // tmp = Bt
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "tmp = B*t" << endl;
|
||||
tout << "tmp == "; upm.display(tout, tmp); tout << endl;
|
||||
);
|
||||
r_upm.add(T.size(), T.c_ptr(), tmp.size(), tmp.c_ptr(), T); // T = Uf + Bt
|
||||
r_upm.add(T.size(), T.data(), tmp.size(), tmp.data(), T); // T = Uf + Bt
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "T = B*tmp" << endl;
|
||||
tout << "T == "; upm.display(tout, T); tout << endl;
|
||||
|
@ -668,8 +668,8 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral
|
|||
// set the result, A1 = A + b*S, B1 = B + b*T (now we compute in Z[x])
|
||||
upm.mul(S, b);
|
||||
upm.mul(T, b);
|
||||
upm.add(A.size(), A.c_ptr(), S.size(), S.c_ptr(), A_lifted);
|
||||
upm.add(B.size(), B.c_ptr(), T.size(), T.c_ptr(), B_lifted);
|
||||
upm.add(A.size(), A.data(), S.size(), S.data(), A_lifted);
|
||||
upm.add(B.size(), B.data(), T.size(), T.data(), B_lifted);
|
||||
|
||||
CASSERT("polynomial::factorizatio::bughunt", check_hansel_lift(upm, C, a, b, r, A, B, A_lifted, B_lifted));
|
||||
}
|
||||
|
@ -680,10 +680,10 @@ bool check_quadratic_hensel(zp_manager & zpe_upm, numeral_vector const & U, nume
|
|||
// compute UA+BV expecting to get 1 (in Z_pe[x])
|
||||
scoped_mpz_vector tmp1(nm);
|
||||
scoped_mpz_vector tmp2(nm);
|
||||
zpe_upm.mul(U.size(), U.c_ptr(), A.size(), A.c_ptr(), tmp1);
|
||||
zpe_upm.mul(V.size(), V.c_ptr(), B.size(), B.c_ptr(), tmp2);
|
||||
zpe_upm.mul(U.size(), U.data(), A.size(), A.data(), tmp1);
|
||||
zpe_upm.mul(V.size(), V.data(), B.size(), B.data(), tmp2);
|
||||
scoped_mpz_vector one(nm);
|
||||
zpe_upm.add(tmp1.size(), tmp1.c_ptr(), tmp2.size(), tmp2.c_ptr(), one);
|
||||
zpe_upm.add(tmp1.size(), tmp1.data(), tmp2.size(), tmp2.data(), one);
|
||||
if (one.size() != 1 || !nm.is_one(one[0])) {
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "sage: R.<x> = Zmod(" << nm.to_string(zpe_upm.m().p()) << ")['x']" << endl;
|
||||
|
@ -724,7 +724,7 @@ void hensel_lift_quadratic(z_manager& upm, numeral_vector const & C,
|
|||
|
||||
// get the U, V, such that A*U + B*V = 1 (mod p)
|
||||
scoped_mpz_vector U(nm), V(nm), D(nm);
|
||||
zp_upm.ext_gcd(A.size(), A.c_ptr(), B.size(), B.c_ptr(), U, V, D);
|
||||
zp_upm.ext_gcd(A.size(), A.data(), B.size(), B.data(), U, V, D);
|
||||
SASSERT(D.size() == 1 && zp_upm.m().is_one(D[0]));
|
||||
|
||||
// we start lifting from (a = p, b = p, r = p)
|
||||
|
@ -762,10 +762,10 @@ void hensel_lift_quadratic(z_manager& upm, numeral_vector const & C,
|
|||
scoped_mpz_vector tmp1(nm), g(nm);
|
||||
g.push_back(numeral());
|
||||
nm.set(g.back(), 1); // g = 1
|
||||
upm.mul(A_lifted.size(), A_lifted.c_ptr(), U.size(), U.c_ptr(), tmp1); // tmp1 = AU
|
||||
upm.sub(g.size(), g.c_ptr(), tmp1.size(), tmp1.c_ptr(), g); // g = 1 - UA
|
||||
upm.mul(B_lifted.size(), B_lifted.c_ptr(), V.size(), V.c_ptr(), tmp1); // tmp1 = BV
|
||||
upm.sub(g.size(), g.c_ptr(), tmp1.size(), tmp1.c_ptr(), g); // g = 1 - UA - VB
|
||||
upm.mul(A_lifted.size(), A_lifted.data(), U.size(), U.data(), tmp1); // tmp1 = AU
|
||||
upm.sub(g.size(), g.data(), tmp1.size(), tmp1.data(), g); // g = 1 - UA
|
||||
upm.mul(B_lifted.size(), B_lifted.data(), V.size(), V.data(), tmp1); // tmp1 = BV
|
||||
upm.sub(g.size(), g.data(), tmp1.size(), tmp1.data(), g); // g = 1 - UA - VB
|
||||
upm.div(g, pe);
|
||||
to_zp_manager(zpe_upm, g);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
|
@ -775,17 +775,17 @@ void hensel_lift_quadratic(z_manager& upm, numeral_vector const & C,
|
|||
|
||||
// compute the S, T
|
||||
scoped_mpz_vector S(nm), T(nm), t(nm), tmp2(nm);
|
||||
zpe_upm.mul(g.size(), g.c_ptr(), V.size(), V.c_ptr(), tmp1); // tmp1 = gV
|
||||
zpe_upm.div_rem(tmp1.size(), tmp1.c_ptr(), A.size(), A.c_ptr(), t, T); // T = gV - tA, deg(T) < deg(A)
|
||||
zpe_upm.mul(g.size(), g.c_ptr(), U.size(), U.c_ptr(), tmp1); // tmp1 = gU
|
||||
zpe_upm.mul(t.size(), t.c_ptr(), B.size(), B.c_ptr(), tmp2); // tmp2 = tB
|
||||
zpe_upm.add(tmp1.size(), tmp1.c_ptr(), tmp2.size(), tmp2.c_ptr(), S);
|
||||
zpe_upm.mul(g.size(), g.data(), V.size(), V.data(), tmp1); // tmp1 = gV
|
||||
zpe_upm.div_rem(tmp1.size(), tmp1.data(), A.size(), A.data(), t, T); // T = gV - tA, deg(T) < deg(A)
|
||||
zpe_upm.mul(g.size(), g.data(), U.size(), U.data(), tmp1); // tmp1 = gU
|
||||
zpe_upm.mul(t.size(), t.data(), B.size(), B.data(), tmp2); // tmp2 = tB
|
||||
zpe_upm.add(tmp1.size(), tmp1.data(), tmp2.size(), tmp2.data(), S);
|
||||
|
||||
// now update U = U + a*S and V = V + a*T
|
||||
upm.mul(S.size(), S.c_ptr(), pe);
|
||||
upm.mul(T.size(), T.c_ptr(), pe);
|
||||
upm.add(U.size(), U.c_ptr(), S.size(), S.c_ptr(), U);
|
||||
upm.add(V.size(), V.c_ptr(), T.size(), T.c_ptr(), V); // deg(V) < deg(A), deg(T) < deg(A) => deg(V') < deg(A)
|
||||
upm.mul(S.size(), S.data(), pe);
|
||||
upm.mul(T.size(), T.data(), pe);
|
||||
upm.add(U.size(), U.data(), S.size(), S.data(), U);
|
||||
upm.add(V.size(), V.data(), T.size(), T.data(), V); // deg(V) < deg(A), deg(T) < deg(A) => deg(V') < deg(A)
|
||||
|
||||
// we go quadratic
|
||||
zpe_upm.m().set_p_sq();
|
||||
|
@ -891,7 +891,7 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
scoped_mpz_vector A(nm), B(nm), C(nm), f_parts(nm); // these will all be in Z_p
|
||||
|
||||
// copy of f, that we'll be cutting parts of
|
||||
upm.set(f.size(), f.c_ptr(), f_parts);
|
||||
upm.set(f.size(), f.data(), f_parts);
|
||||
|
||||
// F_k are factors mod Z_p, A_k the factors mod p^e
|
||||
// the invariant we keep is that:
|
||||
|
@ -902,7 +902,7 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
SASSERT(zp_fs.get_degree(i) == 1); // p was chosen so that f is square-free
|
||||
|
||||
// F_i = A (mod Z_p)
|
||||
zp_upm.set(zp_fs[i].size(), zp_fs[i].c_ptr(), A);
|
||||
zp_upm.set(zp_fs[i].size(), zp_fs[i].data(), A);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "A = "; upm.display(tout, A); tout << endl;
|
||||
);
|
||||
|
@ -923,7 +923,7 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
);
|
||||
|
||||
// we take B to be what's left from C and A
|
||||
zp_upm.div(C.size(), C.c_ptr(), A.size(), A.c_ptr(), B);
|
||||
zp_upm.div(C.size(), C.data(), A.size(), A.data(), B);
|
||||
TRACE("polynomial::factorization::bughunt",
|
||||
tout << "B = "; upm.display(tout, B); tout << endl;
|
||||
);
|
||||
|
@ -944,7 +944,7 @@ void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & z
|
|||
}
|
||||
|
||||
// take the lifted A out of f_parts
|
||||
zpe_upm.div(f_parts.size(), f_parts.c_ptr(), A.size(), A.c_ptr(), f_parts);
|
||||
zpe_upm.div(f_parts.size(), f_parts.data(), A.size(), A.data(), f_parts);
|
||||
|
||||
// add the lifted factor (kills A)
|
||||
zpe_fs.push_back_swap(A, 1);
|
||||
|
@ -1029,12 +1029,12 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
// This method assumes f is primitive. Thus, the content of f must be one
|
||||
DEBUG_CODE({
|
||||
scoped_numeral f_cont(nm);
|
||||
nm.gcd(f.size(), f.c_ptr(), f_cont);
|
||||
nm.gcd(f.size(), f.data(), f_cont);
|
||||
SASSERT(f.size() == 0 || nm.is_one(f_cont));
|
||||
});
|
||||
|
||||
scoped_numeral_vector f_pp(nm);
|
||||
upm.set(f.size(), f.c_ptr(), f_pp);
|
||||
upm.set(f.size(), f.data(), f_pp);
|
||||
|
||||
// make sure the leading coefficient is positive
|
||||
if (!f_pp.empty() && nm.is_neg(f_pp[f_pp.size() - 1])) {
|
||||
|
@ -1103,11 +1103,11 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
tout << "sage: f_pp_zp = "; zp_upm.display(tout, f_pp_zp, "x_p"); tout << endl;
|
||||
);
|
||||
|
||||
if (!zp_upm.is_square_free(f_pp_zp.size(), f_pp_zp.c_ptr()))
|
||||
if (!zp_upm.is_square_free(f_pp_zp.size(), f_pp_zp.data()))
|
||||
continue;
|
||||
|
||||
// we make it monic
|
||||
zp_upm.mk_monic(f_pp_zp.size(), f_pp_zp.c_ptr());
|
||||
zp_upm.mk_monic(f_pp_zp.size(), f_pp_zp.data());
|
||||
|
||||
// found a candidate, factorize in Z_p and add back the constant
|
||||
zp_factors current_fs(zp_upm);
|
||||
|
|
|
@ -345,9 +345,9 @@ namespace upolynomial {
|
|||
void left(numeral_vector & out) const {
|
||||
SASSERT(m_current_size > 0);
|
||||
zp_manager & upm = m_factors.upm();
|
||||
upm.set(m_factors[m_current[0]].size(), m_factors[m_current[0]].c_ptr(), out);
|
||||
upm.set(m_factors[m_current[0]].size(), m_factors[m_current[0]].data(), out);
|
||||
for (int i = 1; i < m_current_size; ++ i) {
|
||||
upm.mul(out.size(), out.c_ptr(), m_factors[m_current[i]].size(), m_factors[m_current[i]].c_ptr(), out);
|
||||
upm.mul(out.size(), out.data(), m_factors[m_current[i]].size(), m_factors[m_current[i]].data(), out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,9 +401,9 @@ namespace upolynomial {
|
|||
if (selection_i >= m_current.size() || (int) current < m_current[selection_i]) {
|
||||
SASSERT(m_factors.get_degree(current) == 1);
|
||||
if (out.empty()) {
|
||||
upm.set(m_factors[current].size(), m_factors[current].c_ptr(), out);
|
||||
upm.set(m_factors[current].size(), m_factors[current].data(), out);
|
||||
} else {
|
||||
upm.mul(out.size(), out.c_ptr(), m_factors[current].size(), m_factors[current].c_ptr(), out);
|
||||
upm.mul(out.size(), out.data(), m_factors[current].size(), m_factors[current].data(), out);
|
||||
}
|
||||
current ++;
|
||||
} else {
|
||||
|
|
|
@ -431,7 +431,7 @@ namespace realclosure {
|
|||
\brief Return the vector of coefficients for the i-th polynomial in the sequence.
|
||||
*/
|
||||
value * const * coeffs(unsigned i) const {
|
||||
return m_seq_coeffs.c_ptr() + m_begins[i];
|
||||
return m_seq_coeffs.data() + m_begins[i];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,7 +462,7 @@ namespace realclosure {
|
|||
|
||||
scoped_sign_conditions(imp & m):m_imp(m) {}
|
||||
~scoped_sign_conditions() {
|
||||
m_imp.del_sign_conditions(m_scs.size(), m_scs.c_ptr());
|
||||
m_imp.del_sign_conditions(m_scs.size(), m_scs.data());
|
||||
}
|
||||
|
||||
sign_condition * & operator[](unsigned idx) { return m_scs[idx]; }
|
||||
|
@ -476,10 +476,10 @@ namespace realclosure {
|
|||
void copy_from(scoped_sign_conditions & scs) {
|
||||
SASSERT(this != &scs);
|
||||
release();
|
||||
m_scs.append(scs.m_scs.size(), scs.m_scs.c_ptr());
|
||||
m_scs.append(scs.m_scs.size(), scs.m_scs.data());
|
||||
scs.release();
|
||||
}
|
||||
sign_condition * const * c_ptr() { return m_scs.c_ptr(); }
|
||||
sign_condition * const * data() { return m_scs.data(); }
|
||||
};
|
||||
|
||||
struct scoped_inc_depth {
|
||||
|
@ -748,7 +748,7 @@ namespace realclosure {
|
|||
That is, after the call p is the 0 polynomial.
|
||||
*/
|
||||
void reset_p(polynomial & p) {
|
||||
dec_ref(p.size(), p.c_ptr());
|
||||
dec_ref(p.size(), p.data());
|
||||
p.finalize(allocator());
|
||||
}
|
||||
|
||||
|
@ -800,7 +800,7 @@ namespace realclosure {
|
|||
|
||||
void del_sign_det(sign_det * sd) {
|
||||
mm().del(sd->M_s);
|
||||
del_sign_conditions(sd->m_sign_conditions.size(), sd->m_sign_conditions.c_ptr());
|
||||
del_sign_conditions(sd->m_sign_conditions.size(), sd->m_sign_conditions.data());
|
||||
sd->m_sign_conditions.finalize(allocator());
|
||||
finalize(sd->m_prs);
|
||||
sd->m_taqrs.finalize(allocator());
|
||||
|
@ -1555,7 +1555,7 @@ namespace realclosure {
|
|||
bool pos_root_lower_bound(unsigned n, value * const * p, int & N) {
|
||||
value_ref_buffer q(*this);
|
||||
reverse(n, p, q);
|
||||
if (pos_root_upper_bound(n, q.c_ptr(), N)) {
|
||||
if (pos_root_upper_bound(n, q.data(), N)) {
|
||||
N = -N;
|
||||
return true;
|
||||
}
|
||||
|
@ -1570,7 +1570,7 @@ namespace realclosure {
|
|||
bool neg_root_upper_bound(unsigned n, value * const * p, int & N) {
|
||||
value_ref_buffer q(*this);
|
||||
reverse(n, p, q);
|
||||
if (neg_root_lower_bound(n, q.c_ptr(), N)) {
|
||||
if (neg_root_lower_bound(n, q.data(), N)) {
|
||||
N = -N;
|
||||
return true;
|
||||
}
|
||||
|
@ -1590,7 +1590,7 @@ namespace realclosure {
|
|||
SASSERT(!is_zero(p[n-1]));
|
||||
value_ref_buffer p_prime(*this);
|
||||
derivative(n, p, p_prime);
|
||||
ds.push(p_prime.size(), p_prime.c_ptr());
|
||||
ds.push(p_prime.size(), p_prime.data());
|
||||
SASSERT(n >= 3);
|
||||
for (unsigned i = 0; i < n - 2; i++) {
|
||||
SASSERT(ds.size() > 0);
|
||||
|
@ -1598,7 +1598,7 @@ namespace realclosure {
|
|||
n = ds.size(prev);
|
||||
p = ds.coeffs(prev);
|
||||
derivative(n, p, p_prime);
|
||||
ds.push(p_prime.size(), p_prime.c_ptr());
|
||||
ds.push(p_prime.size(), p_prime.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1645,7 +1645,7 @@ namespace realclosure {
|
|||
// Expensive case
|
||||
// q2 <- q^2
|
||||
mul(q_sz, q, q_sz, q, q2);
|
||||
int taq_p_q2 = TaQ(p_sz, p, q2.size(), q2.c_ptr(), interval);
|
||||
int taq_p_q2 = TaQ(p_sz, p, q2.size(), q2.data(), interval);
|
||||
SASSERT(0 <= taq_p_q2 && taq_p_q2 <= num_roots);
|
||||
// taq_p_q2 == q_gt_0 + q_lt_0
|
||||
SASSERT((taq_p_q2 + taq_p_q) % 2 == 0);
|
||||
|
@ -1719,15 +1719,15 @@ namespace realclosure {
|
|||
// Add prs * q
|
||||
value_ref_buffer prq(*this);
|
||||
mul(prs.size(i), prs.coeffs(i), q_sz, q, prq);
|
||||
new_taqrs.push_back(TaQ(p_sz, p, prq.size(), prq.c_ptr(), interval));
|
||||
new_prs.push(prq.size(), prq.c_ptr());
|
||||
new_taqrs.push_back(TaQ(p_sz, p, prq.size(), prq.data(), interval));
|
||||
new_prs.push(prq.size(), prq.data());
|
||||
// If use_q2,
|
||||
// Add prs * q^2
|
||||
if (use_q2) {
|
||||
value_ref_buffer prq2(*this);
|
||||
mul(prs.size(i), prs.coeffs(i), q2_sz, q2, prq2);
|
||||
new_taqrs.push_back(TaQ(p_sz, p, prq2.size(), prq2.c_ptr(), interval));
|
||||
new_prs.push(prq2.size(), prq2.c_ptr());
|
||||
new_taqrs.push_back(TaQ(p_sz, p, prq2.size(), prq2.data(), interval));
|
||||
new_prs.push(prq2.size(), prq2.data());
|
||||
}
|
||||
}
|
||||
SASSERT(new_prs.size() == new_taqrs.size());
|
||||
|
@ -1795,9 +1795,9 @@ namespace realclosure {
|
|||
sign_det * r = new (allocator()) sign_det();
|
||||
r->M_s.swap(M_s);
|
||||
set_array_p(r->m_prs, prs);
|
||||
r->m_taqrs.set(allocator(), taqrs.size(), taqrs.c_ptr());
|
||||
r->m_taqrs.set(allocator(), taqrs.size(), taqrs.data());
|
||||
set_array_p(r->m_qs, qs);
|
||||
r->m_sign_conditions.set(allocator(), scs.size(), scs.c_ptr());
|
||||
r->m_sign_conditions.set(allocator(), scs.size(), scs.data());
|
||||
scs.release();
|
||||
return r;
|
||||
}
|
||||
|
@ -2019,7 +2019,7 @@ namespace realclosure {
|
|||
}
|
||||
bool use_q2 = M.n() == 3;
|
||||
mm().tensor_product(M_s, M, new_M_s);
|
||||
expand_taqrs(taqrs, prs, p_sz, p, q_sz, q, use_q2, q2.size(), q2.c_ptr(), iso_interval,
|
||||
expand_taqrs(taqrs, prs, p_sz, p, q_sz, q, use_q2, q2.size(), q2.data(), iso_interval,
|
||||
// --->
|
||||
new_taqrs, new_prs);
|
||||
SASSERT(new_M_s.n() == new_M_s.m()); // it is a square matrix
|
||||
|
@ -2029,7 +2029,7 @@ namespace realclosure {
|
|||
sc_cardinalities.resize(new_taqrs.size(), 0);
|
||||
// Solve
|
||||
// new_M_s * sc_cardinalities = new_taqrs
|
||||
VERIFY(mm().solve(new_M_s, sc_cardinalities.c_ptr(), new_taqrs.c_ptr()));
|
||||
VERIFY(mm().solve(new_M_s, sc_cardinalities.data(), new_taqrs.data()));
|
||||
TRACE("rcf_sign_det", tout << "solution: "; for (unsigned i = 0; i < sc_cardinalities.size(); i++) { tout << sc_cardinalities[i] << " "; } tout << "\n";);
|
||||
// The solution must contain only positive values <= num_roots
|
||||
DEBUG_CODE(for (unsigned j = 0; j < sc_cardinalities.size(); j++) { SASSERT(0 <= sc_cardinalities[j] && sc_cardinalities[j] <= num_roots); });
|
||||
|
@ -2037,7 +2037,7 @@ namespace realclosure {
|
|||
// That is,
|
||||
// If !use_q2, then There is an i s.t. sc_cardinalities[2*i] > 0 && sc_cardinalities[2*i] > 0
|
||||
// If use_q2, then There is an i s.t. AtLeastTwo(sc_cardinalities[3*i] > 0, sc_cardinalities[3*i+1] > 0, sc_cardinalities[3*i+2] > 0)
|
||||
if (!keep_new_sc_assignment(sc_cardinalities.size(), sc_cardinalities.c_ptr(), use_q2)) {
|
||||
if (!keep_new_sc_assignment(sc_cardinalities.size(), sc_cardinalities.data(), use_q2)) {
|
||||
// skip q since it did not reduced the cardinality of the existing sign conditions.
|
||||
continue;
|
||||
}
|
||||
|
@ -2068,10 +2068,10 @@ namespace realclosure {
|
|||
scs.copy_from(new_scs);
|
||||
SASSERT(new_scs.empty());
|
||||
// Update M_s
|
||||
mm().filter_cols(new_M_s, cols_to_keep.size(), cols_to_keep.c_ptr(), M_s);
|
||||
mm().filter_cols(new_M_s, cols_to_keep.size(), cols_to_keep.data(), M_s);
|
||||
SASSERT(M_s.n() == cols_to_keep.size());
|
||||
new_row_idxs.resize(cols_to_keep.size(), 0);
|
||||
unsigned new_num_rows = mm().linear_independent_rows(M_s, new_row_idxs.c_ptr(), M_s);
|
||||
unsigned new_num_rows = mm().linear_independent_rows(M_s, new_row_idxs.data(), M_s);
|
||||
SASSERT(new_num_rows == cols_to_keep.size());
|
||||
// Update taqrs and prs
|
||||
prs.reset();
|
||||
|
@ -2387,7 +2387,7 @@ namespace realclosure {
|
|||
}
|
||||
value_ref_buffer sqf(*this);
|
||||
square_free(n, p, sqf);
|
||||
nz_sqf_isolate_roots(sqf.size(), sqf.c_ptr(), roots);
|
||||
nz_sqf_isolate_roots(sqf.size(), sqf.data(), roots);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2401,7 +2401,7 @@ namespace realclosure {
|
|||
value_ref d(*this);
|
||||
value_ref_buffer norm_p(*this);
|
||||
clean_denominators(n, p, norm_p, d);
|
||||
nz_cd_isolate_roots(norm_p.size(), norm_p.c_ptr(), roots);
|
||||
nz_cd_isolate_roots(norm_p.size(), norm_p.data(), roots);
|
||||
}
|
||||
else {
|
||||
nz_cd_isolate_roots(n, p, roots);
|
||||
|
@ -2429,7 +2429,7 @@ namespace realclosure {
|
|||
ptr_buffer<value> nz_p;
|
||||
for (; i < n; i++)
|
||||
nz_p.push_back(p[i].m_value);
|
||||
nz_isolate_roots(nz_p.size(), nz_p.c_ptr(), roots);
|
||||
nz_isolate_roots(nz_p.size(), nz_p.data(), roots);
|
||||
if (nz_p.size() < n) {
|
||||
// zero is a root
|
||||
roots.push_back(numeral());
|
||||
|
@ -2675,8 +2675,8 @@ namespace realclosure {
|
|||
\brief r <- p1 + p2
|
||||
*/
|
||||
void add(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.c_ptr());
|
||||
SASSERT(p2 != r.c_ptr());
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
r.reset();
|
||||
value_ref a_i(*this);
|
||||
unsigned min = std::min(sz1, sz2);
|
||||
|
@ -2697,7 +2697,7 @@ namespace realclosure {
|
|||
\brief r <- p + a
|
||||
*/
|
||||
void add(unsigned sz, value * const * p, value * a, value_ref_buffer & r) {
|
||||
SASSERT(p != r.c_ptr());
|
||||
SASSERT(p != r.data());
|
||||
SASSERT(sz > 0);
|
||||
r.reset();
|
||||
value_ref a_0(*this);
|
||||
|
@ -2711,8 +2711,8 @@ namespace realclosure {
|
|||
\brief r <- p1 - p2
|
||||
*/
|
||||
void sub(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.c_ptr());
|
||||
SASSERT(p2 != r.c_ptr());
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
r.reset();
|
||||
value_ref a_i(*this);
|
||||
unsigned min = std::min(sz1, sz2);
|
||||
|
@ -2735,7 +2735,7 @@ namespace realclosure {
|
|||
\brief r <- p - a
|
||||
*/
|
||||
void sub(unsigned sz, value * const * p, value * a, value_ref_buffer & r) {
|
||||
SASSERT(p != r.c_ptr());
|
||||
SASSERT(p != r.data());
|
||||
SASSERT(sz > 0);
|
||||
r.reset();
|
||||
value_ref a_0(*this);
|
||||
|
@ -2749,7 +2749,7 @@ namespace realclosure {
|
|||
\brief r <- a * p
|
||||
*/
|
||||
void mul(value * a, unsigned sz, value * const * p, value_ref_buffer & r) {
|
||||
SASSERT(p != r.c_ptr());
|
||||
SASSERT(p != r.data());
|
||||
r.reset();
|
||||
if (a == nullptr)
|
||||
return;
|
||||
|
@ -2764,8 +2764,8 @@ namespace realclosure {
|
|||
\brief r <- p1 * p2
|
||||
*/
|
||||
void mul(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.c_ptr());
|
||||
SASSERT(p2 != r.c_ptr());
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
r.reset();
|
||||
unsigned sz = sz1*sz2;
|
||||
r.resize(sz);
|
||||
|
@ -2877,8 +2877,8 @@ namespace realclosure {
|
|||
\brief r <- rem(p1, p2)
|
||||
*/
|
||||
void rem(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.c_ptr());
|
||||
SASSERT(p2 != r.c_ptr());
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
TRACE("rcf_rem",
|
||||
tout << "rem\n";
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
|
@ -2898,7 +2898,7 @@ namespace realclosure {
|
|||
checkpoint();
|
||||
sz1 = r.size();
|
||||
if (sz1 < sz2) {
|
||||
TRACE("rcf_rem", tout << "rem result\n"; display_poly(tout, r.size(), r.c_ptr()); tout << "\n";);
|
||||
TRACE("rcf_rem", tout << "rem result\n"; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
unsigned m_n = sz1 - sz2;
|
||||
|
@ -2921,8 +2921,8 @@ namespace realclosure {
|
|||
That is, if has_clean_denominators(p1) and has_clean_denominators(p2) then has_clean_denominators(r).
|
||||
*/
|
||||
void prem(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, unsigned & d, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.c_ptr());
|
||||
SASSERT(p2 != r.c_ptr());
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
TRACE("rcf_prem",
|
||||
tout << "prem\n";
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
|
@ -2943,7 +2943,7 @@ namespace realclosure {
|
|||
checkpoint();
|
||||
sz1 = r.size();
|
||||
if (sz1 < sz2) {
|
||||
TRACE("rcf_prem", tout << "prem result\n"; display_poly(tout, r.size(), r.c_ptr()); tout << "\n";);
|
||||
TRACE("rcf_prem", tout << "prem result\n"; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
unsigned m_n = sz1 - sz2;
|
||||
|
@ -2979,7 +2979,7 @@ namespace realclosure {
|
|||
\brief r <- -p
|
||||
*/
|
||||
void neg(unsigned sz, value * const * p, value_ref_buffer & r) {
|
||||
SASSERT(p != r.c_ptr());
|
||||
SASSERT(p != r.data());
|
||||
r.reset();
|
||||
value_ref a_i(*this);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
|
@ -3019,8 +3019,8 @@ namespace realclosure {
|
|||
Signed remainder
|
||||
*/
|
||||
void srem(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.c_ptr());
|
||||
SASSERT(p2 != r.c_ptr());
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
rem(sz1, p1, sz2, p2, r);
|
||||
neg(r);
|
||||
}
|
||||
|
@ -3030,8 +3030,8 @@ namespace realclosure {
|
|||
Signed pseudo remainder
|
||||
*/
|
||||
void sprem(unsigned sz1, value * const * p1, unsigned sz2, value * const * p2, value_ref_buffer & r) {
|
||||
SASSERT(p1 != r.c_ptr());
|
||||
SASSERT(p2 != r.c_ptr());
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
unsigned d;
|
||||
prem(sz1, p1, sz2, p2, d, r);
|
||||
// We should not flip the sign if d is odd and leading coefficient of p2 is negative.
|
||||
|
@ -3094,7 +3094,7 @@ namespace realclosure {
|
|||
bool struct_eq(value * a, value * b)
|
||||
*/
|
||||
bool struct_eq(polynomial const & p_a, polynomial const & p_b) const {
|
||||
return struct_eq(p_a.size(), p_a.c_ptr(), p_b.size(), p_b.c_ptr());
|
||||
return struct_eq(p_a.size(), p_a.data(), p_b.size(), p_b.data());
|
||||
}
|
||||
|
||||
// ---------------------------------
|
||||
|
@ -3135,7 +3135,7 @@ namespace realclosure {
|
|||
\brief See comment at has_clean_denominators(value * a)
|
||||
*/
|
||||
bool has_clean_denominators(polynomial const & p) const {
|
||||
return has_clean_denominators(p.size(), p.c_ptr());
|
||||
return has_clean_denominators(p.size(), p.data());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3170,8 +3170,8 @@ namespace realclosure {
|
|||
}
|
||||
value_ref x(*this);
|
||||
x = mk_rational_function_value(rf_a->ext());
|
||||
mk_polynomial_value(p_num.size(), p_num.c_ptr(), x, p);
|
||||
mk_polynomial_value(p_den.size(), p_den.c_ptr(), x, q);
|
||||
mk_polynomial_value(p_num.size(), p_num.data(), x, p);
|
||||
mk_polynomial_value(p_den.size(), p_den.data(), x, q);
|
||||
if (!struct_eq(d_den, d_num)) {
|
||||
mul(p, d_den, p);
|
||||
mul(q, d_num, q);
|
||||
|
@ -3299,7 +3299,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void clean_denominators_core(polynomial const & p, value_ref_buffer & norm_p, value_ref & d) {
|
||||
clean_denominators_core(p.size(), p.c_ptr(), norm_p, d);
|
||||
clean_denominators_core(p.size(), p.data(), norm_p, d);
|
||||
}
|
||||
|
||||
void clean_denominators(value * a, value_ref & p, value_ref & q) {
|
||||
|
@ -3323,7 +3323,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void clean_denominators(polynomial const & p, value_ref_buffer & norm_p, value_ref & d) {
|
||||
clean_denominators(p.size(), p.c_ptr(), norm_p, d);
|
||||
clean_denominators(p.size(), p.data(), norm_p, d);
|
||||
}
|
||||
|
||||
void clean_denominators(numeral const & a, numeral & p, numeral & q) {
|
||||
|
@ -3394,7 +3394,7 @@ namespace realclosure {
|
|||
\brief See comment in gcd_int_coeffs(value * a, mpz & g)
|
||||
*/
|
||||
bool gcd_int_coeffs(polynomial const & p, mpz & g) {
|
||||
return gcd_int_coeffs(p.size(), p.c_ptr(), g);
|
||||
return gcd_int_coeffs(p.size(), p.data(), g);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3402,7 +3402,7 @@ namespace realclosure {
|
|||
*/
|
||||
void normalize_int_coeffs(value_ref_buffer & p) {
|
||||
scoped_mpz g(qm());
|
||||
if (gcd_int_coeffs(p.size(), p.c_ptr(), g) && !qm().is_one(g)) {
|
||||
if (gcd_int_coeffs(p.size(), p.data(), g) && !qm().is_one(g)) {
|
||||
SASSERT(qm().is_pos(g));
|
||||
value_ref a(*this);
|
||||
for (unsigned i = 0; i < p.size(); i++) {
|
||||
|
@ -3449,7 +3449,7 @@ namespace realclosure {
|
|||
new_ais.push_back(nullptr);
|
||||
}
|
||||
}
|
||||
rational_function_value * r = mk_rational_function_value_core(rf->ext(), new_ais.size(), new_ais.c_ptr(), 1, &m_one);
|
||||
rational_function_value * r = mk_rational_function_value_core(rf->ext(), new_ais.size(), new_ais.data(), 1, &m_one);
|
||||
set_interval(r->m_interval, rf->m_interval);
|
||||
a = r;
|
||||
// divide upper and lower by b
|
||||
|
@ -3513,16 +3513,16 @@ namespace realclosure {
|
|||
B.append(sz2, p2);
|
||||
while (true) {
|
||||
TRACE("rcf_gcd",
|
||||
tout << "A: "; display_poly(tout, A.size(), A.c_ptr()); tout << "\n";
|
||||
tout << "B: "; display_poly(tout, B.size(), B.c_ptr()); tout << "\n";);
|
||||
tout << "A: "; display_poly(tout, A.size(), A.data()); tout << "\n";
|
||||
tout << "B: "; display_poly(tout, B.size(), B.data()); tout << "\n";);
|
||||
if (B.empty()) {
|
||||
mk_monic(A);
|
||||
r = A;
|
||||
TRACE("rcf_gcd",
|
||||
tout << "gcd result: "; display_poly(tout, r.size(), r.c_ptr()); tout << "\n";);
|
||||
tout << "gcd result: "; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
rem(A.size(), A.c_ptr(), B.size(), B.c_ptr(), R);
|
||||
rem(A.size(), A.data(), B.size(), B.data(), R);
|
||||
A = B;
|
||||
B = R;
|
||||
}
|
||||
|
@ -3542,8 +3542,8 @@ namespace realclosure {
|
|||
TRACE("rcf_gcd", tout << "prem-GCD [" << m_exec_depth << "]\n";
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
display_poly(tout, sz2, p2); tout << "\n";);
|
||||
SASSERT(p1 != r.c_ptr());
|
||||
SASSERT(p2 != r.c_ptr());
|
||||
SASSERT(p1 != r.data());
|
||||
SASSERT(p2 != r.data());
|
||||
if (sz1 == 0) {
|
||||
r.append(sz2, p2);
|
||||
flip_sign_if_lc_neg(r);
|
||||
|
@ -3560,17 +3560,17 @@ namespace realclosure {
|
|||
B.append(sz2, p2);
|
||||
while (true) {
|
||||
TRACE("rcf_gcd",
|
||||
tout << "A: "; display_poly(tout, A.size(), A.c_ptr()); tout << "\n";
|
||||
tout << "B: "; display_poly(tout, B.size(), B.c_ptr()); tout << "\n";);
|
||||
tout << "A: "; display_poly(tout, A.size(), A.data()); tout << "\n";
|
||||
tout << "B: "; display_poly(tout, B.size(), B.data()); tout << "\n";);
|
||||
if (B.empty()) {
|
||||
normalize_int_coeffs(A);
|
||||
flip_sign_if_lc_neg(A);
|
||||
r = A;
|
||||
TRACE("rcf_gcd",
|
||||
tout << "gcd result: "; display_poly(tout, r.size(), r.c_ptr()); tout << "\n";);
|
||||
tout << "gcd result: "; display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
return;
|
||||
}
|
||||
prem(A.size(), A.c_ptr(), B.size(), B.c_ptr(), R);
|
||||
prem(A.size(), A.data(), B.size(), B.data(), R);
|
||||
normalize_int_coeffs(R);
|
||||
A = B;
|
||||
B = R;
|
||||
|
@ -3615,14 +3615,14 @@ namespace realclosure {
|
|||
value_ref_buffer g(*this);
|
||||
derivative(sz, p, p_prime);
|
||||
if (m_use_prem)
|
||||
prem_gcd(sz, p, p_prime.size(), p_prime.c_ptr(), g);
|
||||
prem_gcd(sz, p, p_prime.size(), p_prime.data(), g);
|
||||
else
|
||||
gcd(sz, p, p_prime.size(), p_prime.c_ptr(), g);
|
||||
gcd(sz, p, p_prime.size(), p_prime.data(), g);
|
||||
if (g.size() <= 1) {
|
||||
r.append(sz, p);
|
||||
}
|
||||
else {
|
||||
div(sz, p, g.size(), g.c_ptr(), r);
|
||||
div(sz, p, g.size(), g.data(), r);
|
||||
if (m_use_prem)
|
||||
normalize_int_coeffs(r);
|
||||
}
|
||||
|
@ -3654,10 +3654,10 @@ namespace realclosure {
|
|||
}
|
||||
TRACE("rcf_sturm_seq",
|
||||
tout << "sturm_seq_core [" << m_exec_depth << "], new polynomial\n";
|
||||
display_poly(tout, r.size(), r.c_ptr()); tout << "\n";);
|
||||
display_poly(tout, r.size(), r.data()); tout << "\n";);
|
||||
if (r.empty())
|
||||
return;
|
||||
seq.push(r.size(), r.c_ptr());
|
||||
seq.push(r.size(), r.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3679,7 +3679,7 @@ namespace realclosure {
|
|||
value_ref_buffer p_prime(*this);
|
||||
seq.push(sz, p);
|
||||
derivative(sz, p, p_prime);
|
||||
seq.push(p_prime.size(), p_prime.c_ptr());
|
||||
seq.push(p_prime.size(), p_prime.data());
|
||||
sturm_seq_core(seq);
|
||||
}
|
||||
|
||||
|
@ -3692,8 +3692,8 @@ namespace realclosure {
|
|||
value_ref_buffer p1_prime_p2(*this);
|
||||
seq.push(sz1, p1);
|
||||
derivative(sz1, p1, p1_prime);
|
||||
mul(p1_prime.size(), p1_prime.c_ptr(), sz2, p2, p1_prime_p2);
|
||||
seq.push(p1_prime_p2.size(), p1_prime_p2.c_ptr());
|
||||
mul(p1_prime.size(), p1_prime.data(), sz2, p2, p1_prime_p2);
|
||||
seq.push(p1_prime_p2.size(), p1_prime_p2.data());
|
||||
sturm_seq_core(seq);
|
||||
}
|
||||
|
||||
|
@ -4097,7 +4097,7 @@ namespace realclosure {
|
|||
\brief Refine the interval for each coefficient of in the polynomial p.
|
||||
*/
|
||||
bool refine_coeffs_interval(polynomial const & p, unsigned prec) {
|
||||
return refine_coeffs_interval(p.size(), p.c_ptr(), prec);
|
||||
return refine_coeffs_interval(p.size(), p.data(), prec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4262,7 +4262,7 @@ namespace realclosure {
|
|||
scoped_mpbq m(bqm());
|
||||
bqm().add(a_i.lower(), a_i.upper(), m);
|
||||
bqm().div2(m);
|
||||
int mid_sign = eval_sign_at(a->p().size(), a->p().c_ptr(), m);
|
||||
int mid_sign = eval_sign_at(a->p().size(), a->p().data(), m);
|
||||
if (mid_sign == 0) {
|
||||
// found the actual root
|
||||
// set interval [m, m]
|
||||
|
@ -4274,7 +4274,7 @@ namespace realclosure {
|
|||
SASSERT(mid_sign == 1 || mid_sign == -1);
|
||||
if (lower_sign == INT_MIN) {
|
||||
// initialize lower_sign
|
||||
lower_sign = eval_sign_at(a->p().size(), a->p().c_ptr(), a_i.lower());
|
||||
lower_sign = eval_sign_at(a->p().size(), a->p().data(), a_i.lower());
|
||||
}
|
||||
SASSERT(lower_sign == 1 || lower_sign == -1);
|
||||
if (mid_sign == lower_sign) {
|
||||
|
@ -4522,7 +4522,7 @@ namespace realclosure {
|
|||
That is, q(x) does not depend on infinitesimal values.
|
||||
*/
|
||||
bool depends_on_infinitesimals(polynomial const & q, algebraic * x) {
|
||||
return x->depends_on_infinitesimals() || depends_on_infinitesimals(q.size(), q.c_ptr());
|
||||
return x->depends_on_infinitesimals() || depends_on_infinitesimals(q.size(), q.data());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4577,7 +4577,7 @@ namespace realclosure {
|
|||
int num_roots = x->num_roots_inside_interval();
|
||||
SASSERT(x->sdt() != 0 || num_roots == 1);
|
||||
polynomial const & p = x->p();
|
||||
int taq_p_q = TaQ(p.size(), p.c_ptr(), q.size(), q.c_ptr(), x->iso_interval());
|
||||
int taq_p_q = TaQ(p.size(), p.data(), q.size(), q.data(), x->iso_interval());
|
||||
if (num_roots == 1 && taq_p_q == 0)
|
||||
return false; // q(x) is zero
|
||||
if (taq_p_q == num_roots) {
|
||||
|
@ -4603,7 +4603,7 @@ namespace realclosure {
|
|||
SASSERT(x->sdt() != 0);
|
||||
int q_eq_0, q_gt_0, q_lt_0;
|
||||
value_ref_buffer q2(*this);
|
||||
count_signs_at_zeros_core(taq_p_q, p.size(), p.c_ptr(), q.size(), q.c_ptr(), x->iso_interval(), num_roots, q_eq_0, q_gt_0, q_lt_0, q2);
|
||||
count_signs_at_zeros_core(taq_p_q, p.size(), p.data(), q.size(), q.data(), x->iso_interval(), num_roots, q_eq_0, q_gt_0, q_lt_0, q2);
|
||||
if (q_eq_0 > 0 && q_gt_0 == 0 && q_lt_0 == 0) {
|
||||
// q(x) is zero
|
||||
return false;
|
||||
|
@ -4646,19 +4646,19 @@ namespace realclosure {
|
|||
// Add TaQ(p, prs[i] * 1; x->iso_interval())
|
||||
new_taqrs.push_back(taqrs[i]);
|
||||
// Add TaQ(p, prs[i] * q; x->iso_interval())
|
||||
mul(prs[i].size(), prs[i].c_ptr(), q.size(), q.c_ptr(), prq);
|
||||
new_taqrs.push_back(TaQ(p.size(), p.c_ptr(), prq.size(), prq.c_ptr(), x->iso_interval()));
|
||||
mul(prs[i].size(), prs[i].data(), q.size(), q.data(), prq);
|
||||
new_taqrs.push_back(TaQ(p.size(), p.data(), prq.size(), prq.data(), x->iso_interval()));
|
||||
if (use_q2) {
|
||||
// Add TaQ(p, prs[i] * q^2; x->iso_interval())
|
||||
mul(prs[i].size(), prs[i].c_ptr(), q2.size(), q2.c_ptr(), prq);
|
||||
new_taqrs.push_back(TaQ(p.size(), p.c_ptr(), prq.size(), prq.c_ptr(), x->iso_interval()));
|
||||
mul(prs[i].size(), prs[i].data(), q2.size(), q2.data(), prq);
|
||||
new_taqrs.push_back(TaQ(p.size(), p.data(), prq.size(), prq.data(), x->iso_interval()));
|
||||
}
|
||||
}
|
||||
int_buffer sc_cardinalities;
|
||||
sc_cardinalities.resize(new_taqrs.size(), 0);
|
||||
// Solve
|
||||
// new_M_s * sc_cardinalities = new_taqrs
|
||||
VERIFY(mm().solve(new_M_s, sc_cardinalities.c_ptr(), new_taqrs.c_ptr()));
|
||||
VERIFY(mm().solve(new_M_s, sc_cardinalities.data(), new_taqrs.data()));
|
||||
DEBUG_CODE({
|
||||
// check if sc_cardinalities has the expected structure
|
||||
// - contains only 0 or 1
|
||||
|
@ -4852,15 +4852,15 @@ namespace realclosure {
|
|||
value_ref_buffer tmp2(*this);
|
||||
div(sz1, p1, lc, tmp1);
|
||||
div(sz2, p2, lc, tmp2);
|
||||
normalize_num_monic_den(tmp1.size(), tmp1.c_ptr(), tmp2.size(), tmp2.c_ptr(), new_p1, new_p2);
|
||||
normalize_num_monic_den(tmp1.size(), tmp1.data(), tmp2.size(), tmp2.data(), new_p1, new_p2);
|
||||
}
|
||||
}
|
||||
TRACE("normalize_fraction_bug",
|
||||
display_poly(tout, sz1, p1); tout << "\n";
|
||||
display_poly(tout, sz2, p2); tout << "\n";
|
||||
tout << "====>\n";
|
||||
display_poly(tout, new_p1.size(), new_p1.c_ptr()); tout << "\n";
|
||||
display_poly(tout, new_p2.size(), new_p2.c_ptr()); tout << "\n";);
|
||||
display_poly(tout, new_p1.size(), new_p1.data()); tout << "\n";
|
||||
display_poly(tout, new_p2.size(), new_p2.data()); tout << "\n";);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4888,8 +4888,8 @@ namespace realclosure {
|
|||
new_p2.append(sz2, p2);
|
||||
}
|
||||
else {
|
||||
div(sz1, p1, g.size(), g.c_ptr(), new_p1);
|
||||
div(sz2, p2, g.size(), g.c_ptr(), new_p2);
|
||||
div(sz1, p1, g.size(), g.data(), new_p1);
|
||||
div(sz2, p2, g.size(), g.data(), new_p2);
|
||||
SASSERT(is_monic(new_p2));
|
||||
}
|
||||
}
|
||||
|
@ -4908,7 +4908,7 @@ namespace realclosure {
|
|||
void normalize_algebraic(algebraic * x, unsigned sz1, value * const * p1, value_ref_buffer & new_p1) {
|
||||
polynomial const & p = x->p();
|
||||
if (!m_lazy_algebraic_normalization || !m_in_aux_values || is_monic(p)) {
|
||||
rem(sz1, p1, p.size(), p.c_ptr(), new_p1);
|
||||
rem(sz1, p1, p.size(), p.data(), new_p1);
|
||||
}
|
||||
else {
|
||||
new_p1.reset();
|
||||
|
@ -4954,9 +4954,9 @@ namespace realclosure {
|
|||
polynomial const & one = a->den();
|
||||
SASSERT(an.size() > 1);
|
||||
value_ref_buffer new_num(*this);
|
||||
add(an.size(), an.c_ptr(), b, new_num);
|
||||
add(an.size(), an.data(), b, new_num);
|
||||
SASSERT(new_num.size() == an.size());
|
||||
mk_add_value(a, b, new_num.size(), new_num.c_ptr(), one.size(), one.c_ptr(), r);
|
||||
mk_add_value(a, b, new_num.size(), new_num.data(), one.size(), one.data(), r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4973,17 +4973,17 @@ namespace realclosure {
|
|||
SASSERT(!a->ext()->is_algebraic());
|
||||
polynomial const & ad = a->den();
|
||||
// b_ad <- b * ad
|
||||
mul(b, ad.size(), ad.c_ptr(), b_ad);
|
||||
mul(b, ad.size(), ad.data(), b_ad);
|
||||
// num <- a + b * ad
|
||||
add(an.size(), an.c_ptr(), b_ad.size(), b_ad.c_ptr(), num);
|
||||
add(an.size(), an.data(), b_ad.size(), b_ad.data(), num);
|
||||
if (num.empty())
|
||||
r = nullptr;
|
||||
else {
|
||||
value_ref_buffer new_num(*this);
|
||||
value_ref_buffer new_den(*this);
|
||||
normalize_fraction(num.size(), num.c_ptr(), ad.size(), ad.c_ptr(), new_num, new_den);
|
||||
normalize_fraction(num.size(), num.data(), ad.size(), ad.data(), new_num, new_den);
|
||||
SASSERT(!new_num.empty());
|
||||
mk_add_value(a, b, new_num.size(), new_num.c_ptr(), new_den.size(), new_den.c_ptr(), r);
|
||||
mk_add_value(a, b, new_num.size(), new_num.data(), new_den.size(), new_den.data(), r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4999,7 +4999,7 @@ namespace realclosure {
|
|||
polynomial const & one = a->den();
|
||||
polynomial const & bn = b->num();
|
||||
value_ref_buffer new_num(*this);
|
||||
add(an.size(), an.c_ptr(), bn.size(), bn.c_ptr(), new_num);
|
||||
add(an.size(), an.data(), bn.size(), bn.data(), new_num);
|
||||
if (new_num.empty())
|
||||
r = nullptr;
|
||||
else {
|
||||
|
@ -5008,7 +5008,7 @@ namespace realclosure {
|
|||
// That is, their degrees are < degree of the polynomial defining x.
|
||||
// Moreover, when we add polynomials, the degree can only decrease.
|
||||
// So, degree of new_num must be < degree of x's defining polynomial.
|
||||
mk_add_value(a, b, new_num.size(), new_num.c_ptr(), one.size(), one.c_ptr(), r);
|
||||
mk_add_value(a, b, new_num.size(), new_num.data(), one.size(), one.data(), r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5028,21 +5028,21 @@ namespace realclosure {
|
|||
polynomial const & bd = b->den();
|
||||
value_ref_buffer an_bd(*this);
|
||||
value_ref_buffer bn_ad(*this);
|
||||
mul(an.size(), an.c_ptr(), bd.size(), bd.c_ptr(), an_bd);
|
||||
mul(bn.size(), bn.c_ptr(), ad.size(), ad.c_ptr(), bn_ad);
|
||||
mul(an.size(), an.data(), bd.size(), bd.data(), an_bd);
|
||||
mul(bn.size(), bn.data(), ad.size(), ad.data(), bn_ad);
|
||||
value_ref_buffer num(*this);
|
||||
add(an_bd.size(), an_bd.c_ptr(), bn_ad.size(), bn_ad.c_ptr(), num);
|
||||
add(an_bd.size(), an_bd.data(), bn_ad.size(), bn_ad.data(), num);
|
||||
if (num.empty()) {
|
||||
r = nullptr;
|
||||
}
|
||||
else {
|
||||
value_ref_buffer den(*this);
|
||||
mul(ad.size(), ad.c_ptr(), bd.size(), bd.c_ptr(), den);
|
||||
mul(ad.size(), ad.data(), bd.size(), bd.data(), den);
|
||||
value_ref_buffer new_num(*this);
|
||||
value_ref_buffer new_den(*this);
|
||||
normalize_fraction(num.size(), num.c_ptr(), den.size(), den.c_ptr(), new_num, new_den);
|
||||
normalize_fraction(num.size(), num.data(), den.size(), den.data(), new_num, new_den);
|
||||
SASSERT(!new_num.empty());
|
||||
mk_add_value(a, b, new_num.size(), new_num.c_ptr(), new_den.size(), new_den.c_ptr(), r);
|
||||
mk_add_value(a, b, new_num.size(), new_num.data(), new_den.size(), new_den.data(), r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5107,10 +5107,10 @@ namespace realclosure {
|
|||
polynomial const & an = a->num();
|
||||
polynomial const & ad = a->den();
|
||||
value_ref_buffer new_num(*this);
|
||||
neg(an.size(), an.c_ptr(), new_num);
|
||||
neg(an.size(), an.data(), new_num);
|
||||
scoped_mpbqi ri(bqim());
|
||||
bqim().neg(interval(a), ri);
|
||||
r = mk_rational_function_value_core(a->ext(), new_num.size(), new_num.c_ptr(), ad.size(), ad.c_ptr());
|
||||
r = mk_rational_function_value_core(a->ext(), new_num.size(), new_num.data(), ad.size(), ad.data());
|
||||
swap(r->interval(), ri);
|
||||
SASSERT(!contains_zero(r->interval()));
|
||||
}
|
||||
|
@ -5169,9 +5169,9 @@ namespace realclosure {
|
|||
polynomial const & one = a->den();
|
||||
SASSERT(an.size() > 1);
|
||||
value_ref_buffer new_num(*this);
|
||||
mul(b, an.size(), an.c_ptr(), new_num);
|
||||
mul(b, an.size(), an.data(), new_num);
|
||||
SASSERT(new_num.size() == an.size());
|
||||
mk_mul_value(a, b, new_num.size(), new_num.c_ptr(), one.size(), one.c_ptr(), r);
|
||||
mk_mul_value(a, b, new_num.size(), new_num.data(), one.size(), one.data(), r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5187,13 +5187,13 @@ namespace realclosure {
|
|||
polynomial const & ad = a->den();
|
||||
value_ref_buffer num(*this);
|
||||
// num <- b * an
|
||||
mul(b, an.size(), an.c_ptr(), num);
|
||||
mul(b, an.size(), an.data(), num);
|
||||
SASSERT(num.size() == an.size());
|
||||
value_ref_buffer new_num(*this);
|
||||
value_ref_buffer new_den(*this);
|
||||
normalize_fraction(num.size(), num.c_ptr(), ad.size(), ad.c_ptr(), new_num, new_den);
|
||||
normalize_fraction(num.size(), num.data(), ad.size(), ad.data(), new_num, new_den);
|
||||
SASSERT(!new_num.empty());
|
||||
mk_mul_value(a, b, new_num.size(), new_num.c_ptr(), new_den.size(), new_den.c_ptr(), r);
|
||||
mk_mul_value(a, b, new_num.size(), new_num.data(), new_den.size(), new_den.data(), r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5208,17 +5208,17 @@ namespace realclosure {
|
|||
polynomial const & one = a->den();
|
||||
polynomial const & bn = b->num();
|
||||
value_ref_buffer new_num(*this);
|
||||
mul(an.size(), an.c_ptr(), bn.size(), bn.c_ptr(), new_num);
|
||||
mul(an.size(), an.data(), bn.size(), bn.data(), new_num);
|
||||
SASSERT(!new_num.empty());
|
||||
extension * x = a->ext();
|
||||
if (x->is_algebraic()) {
|
||||
value_ref_buffer new_num2(*this);
|
||||
normalize_algebraic(to_algebraic(x), new_num.size(), new_num.c_ptr(), new_num2);
|
||||
normalize_algebraic(to_algebraic(x), new_num.size(), new_num.data(), new_num2);
|
||||
SASSERT(!new_num.empty());
|
||||
mk_mul_value(a, b, new_num2.size(), new_num2.c_ptr(), one.size(), one.c_ptr(), r);
|
||||
mk_mul_value(a, b, new_num2.size(), new_num2.data(), one.size(), one.data(), r);
|
||||
}
|
||||
else {
|
||||
mk_mul_value(a, b, new_num.size(), new_num.c_ptr(), one.size(), one.c_ptr(), r);
|
||||
mk_mul_value(a, b, new_num.size(), new_num.data(), one.size(), one.data(), r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5238,14 +5238,14 @@ namespace realclosure {
|
|||
polynomial const & bd = b->den();
|
||||
value_ref_buffer num(*this);
|
||||
value_ref_buffer den(*this);
|
||||
mul(an.size(), an.c_ptr(), bn.size(), bn.c_ptr(), num);
|
||||
mul(ad.size(), ad.c_ptr(), bd.size(), bd.c_ptr(), den);
|
||||
mul(an.size(), an.data(), bn.size(), bn.data(), num);
|
||||
mul(ad.size(), ad.data(), bd.size(), bd.data(), den);
|
||||
SASSERT(!num.empty()); SASSERT(!den.empty());
|
||||
value_ref_buffer new_num(*this);
|
||||
value_ref_buffer new_den(*this);
|
||||
normalize_fraction(num.size(), num.c_ptr(), den.size(), den.c_ptr(), new_num, new_den);
|
||||
normalize_fraction(num.size(), num.data(), den.size(), den.data(), new_num, new_den);
|
||||
SASSERT(!new_num.empty());
|
||||
mk_mul_value(a, b, new_num.size(), new_num.c_ptr(), new_den.size(), new_den.c_ptr(), r);
|
||||
mk_mul_value(a, b, new_num.size(), new_num.data(), new_den.size(), new_den.data(), r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5350,20 +5350,20 @@ namespace realclosure {
|
|||
// In every iteration of the loop we have
|
||||
// Q(alpha) * h(alpha) = R(alpha)
|
||||
TRACE("inv_algebraic",
|
||||
tout << "Q: "; display_poly(tout, Q.size(), Q.c_ptr()); tout << "\n";
|
||||
tout << "R: "; display_poly(tout, R.size(), R.c_ptr()); tout << "\n";);
|
||||
tout << "Q: "; display_poly(tout, Q.size(), Q.data()); tout << "\n";
|
||||
tout << "R: "; display_poly(tout, R.size(), R.data()); tout << "\n";);
|
||||
if (Q.size() == 1) {
|
||||
// If the new Q is the constant polynomial, they we are done.
|
||||
// We just divide R by Q[0].
|
||||
// h(alpha) = R(alpha) / Q[0]
|
||||
div(R.size(), R.c_ptr(), Q[0], h);
|
||||
TRACE("inv_algebraic", tout << "h: "; display_poly(tout, h.size(), h.c_ptr()); tout << "\n";);
|
||||
div(R.size(), R.data(), Q[0], h);
|
||||
TRACE("inv_algebraic", tout << "h: "; display_poly(tout, h.size(), h.data()); tout << "\n";);
|
||||
// g <- 1
|
||||
g.reset(); g.push_back(one());
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
div_rem(p_sz, p, Q.size(), Q.c_ptr(), Quo, Rem);
|
||||
div_rem(p_sz, p, Q.size(), Q.data(), Quo, Rem);
|
||||
if (Rem.empty()) {
|
||||
// failed
|
||||
// GCD(q, p) != 1
|
||||
|
@ -5384,11 +5384,11 @@ namespace realclosure {
|
|||
// Q <- -REM
|
||||
// R <- R * Quo
|
||||
// Q <- -Rem
|
||||
neg(Rem.size(), Rem.c_ptr(), Q);
|
||||
mul(R.size(), R.c_ptr(), Quo.size(), Quo.c_ptr(), aux);
|
||||
neg(Rem.size(), Rem.data(), Q);
|
||||
mul(R.size(), R.data(), Quo.size(), Quo.data(), aux);
|
||||
// Moreover since p(alpha) = 0, we can simplify Q, by using
|
||||
// Q(alpha) = REM(Q, p)(alpha)
|
||||
rem(aux.size(), aux.c_ptr(), p_sz, p, R);
|
||||
rem(aux.size(), aux.data(), p_sz, p, R);
|
||||
SASSERT(R.size() < p_sz);
|
||||
//
|
||||
}
|
||||
|
@ -5410,15 +5410,15 @@ namespace realclosure {
|
|||
polynomial const & p = alpha->p();
|
||||
value_ref_buffer norm_q(*this);
|
||||
// since p(alpha) = 0, we have that q(alpha) = rem(q, p)(alpha)
|
||||
rem(q.size(), q.c_ptr(), p.size(), p.c_ptr(), norm_q);
|
||||
rem(q.size(), q.data(), p.size(), p.data(), norm_q);
|
||||
SASSERT(norm_q.size() < p.size());
|
||||
value_ref_buffer new_num(*this), g(*this);
|
||||
if (inv_algebraic(norm_q.size(), norm_q.c_ptr(), p.size(), p.c_ptr(), g, new_num)) {
|
||||
if (inv_algebraic(norm_q.size(), norm_q.data(), p.size(), p.data(), g, new_num)) {
|
||||
if (new_num.size() == 1) {
|
||||
r = new_num[0];
|
||||
}
|
||||
else {
|
||||
r = mk_rational_function_value_core(alpha, new_num.size(), new_num.c_ptr());
|
||||
r = mk_rational_function_value_core(alpha, new_num.size(), new_num.data());
|
||||
swap(r->interval(), ri);
|
||||
SASSERT(!contains_zero(r->interval()));
|
||||
}
|
||||
|
@ -5436,11 +5436,11 @@ namespace realclosure {
|
|||
// And try again :)
|
||||
|
||||
value_ref_buffer new_p(*this);
|
||||
div(p.size(), p.c_ptr(), g.size(), g.c_ptr(), new_p);
|
||||
div(p.size(), p.data(), g.size(), g.data(), new_p);
|
||||
if (m_clean_denominators) {
|
||||
value_ref_buffer tmp(*this);
|
||||
value_ref d(*this);
|
||||
clean_denominators(new_p.size(), new_p.c_ptr(), tmp, d);
|
||||
clean_denominators(new_p.size(), new_p.data(), tmp, d);
|
||||
new_p = tmp;
|
||||
}
|
||||
SASSERT(new_p.size() >= 2);
|
||||
|
@ -5454,7 +5454,7 @@ namespace realclosure {
|
|||
div(alpha_val, new_p[1], alpha_val);
|
||||
// Thus, a is equal to q(alpha_val)
|
||||
value_ref new_a(*this);
|
||||
mk_polynomial_value(q.size(), q.c_ptr(), alpha_val, new_a);
|
||||
mk_polynomial_value(q.size(), q.data(), alpha_val, new_a);
|
||||
// Remark new_a does not depend on alpha anymore
|
||||
// r == 1/inv(new_a)
|
||||
inv(new_a, r);
|
||||
|
@ -5465,7 +5465,7 @@ namespace realclosure {
|
|||
// The m_iso_interval for p() is also an isolating interval for new_p,
|
||||
// since the roots of new_p() are a subset of the roots of p
|
||||
reset_p(alpha->m_p);
|
||||
set_p(alpha->m_p, new_p.size(), new_p.c_ptr());
|
||||
set_p(alpha->m_p, new_p.size(), new_p.data());
|
||||
|
||||
// The new call will succeed because q and new_p are co-prime
|
||||
inv_algebraic(a, r);
|
||||
|
@ -5488,7 +5488,7 @@ namespace realclosure {
|
|||
// - new_p is square free (it is a factor of the square free polynomial p)
|
||||
// - 0 is not a root of new_p (it is a factor of p, and 0 is not a root of p)
|
||||
numeral_vector roots;
|
||||
nl_nz_sqf_isolate_roots(new_p.size(), new_p.c_ptr(), roots);
|
||||
nl_nz_sqf_isolate_roots(new_p.size(), new_p.data(), roots);
|
||||
SASSERT(roots.size() > 0);
|
||||
algebraic * new_alpha;
|
||||
if (roots.size() == 1) {
|
||||
|
@ -5513,7 +5513,7 @@ namespace realclosure {
|
|||
|
||||
// copy new_alpha->m_p
|
||||
reset_p(alpha->m_p);
|
||||
set_p(alpha->m_p, new_alpha->m_p.size(), new_alpha->m_p.c_ptr());
|
||||
set_p(alpha->m_p, new_alpha->m_p.size(), new_alpha->m_p.data());
|
||||
// copy new_alpha->m_sign_det
|
||||
inc_ref_sign_det(new_alpha->m_sign_det);
|
||||
dec_ref_sign_det(alpha->m_sign_det);
|
||||
|
@ -5542,8 +5542,8 @@ namespace realclosure {
|
|||
// The GCD of an and ad is one, we may use a simpler version of normalize
|
||||
value_ref_buffer new_num(*this);
|
||||
value_ref_buffer new_den(*this);
|
||||
normalize_fraction(ad.size(), ad.c_ptr(), an.size(), an.c_ptr(), new_num, new_den);
|
||||
r = mk_rational_function_value_core(a->ext(), new_num.size(), new_num.c_ptr(), new_den.size(), new_den.c_ptr());
|
||||
normalize_fraction(ad.size(), ad.data(), an.size(), an.data(), new_num, new_den);
|
||||
r = mk_rational_function_value_core(a->ext(), new_num.size(), new_num.data(), new_den.size(), new_den.data());
|
||||
swap(r->interval(), ri);
|
||||
SASSERT(!contains_zero(r->interval()));
|
||||
}
|
||||
|
@ -5646,7 +5646,7 @@ namespace realclosure {
|
|||
p.push_back(one());
|
||||
|
||||
numeral_vector roots;
|
||||
nz_isolate_roots(p.size(), p.c_ptr(), roots);
|
||||
nz_isolate_roots(p.size(), p.data(), roots);
|
||||
SASSERT(roots.size() == 1 || roots.size() == 2);
|
||||
if (roots.size() == 1 || sign(roots[0].m_value) > 0) {
|
||||
set(b, roots[0]);
|
||||
|
@ -5817,7 +5817,7 @@ namespace realclosure {
|
|||
|
||||
template<typename DisplayVar>
|
||||
void display_polynomial(std::ostream & out, polynomial const & p, DisplayVar const & display_var, bool compact, bool pp) const {
|
||||
display_polynomial(out, p.size(), p.c_ptr(), display_var, compact, pp);
|
||||
display_polynomial(out, p.size(), p.data(), display_var, compact, pp);
|
||||
}
|
||||
|
||||
struct display_free_var_proc {
|
||||
|
|
|
@ -273,7 +273,7 @@ namespace realclosure {
|
|||
num():m_value(nullptr) {}
|
||||
|
||||
// Low level functions for implementing the C API
|
||||
void * c_ptr() { return m_value; }
|
||||
void * data() { return m_value; }
|
||||
static num mk(void * ptr) { num r; r.m_value = reinterpret_cast<value*>(ptr); return r; }
|
||||
};
|
||||
};
|
||||
|
|
|
@ -699,7 +699,7 @@ namespace opt {
|
|||
unsigned i = 0, j = 0;
|
||||
while (i < r1.m_vars.size() || j < r2.m_vars.size()) {
|
||||
if (j == r2.m_vars.size()) {
|
||||
m_new_vars.append(r1.m_vars.size() - i, r1.m_vars.c_ptr() + i);
|
||||
m_new_vars.append(r1.m_vars.size() - i, r1.m_vars.data() + i);
|
||||
break;
|
||||
}
|
||||
if (i == r1.m_vars.size()) {
|
||||
|
@ -823,7 +823,7 @@ namespace opt {
|
|||
row& r = m_rows[row_id];
|
||||
rational val(c);
|
||||
SASSERT(r.m_vars.empty());
|
||||
r.m_vars.append(coeffs.size(), coeffs.c_ptr());
|
||||
r.m_vars.append(coeffs.size(), coeffs.data());
|
||||
bool is_int_row = !coeffs.empty();
|
||||
std::sort(r.m_vars.begin(), r.m_vars.end(), var::compare());
|
||||
for (auto const& c : coeffs) {
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace subpaving {
|
|||
m_ctx.nm().set(m_as[i], as[i]);
|
||||
}
|
||||
m_ctx.nm().set(m_c, c);
|
||||
return m_ctx.mk_sum(m_c, sz, m_as.c_ptr(), xs);
|
||||
return m_ctx.mk_sum(m_c, sz, m_as.data(), xs);
|
||||
}
|
||||
ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override {
|
||||
return reinterpret_cast<ineq*>(m_ctx.mk_ineq(x, k, lower, open));
|
||||
|
@ -119,7 +119,7 @@ namespace subpaving {
|
|||
int2mpf(as[i], m_as[i]);
|
||||
}
|
||||
int2mpf(c, m_c);
|
||||
return m_ctx.mk_sum(m_c, sz, m_as.c_ptr(), xs);
|
||||
return m_ctx.mk_sum(m_c, sz, m_as.data(), xs);
|
||||
}
|
||||
catch (const f2n<mpf_manager>::exception &) {
|
||||
throw subpaving::exception();
|
||||
|
@ -176,7 +176,7 @@ namespace subpaving {
|
|||
int2hwf(as[i], m_as[i]);
|
||||
}
|
||||
int2hwf(c, m_c);
|
||||
return m_ctx.mk_sum(m_c, sz, m_as.c_ptr(), xs);
|
||||
return m_ctx.mk_sum(m_c, sz, m_as.data(), xs);
|
||||
}
|
||||
catch (const f2n<mpf_manager>::exception &) {
|
||||
throw subpaving::exception();
|
||||
|
@ -234,7 +234,7 @@ namespace subpaving {
|
|||
int2fpoint(as[i], m_as[i]);
|
||||
}
|
||||
int2fpoint(c, m_c);
|
||||
return this->m_ctx.mk_sum(m_c, sz, m_as.c_ptr(), xs);
|
||||
return this->m_ctx.mk_sum(m_c, sz, m_as.data(), xs);
|
||||
}
|
||||
catch (const typename context_fpoint::numeral_manager::exception &) {
|
||||
throw subpaving::exception();
|
||||
|
|
|
@ -712,7 +712,7 @@ var context_t<C>::mk_monomial(unsigned sz, power const * pws) {
|
|||
}
|
||||
}
|
||||
sz = j + 1;
|
||||
pws = m_pws.c_ptr();
|
||||
pws = m_pws.data();
|
||||
unsigned mem_sz = monomial::get_obj_size(sz);
|
||||
void * mem = allocator().allocate(mem_sz);
|
||||
monomial * r = new (mem) monomial(sz, pws);
|
||||
|
|
|
@ -212,7 +212,7 @@ struct expr2subpaving::imp {
|
|||
else if (pws.size() == 1 && pws[0].degree() == 1)
|
||||
x = pws[0].get_var();
|
||||
else
|
||||
x = s().mk_monomial(pws.size(), pws.c_ptr());
|
||||
x = s().mk_monomial(pws.size(), pws.data());
|
||||
cache_result(t, x, n, d);
|
||||
return x;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ struct expr2subpaving::imp {
|
|||
x = subpaving::null_var;
|
||||
}
|
||||
else {
|
||||
x = s().mk_sum(sum_c, sz, ns.c_ptr(), xs.c_ptr());
|
||||
x = s().mk_sum(sum_c, sz, ns.data(), xs.data());
|
||||
qm().set(n, 1);
|
||||
}
|
||||
cache_result(t, x, n, d);
|
||||
|
|
|
@ -174,7 +174,7 @@ class subpaving_tactic : public tactic {
|
|||
for (unsigned i = 0; i < sz; i++) {
|
||||
ineq_buffer.push_back(mk_ineq(args[i]));
|
||||
}
|
||||
m_ctx->add_clause(sz, ineq_buffer.c_ptr());
|
||||
m_ctx->add_clause(sz, ineq_buffer.data());
|
||||
}
|
||||
|
||||
void internalize(goal const & g) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue