mirror of
https://github.com/Z3Prover/z3
synced 2026-02-22 08:17:37 +00:00
Standardize for-loop increments to prefix form (++i) (#8199)
* Initial plan * Convert postfix to prefix increment in for loops Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Fix member variable increment conversion bug Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Update API generator to produce prefix increments Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
1bf463d77a
commit
2436943794
475 changed files with 3237 additions and 3237 deletions
|
|
@ -126,7 +126,7 @@ void grobner::display_var(std::ostream & out, expr * var) const {
|
|||
}
|
||||
|
||||
void grobner::display_vars(std::ostream & out, unsigned num_vars, expr * const * vars) const {
|
||||
for (unsigned i = 0; i < num_vars; i++) {
|
||||
for (unsigned i = 0; i < num_vars; ++i) {
|
||||
display_var(out, vars[i]);
|
||||
out << " ";
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ void grobner::display_monomial(std::ostream & out, monomial const & m, std::func
|
|||
|
||||
void grobner::display_monomials(std::ostream & out, unsigned num_monomials, monomial * const * monomials, std::function<void(std::ostream&, expr*)>& display_var) const {
|
||||
bool first = true;
|
||||
for (unsigned i = 0; i < num_monomials; i++) {
|
||||
for (unsigned i = 0; i < num_monomials; ++i) {
|
||||
monomial const * m = monomials[i];
|
||||
if (first)
|
||||
first = false;
|
||||
|
|
@ -277,7 +277,7 @@ inline void grobner::add_var(monomial * m, expr * v) {
|
|||
grobner::monomial * grobner::mk_monomial(rational const & coeff, unsigned num_vars, expr * const * vars) {
|
||||
monomial * r = alloc(monomial);
|
||||
r->m_coeff = coeff;
|
||||
for (unsigned i = 0; i < num_vars; i++)
|
||||
for (unsigned i = 0; i < num_vars; ++i)
|
||||
add_var(r, vars[i]);
|
||||
std::stable_sort(r->m_vars.begin(), r->m_vars.end(), m_var_lt);
|
||||
return r;
|
||||
|
|
@ -341,7 +341,7 @@ void grobner::assert_eq_0(unsigned num_monomials, monomial * const * monomials,
|
|||
void grobner::assert_eq_0(unsigned num_monomials, rational const * coeffs, expr * const * monomials, v_dependency * ex) {
|
||||
#define MK_EQ(COEFF) \
|
||||
ptr_vector<monomial> ms; \
|
||||
for (unsigned i = 0; i < num_monomials; i++) \
|
||||
for (unsigned i = 0; i < num_monomials; ++i) \
|
||||
ms.push_back(mk_monomial(COEFF, monomials[i])); \
|
||||
std::stable_sort(ms.begin(), ms.end(), m_monomial_lt); \
|
||||
merge_monomials(ms); \
|
||||
|
|
@ -473,14 +473,14 @@ void grobner::normalize_coeff(ptr_vector<monomial> & monomials) {
|
|||
if (c.is_one())
|
||||
return;
|
||||
if (c.is_minus_one()) {
|
||||
for (unsigned i = 0; i < sz && m_manager.inc(); i++)
|
||||
for (unsigned i = 0; i < sz && m_manager.inc(); ++i)
|
||||
monomials[i]->m_coeff.neg();
|
||||
return;
|
||||
}
|
||||
if (c.bitsize() > 1000)
|
||||
return;
|
||||
|
||||
for (unsigned i = 0; i < sz && m_manager.inc(); i++) {
|
||||
for (unsigned i = 0; i < sz && m_manager.inc(); ++i) {
|
||||
if (monomials[i]->m_coeff.bitsize() > 1000)
|
||||
continue;
|
||||
monomials[i]->m_coeff /= c;
|
||||
|
|
@ -536,7 +536,7 @@ bool grobner::is_subset(monomial const * m1, monomial const * m2, ptr_vector<exp
|
|||
if (sz1 <= sz2) {
|
||||
while (true) {
|
||||
if (i1 >= sz1) {
|
||||
for (; i2 < sz2; i2++)
|
||||
for (; i2 < sz2; ++i2)
|
||||
rest.push_back(m2->m_vars[i2]);
|
||||
TRACE(grobner,
|
||||
tout << "monomial: "; display_monomial(tout, *m1); tout << " is a subset of ";
|
||||
|
|
@ -574,7 +574,7 @@ bool grobner::is_subset(monomial const * m1, monomial const * m2, ptr_vector<exp
|
|||
*/
|
||||
void grobner::mul_append(unsigned start_idx, equation const * source, rational const & coeff, ptr_vector<expr> const & vars, ptr_vector<monomial> & result) {
|
||||
unsigned sz = source->get_num_monomials();
|
||||
for (unsigned i = start_idx; i < sz; i++) {
|
||||
for (unsigned i = start_idx; i < sz; ++i) {
|
||||
monomial const * m = source->get_monomial(i);
|
||||
monomial * new_m = alloc(monomial);
|
||||
new_m->m_coeff = m->m_coeff;
|
||||
|
|
@ -605,7 +605,7 @@ grobner::monomial * grobner::copy_monomial(monomial const * m) {
|
|||
grobner::equation * grobner::copy_equation(equation const * eq) {
|
||||
equation * r = alloc(equation);
|
||||
unsigned sz = eq->get_num_monomials();
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
r->m_monomials.push_back(copy_monomial(eq->get_monomial(i)));
|
||||
init_equation(r, eq->m_dep);
|
||||
r->m_lc = eq->m_lc;
|
||||
|
|
@ -636,7 +636,7 @@ grobner::equation * grobner::simplify(equation const * source, equation * target
|
|||
ptr_vector<monomial> & new_monomials = m_tmp_monomials;
|
||||
new_monomials.reset();
|
||||
ptr_vector<expr> & rest = m_tmp_vars1;
|
||||
for (; i < sz; i++) {
|
||||
for (; i < sz; ++i) {
|
||||
monomial * curr = target->m_monomials[i];
|
||||
rest.reset();
|
||||
if (is_subset(LT, curr, rest)) {
|
||||
|
|
@ -828,7 +828,7 @@ bool grobner::unify(monomial const * m1, monomial const * m2, ptr_vector<expr> &
|
|||
while (true) {
|
||||
if (i1 >= sz1) {
|
||||
if (found_M) {
|
||||
for (; i2 < sz2; i2++)
|
||||
for (; i2 < sz2; ++i2)
|
||||
rest2.push_back(m2->m_vars[i2]);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -836,7 +836,7 @@ bool grobner::unify(monomial const * m1, monomial const * m2, ptr_vector<expr> &
|
|||
}
|
||||
if (i2 >= sz2) {
|
||||
if (found_M) {
|
||||
for (; i1 < sz1; i1++)
|
||||
for (; i1 < sz1; ++i1)
|
||||
rest1.push_back(m1->m_vars[i1]);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ template<typename C>
|
|||
void interval_manager<C>::fact(unsigned n, numeral & o) {
|
||||
_scoped_numeral<numeral_manager> aux(m());
|
||||
m().set(o, 1);
|
||||
for (unsigned i = 2; i <= n; i++) {
|
||||
for (unsigned i = 2; i <= n; ++i) {
|
||||
m().set(aux, static_cast<int>(i));
|
||||
m().mul(aux, o, o);
|
||||
TRACE(fact_bug, tout << "i: " << i << ", o: " << m().to_rational_string(o) << "\n";);
|
||||
|
|
@ -1901,7 +1901,7 @@ void interval_manager<C>::pi(unsigned n, interval & r) {
|
|||
// compute lower bound
|
||||
numeral & l_val = m_result_lower;
|
||||
m().reset(l_val);
|
||||
for (unsigned i = 0; i <= n; i++) {
|
||||
for (unsigned i = 0; i <= n; ++i) {
|
||||
pi_series(i, p, false);
|
||||
round_to_minus_inf();
|
||||
m().add(l_val, p, l_val);
|
||||
|
|
@ -1916,7 +1916,7 @@ void interval_manager<C>::pi(unsigned n, interval & r) {
|
|||
else {
|
||||
// recompute the sum rounding to plus infinite
|
||||
m().reset(u_val);
|
||||
for (unsigned i = 0; i <= n; i++) {
|
||||
for (unsigned i = 0; i <= n; ++i) {
|
||||
pi_series(i, p, true);
|
||||
round_to_plus_inf();
|
||||
m().add(u_val, p, u_val);
|
||||
|
|
@ -1954,7 +1954,7 @@ void interval_manager<C>::e_series(unsigned k, bool upper, numeral & o) {
|
|||
_scoped_numeral<numeral_manager> d(m()), a(m());
|
||||
m().set(o, 2);
|
||||
m().set(d, 1);
|
||||
for (unsigned i = 2; i <= k; i++) {
|
||||
for (unsigned i = 2; i <= k; ++i) {
|
||||
set_rounding(!upper);
|
||||
m().set(a, static_cast<int>(i));
|
||||
m().mul(d, a, d); // d == i!
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ core_solver_pretty_printer<T, X>::core_solver_pretty_printer(const lp_core_solve
|
|||
|
||||
template <typename T, typename X> void core_solver_pretty_printer<T, X>::init_costs() {
|
||||
|
||||
for (unsigned i = 0; i < ncols(); i++) {
|
||||
for (unsigned i = 0; i < ncols(); ++i) {
|
||||
if (m_core_solver.m_basis_heading[i] < 0) {
|
||||
set_coeff(m_costs, m_cost_signs, i, m_core_solver.m_d[i], m_core_solver.column_name(i));
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::init_co
|
|||
|
||||
template <typename T, typename X> void core_solver_pretty_printer<T, X>::init_rs_width() {
|
||||
m_rs_width = static_cast<unsigned>(T_to_string(m_core_solver.get_cost()).size());
|
||||
for (unsigned i = 0; i < nrows(); i++) {
|
||||
for (unsigned i = 0; i < nrows(); ++i) {
|
||||
unsigned wt = static_cast<unsigned>(T_to_string(m_rs[i]).size());
|
||||
if (wt > m_rs_width) {
|
||||
m_rs_width = wt;
|
||||
|
|
@ -78,7 +78,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::init_rs
|
|||
}
|
||||
|
||||
template <typename T, typename X> void core_solver_pretty_printer<T, X>::init_m_A_and_signs() {
|
||||
for (unsigned column = 0; column < ncols(); column++) {
|
||||
for (unsigned column = 0; column < ncols(); ++column) {
|
||||
vector<T> t(nrows(), zero_of_type<T>());
|
||||
for (const auto & c : m_core_solver.m_A.m_columns[column]){
|
||||
t[c.var()] = m_core_solver.m_A.get_val(c);
|
||||
|
|
@ -108,7 +108,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::init_m_
|
|||
}
|
||||
|
||||
template <typename T, typename X> void core_solver_pretty_printer<T, X>::init_column_widths() {
|
||||
for (unsigned i = 0; i < ncols(); i++) {
|
||||
for (unsigned i = 0; i < ncols(); ++i) {
|
||||
m_column_widths[i] = get_column_width(i);
|
||||
}
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ template <typename T, typename X> unsigned core_solver_pretty_printer<T, X>:: ge
|
|||
unsigned w = static_cast<unsigned>(std::max((size_t)m_costs[column].size(), T_to_string(m_core_solver.m_x[column]).size()));
|
||||
adjust_width_with_bounds(column, w);
|
||||
adjust_width_with_basis_heading(column, w);
|
||||
for (unsigned i = 0; i < nrows(); i++) {
|
||||
for (unsigned i = 0; i < nrows(); ++i) {
|
||||
unsigned cellw = static_cast<unsigned>(m_A[i][column].size());
|
||||
if (cellw > w) {
|
||||
w = cellw;
|
||||
|
|
@ -196,7 +196,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_x
|
|||
print_blanks_local(blanks, m_out);
|
||||
|
||||
auto bh = m_core_solver.m_x;
|
||||
for (unsigned i = 0; i < ncols(); i++) {
|
||||
for (unsigned i = 0; i < ncols(); ++i) {
|
||||
string s = T_to_string(bh[i]);
|
||||
int blanks = m_column_widths[i] - static_cast<int>(s.size());
|
||||
print_blanks_local(blanks, m_out);
|
||||
|
|
@ -241,7 +241,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_l
|
|||
m_out << m_lower_bounds_title;
|
||||
print_blanks_local(blanks, m_out);
|
||||
|
||||
for (unsigned i = 0; i < ncols(); i++) {
|
||||
for (unsigned i = 0; i < ncols(); ++i) {
|
||||
string s = get_lower_bound_string(i);
|
||||
int blanks = m_column_widths[i] - static_cast<unsigned>(s.size());
|
||||
print_blanks_local(blanks, m_out);
|
||||
|
|
@ -258,7 +258,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_u
|
|||
m_out << m_upp_bounds_title;
|
||||
print_blanks_local(blanks, m_out);
|
||||
|
||||
for (unsigned i = 0; i < ncols(); i++) {
|
||||
for (unsigned i = 0; i < ncols(); ++i) {
|
||||
string s = get_upp_bound_string(i);
|
||||
int blanks = m_column_widths[i] - static_cast<unsigned>(s.size());
|
||||
print_blanks_local(blanks, m_out);
|
||||
|
|
@ -273,7 +273,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_a
|
|||
}
|
||||
|
||||
template <typename T, typename X> void core_solver_pretty_printer<T, X>::print() {
|
||||
for (unsigned i = 0; i < nrows(); i++) {
|
||||
for (unsigned i = 0; i < nrows(); ++i) {
|
||||
print_row(i);
|
||||
}
|
||||
m_out << std::endl;
|
||||
|
|
@ -295,7 +295,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_b
|
|||
return;
|
||||
}
|
||||
auto bh = m_core_solver.m_basis_heading;
|
||||
for (unsigned i = 0; i < ncols(); i++) {
|
||||
for (unsigned i = 0; i < ncols(); ++i) {
|
||||
string s = T_to_string(bh[i]);
|
||||
int blanks = m_column_widths[i] - static_cast<unsigned>(s.size());
|
||||
print_blanks_local(blanks, m_out);
|
||||
|
|
@ -320,7 +320,7 @@ bool string_is_trivial(const std::string & s) {
|
|||
}
|
||||
|
||||
template <typename T, typename X> void core_solver_pretty_printer<T, X>::print_given_row(vector<string> & row, vector<string> & signs, X rst) {
|
||||
for (unsigned col = 0; col < row.size(); col++) {
|
||||
for (unsigned col = 0; col < row.size(); ++col) {
|
||||
unsigned width = m_column_widths[col];
|
||||
string s = row[col];
|
||||
if (m_squash_blanks && string_is_trivial(s))
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public:
|
|||
auto common_vars = get_vars_of_expr(ch[0]);
|
||||
for (lpvar j : common_vars) {
|
||||
bool divides_the_rest = true;
|
||||
for (unsigned i = 1; i < ch.size() && divides_the_rest; i++) {
|
||||
for (unsigned i = 1; i < ch.size() && divides_the_rest; ++i) {
|
||||
if (!ch[i]->contains(j))
|
||||
divides_the_rest = false;
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ public:
|
|||
|
||||
static void restore_front(const vector<nex*> ©, vector<nex**>& front) {
|
||||
SASSERT(copy.size() == front.size());
|
||||
for (unsigned i = 0; i < front.size(); i++)
|
||||
for (unsigned i = 0; i < front.size(); ++i)
|
||||
*(front[i]) = copy[i];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ public:
|
|||
dense_matrix operator*=(matrix<T, X> const & a) {
|
||||
SASSERT(column_count() == a.row_count());
|
||||
dense_matrix c(row_count(), a.column_count());
|
||||
for (unsigned i = 0; i < row_count(); i++) {
|
||||
for (unsigned j = 0; j < a.column_count(); j++) {
|
||||
for (unsigned i = 0; i < row_count(); ++i) {
|
||||
for (unsigned j = 0; j < a.column_count(); ++j) {
|
||||
T v = numeric_traits<T>::zero();
|
||||
for (unsigned k = 0; k < a.column_count(); k++) {
|
||||
for (unsigned k = 0; k < a.column_count(); ++k) {
|
||||
v += get_elem(i, k) * a(k, j);
|
||||
}
|
||||
c.set_elem(i, j, v);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ dense_matrix<T, X>::operator=(matrix<T, X> const & other){
|
|||
return *this;
|
||||
m_values = new T[m_m * m_n];
|
||||
for (unsigned i = 0; i < m_m; i ++)
|
||||
for (unsigned j = 0; j < m_n; j++)
|
||||
for (unsigned j = 0; j < m_n; ++j)
|
||||
m_values[i * m_n + j] = other.get_elem(i, j);
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ dense_matrix<T, X>::operator=(dense_matrix const & other){
|
|||
m_n = other.m_n;
|
||||
m_values.resize(m_m * m_n);
|
||||
for (unsigned i = 0; i < m_m; i ++)
|
||||
for (unsigned j = 0; j < m_n; j++)
|
||||
for (unsigned j = 0; j < m_n; ++j)
|
||||
m_values[i * m_n + j] = other.get_elem(i, j);
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -56,8 +56,8 @@ template <typename T, typename X> dense_matrix<T, X>::dense_matrix(matrix<T, X>
|
|||
m_m(other->row_count()),
|
||||
m_n(other->column_count()) {
|
||||
m_values.resize(m_m*m_n);
|
||||
for (unsigned i = 0; i < m_m; i++)
|
||||
for (unsigned j = 0; j < m_n; j++)
|
||||
for (unsigned i = 0; i < m_m; ++i)
|
||||
for (unsigned j = 0; j < m_n; ++j)
|
||||
m_values[i * m_n + j] = other->get_elem(i, j);
|
||||
}
|
||||
|
||||
|
|
@ -65,13 +65,13 @@ template <typename T, typename X> void dense_matrix<T, X>::apply_from_right(T *
|
|||
T * t = new T[m_m];
|
||||
for (int i = 0; i < m_m; i ++) {
|
||||
T v = numeric_traits<T>::zero();
|
||||
for (int j = 0; j < m_m; j++) {
|
||||
for (int j = 0; j < m_m; ++j) {
|
||||
v += w[j]* get_elem(j, i);
|
||||
}
|
||||
t[i] = v;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_m; i++) {
|
||||
for (int i = 0; i < m_m; ++i) {
|
||||
w[i] = t[i];
|
||||
}
|
||||
delete [] t;
|
||||
|
|
@ -81,11 +81,11 @@ template <typename T, typename X> void dense_matrix<T, X>::apply_from_right(vect
|
|||
vector<T> t(m_m, numeric_traits<T>::zero());
|
||||
for (unsigned i = 0; i < m_m; i ++) {
|
||||
auto & v = t[i];
|
||||
for (unsigned j = 0; j < m_m; j++)
|
||||
for (unsigned j = 0; j < m_m; ++j)
|
||||
v += w[j]* get_elem(j, i);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < m_m; i++)
|
||||
for (unsigned i = 0; i < m_m; ++i)
|
||||
w[i] = t[i];
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ apply_from_left_with_different_dims(vector<T> & w) {
|
|||
T * t = new T[m_m];
|
||||
for (int i = 0; i < m_m; i ++) {
|
||||
T v = numeric_traits<T>::zero();
|
||||
for (int j = 0; j < m_n; j++) {
|
||||
for (int j = 0; j < m_n; ++j) {
|
||||
v += w[j]* get_elem(i, j);
|
||||
}
|
||||
t[i] = v;
|
||||
|
|
@ -107,7 +107,7 @@ template <typename T, typename X> void dense_matrix<T, X>::apply_from_left(vecto
|
|||
T * t = new T[m_m];
|
||||
for (unsigned i = 0; i < m_m; i ++) {
|
||||
T v = numeric_traits<T>::zero();
|
||||
for (unsigned j = 0; j < m_m; j++) {
|
||||
for (unsigned j = 0; j < m_m; ++j) {
|
||||
v += w[j]* get_elem(i, j);
|
||||
}
|
||||
t[i] = v;
|
||||
|
|
@ -123,7 +123,7 @@ template <typename T, typename X> void dense_matrix<T, X>::apply_from_left(X * w
|
|||
T * t = new T[m_m];
|
||||
for (int i = 0; i < m_m; i ++) {
|
||||
T v = numeric_traits<T>::zero();
|
||||
for (int j = 0; j < m_m; j++) {
|
||||
for (int j = 0; j < m_m; ++j) {
|
||||
v += w[j]* get_elem(i, j);
|
||||
}
|
||||
t[i] = v;
|
||||
|
|
@ -139,7 +139,7 @@ template <typename T, typename X> void dense_matrix<T, X>::apply_from_left_to_X(
|
|||
vector<X> t(m_m);
|
||||
for (int i = 0; i < m_m; i ++) {
|
||||
X v = zero_of_type<X>();
|
||||
for (int j = 0; j < m_m; j++) {
|
||||
for (int j = 0; j < m_m; ++j) {
|
||||
v += w[j]* get_elem(i, j);
|
||||
}
|
||||
t[i] = v;
|
||||
|
|
@ -152,7 +152,7 @@ template <typename T, typename X> void dense_matrix<T, X>::apply_from_left_to_X(
|
|||
|
||||
|
||||
template <typename T, typename X> void dense_matrix<T, X>::swap_columns(unsigned a, unsigned b) {
|
||||
for (unsigned i = 0; i < m_m; i++) {
|
||||
for (unsigned i = 0; i < m_m; ++i) {
|
||||
T t = get_elem(i, a);
|
||||
set_elem(i, a, get_elem(i, b));
|
||||
set_elem(i, b, t);
|
||||
|
|
@ -160,7 +160,7 @@ template <typename T, typename X> void dense_matrix<T, X>::swap_columns(unsigned
|
|||
}
|
||||
|
||||
template <typename T, typename X> void dense_matrix<T, X>::swap_rows(unsigned a, unsigned b) {
|
||||
for (unsigned i = 0; i < m_n; i++) {
|
||||
for (unsigned i = 0; i < m_n; ++i) {
|
||||
T t = get_elem(a, i);
|
||||
set_elem(a, i, get_elem(b, i));
|
||||
set_elem(b, i, t);
|
||||
|
|
@ -168,7 +168,7 @@ template <typename T, typename X> void dense_matrix<T, X>::swap_rows(unsigned a,
|
|||
}
|
||||
|
||||
template <typename T, typename X> void dense_matrix<T, X>::multiply_row_by_constant(unsigned row, T & t) {
|
||||
for (unsigned i = 0; i < m_n; i++) {
|
||||
for (unsigned i = 0; i < m_n; ++i) {
|
||||
set_elem(row, i, t * get_elem(row, i));
|
||||
}
|
||||
}
|
||||
|
|
@ -177,8 +177,8 @@ template <typename T, typename X>
|
|||
dense_matrix<T, X> operator* (matrix<T, X> & a, matrix<T, X> & b){
|
||||
SASSERT(a.column_count() == b.row_count());
|
||||
dense_matrix<T, X> ret(a.row_count(), b.column_count());
|
||||
for (unsigned i = 0; i < ret.m_m; i++)
|
||||
for (unsigned j = 0; j< ret.m_n; j++) {
|
||||
for (unsigned i = 0; i < ret.m_m; ++i)
|
||||
for (unsigned j = 0; j< ret.m_n; ++j) {
|
||||
T v = numeric_traits<T>::zero();
|
||||
for (unsigned k = 0; k < a.column_count(); k ++){
|
||||
v += (a.get_elem(i, k) * b.get_elem(k, j));
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ namespace lp {
|
|||
|
||||
std::ostream& print_S(std::ostream& out) {
|
||||
out << "S:\n";
|
||||
for (unsigned ei = 0 ; ei < m_e_matrix.row_count(); ei++) {
|
||||
for (unsigned ei = 0 ; ei < m_e_matrix.row_count(); ++ei) {
|
||||
print_entry(ei, out, false, false, true);
|
||||
}
|
||||
return out;
|
||||
|
|
@ -468,7 +468,7 @@ namespace lp {
|
|||
bool invariant() const {
|
||||
// 1. For each j in [0..m_index.size()), if m_index[j] = -1, ensure no m_data[k].var() == j
|
||||
// otherwise verify m_data[m_index[j]].var() == j
|
||||
for (unsigned j = 0; j < m_index.size(); j++) {
|
||||
for (unsigned j = 0; j < m_index.size(); ++j) {
|
||||
int idx = m_index[j];
|
||||
if (idx == -1) {
|
||||
// Check that j is not in m_data
|
||||
|
|
@ -690,7 +690,7 @@ namespace lp {
|
|||
|
||||
auto& column = m_l_matrix.m_columns[j];
|
||||
int pivot_col_cell_index = -1;
|
||||
for (unsigned k = 0; k < column.size(); k++) {
|
||||
for (unsigned k = 0; k < column.size(); ++k) {
|
||||
if (column[k].var() == last_row_index) {
|
||||
pivot_col_cell_index = k;
|
||||
break;
|
||||
|
|
@ -1135,7 +1135,7 @@ namespace lp {
|
|||
|
||||
bool entries_are_ok() {
|
||||
if (lra.settings().get_cancel_flag()) return true;
|
||||
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ei++) {
|
||||
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ++ei) {
|
||||
if (entry_invariant(ei) == false) {
|
||||
TRACE(dio, tout << "bad entry:"; print_entry(ei, tout););
|
||||
return false;
|
||||
|
|
@ -1909,7 +1909,7 @@ namespace lp {
|
|||
}
|
||||
|
||||
void fill_f_vector(std_vector<unsigned> & f_vector) {
|
||||
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ei++) {
|
||||
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ++ei) {
|
||||
if (belongs_to_s(ei)) continue;
|
||||
if (m_e_matrix.m_rows[ei].size() == 0) {
|
||||
if (m_sum_of_fixed[ei].is_zero()) {
|
||||
|
|
@ -2011,7 +2011,7 @@ namespace lp {
|
|||
|
||||
bool columns_to_terms_is_correct() const {
|
||||
std::unordered_map<unsigned, std::unordered_set<unsigned>> c2t;
|
||||
for (unsigned k = 0; k < lra.terms().size(); k++) {
|
||||
for (unsigned k = 0; k < lra.terms().size(); ++k) {
|
||||
const lar_term* t = lra.terms()[k];
|
||||
if (!lia.column_is_int(t->j())) continue;
|
||||
SASSERT(t->j() != UINT_MAX);
|
||||
|
|
@ -2059,7 +2059,7 @@ namespace lp {
|
|||
return true;
|
||||
}
|
||||
bool is_in_sync() const {
|
||||
for (unsigned j = 0; j < m_e_matrix.column_count(); j++) {
|
||||
for (unsigned j = 0; j < m_e_matrix.column_count(); ++j) {
|
||||
unsigned external_j = m_var_register.local_to_external(j);
|
||||
if (external_j == UINT_MAX)
|
||||
continue;
|
||||
|
|
@ -2069,7 +2069,7 @@ namespace lp {
|
|||
|
||||
}
|
||||
|
||||
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ei++) {
|
||||
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ++ei) {
|
||||
auto it = m_row2fresh_defs.find(ei);
|
||||
if (it != m_row2fresh_defs.end()) {
|
||||
for (unsigned xt : it->second) {
|
||||
|
|
@ -2212,7 +2212,7 @@ namespace lp {
|
|||
}
|
||||
|
||||
bool is_eliminated_from_f(unsigned j) const {
|
||||
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ei++) {
|
||||
for (unsigned ei = 0; ei < m_e_matrix.row_count(); ++ei) {
|
||||
if (!belongs_to_f(ei))
|
||||
continue;
|
||||
const auto& row = m_e_matrix.m_rows[ei];
|
||||
|
|
@ -2488,7 +2488,7 @@ namespace lp {
|
|||
int kh_sign = 0; // the initial values of kh_sign and h_markovich_number do not matter, assign to remove the warning
|
||||
unsigned h_markovich_number = 0;
|
||||
unsigned ih = -1; // f_vector[ih] = h
|
||||
for (unsigned i = 0; i < f_vector.size(); i++) {
|
||||
for (unsigned i = 0; i < f_vector.size(); ++i) {
|
||||
unsigned ei = f_vector[i];
|
||||
SASSERT (belongs_to_f(ei));
|
||||
if (m_e_matrix.m_rows[ei].size() == 0) {
|
||||
|
|
|
|||
|
|
@ -517,7 +517,7 @@ bool emonics::invariant() const {
|
|||
TRACE(nla_solver_mons, display(tout););
|
||||
// the variable index contains exactly the active monomials
|
||||
unsigned mons = 0;
|
||||
for (lpvar v = 0; v < m_var2index.size(); v++)
|
||||
for (lpvar v = 0; v < m_var2index.size(); ++v)
|
||||
if (is_monic_var(v))
|
||||
mons++;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ void const_iterator_mon::init_vars_by_the_mask(unsigned_vector & k_vars, unsigne
|
|||
// the last element for m_factorization.m_rooted_vars goes to k_vars
|
||||
SASSERT(m_mask.size() + 1 == m_ff->m_vars.size());
|
||||
k_vars.push_back(m_ff->m_vars.back());
|
||||
for (unsigned j = 0; j < m_mask.size(); j++) {
|
||||
for (unsigned j = 0; j < m_mask.size(); ++j) {
|
||||
if (m_mask[j])
|
||||
k_vars.push_back(m_ff->m_vars[j]);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ public:
|
|||
unsigned m = row_count();
|
||||
unsigned n = column_count();
|
||||
general_matrix g(m, n);
|
||||
for (unsigned i = 0; i < m; i++)
|
||||
for (unsigned j = 0; j < n; j++)
|
||||
for (unsigned i = 0; i < m; ++i)
|
||||
for (unsigned j = 0; j < n; ++j)
|
||||
g[i][j] = (*this)[i][j];
|
||||
print_matrix<mpq>(g.m_data, out, blanks);
|
||||
}
|
||||
|
|
@ -88,8 +88,8 @@ public:
|
|||
|
||||
void print_submatrix(std::ostream & out, unsigned k, unsigned blanks = 0) const {
|
||||
general_matrix m(row_count() - k, column_count() - k);
|
||||
for (unsigned i = k; i < row_count(); i++) {
|
||||
for (unsigned j = k; j < column_count(); j++)
|
||||
for (unsigned i = k; i < row_count(); ++i) {
|
||||
for (unsigned j = k; j < column_count(); ++j)
|
||||
m[i-k][j-k] = (*this)[i][j];
|
||||
}
|
||||
print_matrix<mpq>(m.m_data, out, blanks);
|
||||
|
|
@ -118,9 +118,9 @@ public:
|
|||
SASSERT(m.row_count() == column_count());
|
||||
general_matrix ret(row_count(), m.column_count());
|
||||
for (unsigned i = 0; i < row_count(); i ++) {
|
||||
for (unsigned j = 0; j < m.column_count(); j++) {
|
||||
for (unsigned j = 0; j < m.column_count(); ++j) {
|
||||
mpq a(0);
|
||||
for (unsigned k = 0; k < column_count(); k++)
|
||||
for (unsigned k = 0; k < column_count(); ++k)
|
||||
a += ((*this)[i][k])*m[k][j];
|
||||
ret[i][j] = a;
|
||||
}
|
||||
|
|
@ -129,16 +129,16 @@ public:
|
|||
}
|
||||
|
||||
bool elements_are_equal(const general_matrix& m) const {
|
||||
for (unsigned i = 0; i < row_count(); i++)
|
||||
for (unsigned j = 0; j < column_count(); j++)
|
||||
for (unsigned i = 0; i < row_count(); ++i)
|
||||
for (unsigned j = 0; j < column_count(); ++j)
|
||||
if ( (*this)[i][j] != m[i][j])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool elements_are_equal_modulo(const general_matrix& m, const mpq & d) const {
|
||||
for (unsigned i = 0; i < row_count(); i++)
|
||||
for (unsigned j = 0; j < column_count(); j++)
|
||||
for (unsigned i = 0; i < row_count(); ++i)
|
||||
for (unsigned j = 0; j < column_count(); ++j)
|
||||
if (!is_zero(((*this)[i][j] - m[i][j]) % d))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -159,9 +159,9 @@ public:
|
|||
vector<mpq> operator*(const vector<mpq> & x) const {
|
||||
vector<mpq> r;
|
||||
SASSERT(x.size() == column_count());
|
||||
for (unsigned i = 0; i < row_count(); i++) {
|
||||
for (unsigned i = 0; i < row_count(); ++i) {
|
||||
mpq v(0);
|
||||
for (unsigned j = 0; j < column_count(); j++) {
|
||||
for (unsigned j = 0; j < column_count(); ++j) {
|
||||
v += (*this)[i][j] * x[j];
|
||||
}
|
||||
r.push_back(v);
|
||||
|
|
@ -214,8 +214,8 @@ public:
|
|||
if (n == column_count())
|
||||
return *this;
|
||||
general_matrix ret(row_count(), n);
|
||||
for (unsigned i = 0; i < row_count(); i++)
|
||||
for (unsigned j = 0; j < n; j++)
|
||||
for (unsigned i = 0; i < row_count(); ++i)
|
||||
for (unsigned j = 0; j < n; ++j)
|
||||
ret[i][j] = (*this)[i][j];
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ public:
|
|||
vector<mpq> r(a.column_count());
|
||||
for (unsigned j = 0; j < a.column_count(); j ++) {
|
||||
mpq t = zero_of_type<mpq>();
|
||||
for (unsigned i = 0; i < a.row_count(); i++) {
|
||||
for (unsigned i = 0; i < a.row_count(); ++i) {
|
||||
t += f[i] * a[i][j];
|
||||
}
|
||||
r[j] = t;
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ void extended_gcd_minimal_uv(const mpq & a, const mpq & b, mpq & d, mpq & u, mpq
|
|||
|
||||
template <typename M>
|
||||
bool prepare_pivot_for_lower_triangle(M &m, unsigned r) {
|
||||
for (unsigned i = r; i < m.row_count(); i++) {
|
||||
for (unsigned j = r; j < m.column_count(); j++) {
|
||||
for (unsigned i = r; i < m.row_count(); ++i) {
|
||||
for (unsigned j = r; j < m.column_count(); ++j) {
|
||||
if (!is_zero(m[i][j])) {
|
||||
if (i != r) {
|
||||
m.transpose_rows(i, r);
|
||||
|
|
@ -128,8 +128,8 @@ bool prepare_pivot_for_lower_triangle(M &m, unsigned r) {
|
|||
template <typename M>
|
||||
void pivot_column_non_fractional(M &m, unsigned r, bool & overflow, const mpq & big_number) {
|
||||
SASSERT(!is_zero(m[r][r]));
|
||||
for (unsigned j = r + 1; j < m.column_count(); j++) {
|
||||
for (unsigned i = r + 1; i < m.row_count(); i++) {
|
||||
for (unsigned j = r + 1; j < m.column_count(); ++j) {
|
||||
for (unsigned i = r + 1; i < m.row_count(); ++i) {
|
||||
if (
|
||||
(m[i][j] = (r > 0) ? (m[r][r]*m[i][j] - m[i][r]*m[r][j]) / m[r-1][r-1] :
|
||||
(m[r][r]*m[i][j] - m[i][r]*m[r][j]))
|
||||
|
|
@ -146,7 +146,7 @@ void pivot_column_non_fractional(M &m, unsigned r, bool & overflow, const mpq &
|
|||
template <typename M>
|
||||
unsigned to_lower_triangle_non_fractional(M &m, bool & overflow, const mpq& big_number) {
|
||||
unsigned i = 0;
|
||||
for (; i < m.row_count(); i++) {
|
||||
for (; i < m.row_count(); ++i) {
|
||||
if (!prepare_pivot_for_lower_triangle(m, i)) {
|
||||
return i;
|
||||
}
|
||||
|
|
@ -163,13 +163,13 @@ template <typename M>
|
|||
mpq gcd_of_row_starting_from_diagonal(const M& m, unsigned i) {
|
||||
mpq g = zero_of_type<mpq>();
|
||||
unsigned j = i;
|
||||
for (; j < m.column_count() && is_zero(g); j++) {
|
||||
for (; j < m.column_count() && is_zero(g); ++j) {
|
||||
const auto & t = m[i][j];
|
||||
if (!is_zero(t))
|
||||
g = abs(t);
|
||||
}
|
||||
SASSERT(!is_zero(g));
|
||||
for (; j < m.column_count(); j++) {
|
||||
for (; j < m.column_count(); ++j) {
|
||||
const auto & t = m[i][j];
|
||||
if (!is_zero(t))
|
||||
g = gcd(g, t);
|
||||
|
|
@ -193,7 +193,7 @@ mpq determinant_of_rectangular_matrix(const M& m, svector<unsigned> & basis_rows
|
|||
if (rank == 0)
|
||||
return one_of_type<mpq>();
|
||||
|
||||
for (unsigned i = 0; i < rank; i++) {
|
||||
for (unsigned i = 0; i < rank; ++i) {
|
||||
basis_rows.push_back(m_copy.adjust_row(i));
|
||||
}
|
||||
TRACE(hnf_calc, tout << "basis_rows = "; print_vector(basis_rows, tout); m_copy.print(tout, "m_copy = "););
|
||||
|
|
@ -236,13 +236,13 @@ class hnf {
|
|||
|
||||
#ifdef Z3DEBUG
|
||||
void buffer_p_col_i_plus_q_col_j_H(const mpq & p, unsigned i, const mpq & q, unsigned j) {
|
||||
for (unsigned k = i; k < m_m; k++) {
|
||||
for (unsigned k = i; k < m_m; ++k) {
|
||||
m_buffer[k] = p * m_H[k][i] + q * m_H[k][j];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
bool zeros_in_column_W_above(unsigned i) {
|
||||
for (unsigned k = 0; k < i; k++)
|
||||
for (unsigned k = 0; k < i; ++k)
|
||||
if (!is_zero(m_W[k][i]))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -250,13 +250,13 @@ class hnf {
|
|||
|
||||
void buffer_p_col_i_plus_q_col_j_W_modulo(const mpq & p, const mpq & q) {
|
||||
SASSERT(zeros_in_column_W_above(m_i));
|
||||
for (unsigned k = m_i; k < m_m; k++) {
|
||||
for (unsigned k = m_i; k < m_m; ++k) {
|
||||
m_buffer[k] = mod_R_balanced(mod_R_balanced(p * m_W[k][m_i]) + mod_R_balanced(q * m_W[k][m_j]));
|
||||
}
|
||||
}
|
||||
#ifdef Z3DEBUG
|
||||
void buffer_p_col_i_plus_q_col_j_U(const mpq & p, unsigned i, const mpq & q, unsigned j) {
|
||||
for (unsigned k = 0; k < m_n; k++) {
|
||||
for (unsigned k = 0; k < m_n; ++k) {
|
||||
m_buffer[k] = p * m_U[k][i] + q * m_U[k][j];
|
||||
}
|
||||
}
|
||||
|
|
@ -284,12 +284,12 @@ class hnf {
|
|||
}
|
||||
|
||||
void copy_buffer_to_col_i_H(unsigned i) {
|
||||
for (unsigned k = i; k < m_m; k++) {
|
||||
for (unsigned k = i; k < m_m; ++k) {
|
||||
m_H[k][i] = m_buffer[k];
|
||||
}
|
||||
}
|
||||
void copy_buffer_to_col_i_U(unsigned i) {
|
||||
for (unsigned k = 0; k < m_n; k++)
|
||||
for (unsigned k = 0; k < m_n; ++k)
|
||||
m_U[k][i] = m_buffer[k];
|
||||
}
|
||||
|
||||
|
|
@ -301,17 +301,17 @@ class hnf {
|
|||
|
||||
void multiply_U_reverse_from_left_by(unsigned i, unsigned j, const mpq & a, const mpq & b, const mpq & c, const mpq d) {
|
||||
// the new i-th row goes to the buffer
|
||||
for (unsigned k = 0; k < m_n; k++) {
|
||||
for (unsigned k = 0; k < m_n; ++k) {
|
||||
m_buffer[k] = a * m_U_reverse[i][k] + b * m_U_reverse[j][k];
|
||||
}
|
||||
|
||||
// calculate the new j-th row in place
|
||||
for (unsigned k = 0; k < m_n; k++) {
|
||||
for (unsigned k = 0; k < m_n; ++k) {
|
||||
m_U_reverse[j][k] = c * m_U_reverse[i][k] + d * m_U_reverse[j][k];
|
||||
}
|
||||
|
||||
// copy the buffer into i-th row
|
||||
for (unsigned k = 0; k < m_n; k++) {
|
||||
for (unsigned k = 0; k < m_n; ++k) {
|
||||
m_U_reverse[i][k] = m_buffer[k];
|
||||
}
|
||||
}
|
||||
|
|
@ -346,13 +346,13 @@ class hnf {
|
|||
|
||||
|
||||
void switch_sign_for_column(unsigned i) {
|
||||
for (unsigned k = i; k < m_m; k++)
|
||||
for (unsigned k = i; k < m_m; ++k)
|
||||
m_H[k][i].neg();
|
||||
for (unsigned k = 0; k < m_n; k++)
|
||||
for (unsigned k = 0; k < m_n; ++k)
|
||||
m_U[k][i].neg();
|
||||
|
||||
// switch sign for the i-th row in the reverse m_U_reverse
|
||||
for (unsigned k = 0; k < m_n; k++)
|
||||
for (unsigned k = 0; k < m_n; ++k)
|
||||
m_U_reverse[i][k].neg();
|
||||
|
||||
}
|
||||
|
|
@ -365,14 +365,14 @@ class hnf {
|
|||
|
||||
void replace_column_j_by_j_minus_u_col_i_H(unsigned i, unsigned j, const mpq & u) {
|
||||
SASSERT(j < i);
|
||||
for (unsigned k = i; k < m_m; k++) {
|
||||
for (unsigned k = i; k < m_m; ++k) {
|
||||
m_H[k][j] -= u * m_H[k][i];
|
||||
}
|
||||
}
|
||||
void replace_column_j_by_j_minus_u_col_i_U(unsigned i, unsigned j, const mpq & u) {
|
||||
|
||||
SASSERT(j < i);
|
||||
for (unsigned k = 0; k < m_n; k++) {
|
||||
for (unsigned k = 0; k < m_n; ++k) {
|
||||
m_U[k][j] -= u * m_U[k][i];
|
||||
}
|
||||
// Here we multiply from m_U from the right by the matrix ( 1, 0)
|
||||
|
|
@ -380,7 +380,7 @@ class hnf {
|
|||
// To adjust the reverse we multiply it from the left by (1, 0)
|
||||
// (u, 1)
|
||||
|
||||
for (unsigned k = 0; k < m_n; k++) {
|
||||
for (unsigned k = 0; k < m_n; ++k) {
|
||||
m_U_reverse[i][k] += u * m_U_reverse[j][k];
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ class hnf {
|
|||
void work_on_columns_less_than_i_in_the_triangle(unsigned i) {
|
||||
const mpq & mii = m_H[i][i];
|
||||
if (is_zero(mii)) return;
|
||||
for (unsigned j = 0; j < i; j++) {
|
||||
for (unsigned j = 0; j < i; ++j) {
|
||||
const mpq & mij = m_H[i][j];
|
||||
if (!is_pos(mij) && - mij < mii)
|
||||
continue;
|
||||
|
|
@ -401,7 +401,7 @@ class hnf {
|
|||
}
|
||||
|
||||
void process_row(unsigned i) {
|
||||
for (unsigned j = i + 1; j < m_n; j++) {
|
||||
for (unsigned j = i + 1; j < m_n; ++j) {
|
||||
process_row_column(i, j);
|
||||
}
|
||||
if (i >= m_n) {
|
||||
|
|
@ -415,14 +415,14 @@ class hnf {
|
|||
}
|
||||
|
||||
void calculate() {
|
||||
for (unsigned i = 0; i < m_m; i++) {
|
||||
for (unsigned i = 0; i < m_m; ++i) {
|
||||
process_row(i);
|
||||
}
|
||||
}
|
||||
|
||||
void prepare_U_and_U_reverse() {
|
||||
m_U = M(m_H.column_count());
|
||||
for (unsigned i = 0; i < m_U.column_count(); i++)
|
||||
for (unsigned i = 0; i < m_U.column_count(); ++i)
|
||||
m_U[i][i] = 1;
|
||||
|
||||
m_U_reverse = m_U;
|
||||
|
|
@ -436,7 +436,7 @@ class hnf {
|
|||
const mpq& hii = m_H[i][i];
|
||||
if (is_neg(hii))
|
||||
return false;
|
||||
for (unsigned j = 0; j < i; j++) {
|
||||
for (unsigned j = 0; j < i; ++j) {
|
||||
const mpq & hij = m_H[i][j];
|
||||
if (is_pos(hij))
|
||||
return false;
|
||||
|
|
@ -448,7 +448,7 @@ class hnf {
|
|||
}
|
||||
|
||||
bool is_correct_form() const {
|
||||
for (unsigned i = 0; i < m_m; i++)
|
||||
for (unsigned i = 0; i < m_m; ++i)
|
||||
if (!row_is_correct_form(i))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -483,14 +483,14 @@ public:
|
|||
private:
|
||||
#endif
|
||||
void copy_buffer_to_col_i_W_modulo() {
|
||||
for (unsigned k = m_i; k < m_m; k++) {
|
||||
for (unsigned k = m_i; k < m_m; ++k) {
|
||||
m_W[k][m_i] = m_buffer[k];
|
||||
}
|
||||
}
|
||||
|
||||
void replace_column_j_by_j_minus_u_col_i_W(unsigned j, const mpq & u) {
|
||||
SASSERT(j < m_i);
|
||||
for (unsigned k = m_i; k < m_m; k++) {
|
||||
for (unsigned k = m_i; k < m_m; ++k) {
|
||||
m_W[k][j] -= u * m_W[k][m_i];
|
||||
// m_W[k][j] = mod_R_balanced(m_W[k][j]);
|
||||
}
|
||||
|
|
@ -501,7 +501,7 @@ private:
|
|||
unsigned n = u.column_count();
|
||||
if (m != n) return false;
|
||||
for (unsigned i = 0; i < m; i ++)
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
if (i == j) {
|
||||
if (one_of_type<mpq>() != u[i][j])
|
||||
return false;
|
||||
|
|
@ -549,13 +549,13 @@ private:
|
|||
SASSERT(is_pos(mii));
|
||||
|
||||
// adjust column m_i
|
||||
for (unsigned k = m_i + 1; k < m_m; k++) {
|
||||
for (unsigned k = m_i + 1; k < m_m; ++k) {
|
||||
m_W[k][m_i] *= u;
|
||||
m_W[k][m_i] = mod_R_balanced(m_W[k][m_i]);
|
||||
}
|
||||
|
||||
SASSERT(is_pos(mii));
|
||||
for (unsigned j = 0; j < m_i; j++) {
|
||||
for (unsigned j = 0; j < m_i; ++j) {
|
||||
const mpq & mij = m_W[m_i][j];
|
||||
if (!is_pos(mij) && - mij < mii)
|
||||
continue;
|
||||
|
|
@ -566,7 +566,7 @@ private:
|
|||
|
||||
|
||||
void process_row_modulo() {
|
||||
for (m_j = m_i + 1; m_j < m_n; m_j++) {
|
||||
for (m_j = m_i + 1; m_j < m_n; ++m_j) {
|
||||
process_column_in_row_modulo();
|
||||
}
|
||||
fix_row_under_diagonal_W_modulo();
|
||||
|
|
|
|||
|
|
@ -67,15 +67,15 @@ namespace lp {
|
|||
|
||||
void hnf_cutter::init_matrix_A() {
|
||||
m_A = general_matrix(terms_count(), vars().size());
|
||||
for (unsigned i = 0; i < terms_count(); i++)
|
||||
for (unsigned i = 0; i < terms_count(); ++i)
|
||||
initialize_row(i);
|
||||
}
|
||||
|
||||
// todo: as we need only one row i with non integral b[i] need to optimize later
|
||||
void hnf_cutter::find_h_minus_1_b(const general_matrix& H, vector<mpq> & b) {
|
||||
// the solution will be put into b
|
||||
for (unsigned i = 0; i < H.row_count() ;i++) {
|
||||
for (unsigned j = 0; j < i; j++) {
|
||||
for (unsigned i = 0; i < H.row_count() ;++i) {
|
||||
for (unsigned j = 0; j < i; ++j) {
|
||||
b[i] -= H[i][j]*b[j];
|
||||
}
|
||||
b[i] /= H[i][i];
|
||||
|
|
@ -95,7 +95,7 @@ namespace lp {
|
|||
int hnf_cutter::find_cut_row_index(const vector<mpq> & b) {
|
||||
int ret = -1;
|
||||
int n = 0;
|
||||
for (int i = 0; i < static_cast<int>(b.size()); i++) {
|
||||
for (int i = 0; i < static_cast<int>(b.size()); ++i) {
|
||||
if (is_integer(b[i]))
|
||||
continue;
|
||||
if (n == 0) {
|
||||
|
|
@ -114,13 +114,13 @@ namespace lp {
|
|||
// we solve x = ei * H_min_1
|
||||
// or x * H = ei
|
||||
unsigned m = H.row_count();
|
||||
for (unsigned k = i + 1; k < m; k++) {
|
||||
for (unsigned k = i + 1; k < m; ++k) {
|
||||
row[k] = zero_of_type<mpq>();
|
||||
}
|
||||
row[i] = one_of_type<mpq>() / H[i][i];
|
||||
for(int k = i - 1; k >= 0; k--) {
|
||||
mpq t = zero_of_type<mpq>();
|
||||
for (unsigned l = k + 1; l <= i; l++) {
|
||||
for (unsigned l = k + 1; l <= i; ++l) {
|
||||
t += H[l][k]*row[l];
|
||||
}
|
||||
row[k] = -t / H[k][k];
|
||||
|
|
@ -128,7 +128,7 @@ namespace lp {
|
|||
}
|
||||
|
||||
void hnf_cutter::fill_term(const vector<mpq> & row, lar_term& t) {
|
||||
for (unsigned j = 0; j < row.size(); j++) {
|
||||
for (unsigned j = 0; j < row.size(); ++j) {
|
||||
if (!is_zero(row[j]))
|
||||
t.add_monomial(row[j], m_var_register.local_to_external(j));
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ namespace lp {
|
|||
#ifdef Z3DEBUG
|
||||
vector<mpq> hnf_cutter::transform_to_local_columns(const vector<impq> & x) const {
|
||||
vector<mpq> ret;
|
||||
for (unsigned j = 0; j < vars().size(); j++) {
|
||||
for (unsigned j = 0; j < vars().size(); ++j) {
|
||||
ret.push_back(x[m_var_register.local_to_external(j)].x);
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ bool horner::horner_lemmas() {
|
|||
unsigned r = c().random();
|
||||
unsigned sz = rows.size();
|
||||
bool conflict = false;
|
||||
for (unsigned i = 0; i < sz && !conflict; i++) {
|
||||
for (unsigned i = 0; i < sz && !conflict; ++i) {
|
||||
m_row_index = rows[(i + r) % sz];
|
||||
if (lemmas_on_row(matrix.m_rows[m_row_index])) {
|
||||
c().lp_settings().stats().m_horner_conflicts++;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace lp {
|
|||
|
||||
|
||||
void print_vector_as_doubles(const vector<mpq> & t, std::ostream & out) {
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
for (unsigned i = 0; i < t.size(); ++i)
|
||||
out << t[i].get_double() << std::setprecision(3) << " ";
|
||||
out << std::endl;
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ void indexed_vector<T>::erase(unsigned j) {
|
|||
template <typename T>
|
||||
void indexed_vector<T>::print(std::ostream & out) {
|
||||
out << "m_index " << std::endl;
|
||||
for (unsigned i = 0; i < m_index.size(); i++) {
|
||||
for (unsigned i = 0; i < m_index.size(); ++i) {
|
||||
out << m_index[i] << " ";
|
||||
}
|
||||
out << std::endl;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ int int_branch::find_inf_int_base_column() {
|
|||
|
||||
// this loop looks for a column with the most usages, but breaks when
|
||||
// a column with a small span of bounds is found
|
||||
for (; k < lra.r_basis().size(); k++) {
|
||||
for (; k < lra.r_basis().size(); ++k) {
|
||||
j = lra.r_basis()[k];
|
||||
if (!lia.column_is_int_inf(j))
|
||||
continue;
|
||||
|
|
@ -92,7 +92,7 @@ int int_branch::find_inf_int_base_column() {
|
|||
}
|
||||
SASSERT(k == lra.r_basis().size() || n == 1);
|
||||
// this loop looks for boxed columns with a small span
|
||||
for (; k < lra.r_basis().size(); k++) {
|
||||
for (; k < lra.r_basis().size(); ++k) {
|
||||
j = lra.r_basis()[k];
|
||||
if (!lia.column_is_int_inf(j) || !lia.is_boxed(j))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace lp {
|
|||
lia_move int_cube::operator()() {
|
||||
lia.settings().stats().m_cube_calls++;
|
||||
TRACE(cube,
|
||||
for (unsigned j = 0; j < lra.number_of_vars(); j++)
|
||||
for (unsigned j = 0; j < lra.number_of_vars(); ++j)
|
||||
lia.display_column(tout, j);
|
||||
tout << lra.constraints();
|
||||
);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace lp {
|
|||
bool int_gcd_test::gcd_test() {
|
||||
reset_test();
|
||||
const auto & A = lra.A_r(); // getting the matrix
|
||||
for (unsigned i = 0; i < A.row_count(); i++) {
|
||||
for (unsigned i = 0; i < A.row_count(); ++i) {
|
||||
unsigned basic_var = lra.r_basis()[i];
|
||||
if (!lia.column_is_int(basic_var))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ namespace lp {
|
|||
|
||||
bool all_columns_are_integral() const {
|
||||
return true; // otherwise it never returns true!
|
||||
for (lpvar j = 0; j < lra.number_of_vars(); j++)
|
||||
for (lpvar j = 0; j < lra.number_of_vars(); ++j)
|
||||
if (!lra.column_is_int(j))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -449,14 +449,14 @@ namespace lp {
|
|||
|
||||
std::ostream& int_solver::display_inf_rows(std::ostream& out) const {
|
||||
unsigned num = lra.A_r().column_count();
|
||||
for (unsigned v = 0; v < num; v++) {
|
||||
for (unsigned v = 0; v < num; ++v) {
|
||||
if (column_is_int(v) && !get_value(v).is_int()) {
|
||||
display_column(out, v);
|
||||
}
|
||||
}
|
||||
|
||||
num = 0;
|
||||
for (unsigned i = 0; i < lra.A_r().row_count(); i++) {
|
||||
for (unsigned i = 0; i < lra.A_r().row_count(); ++i) {
|
||||
unsigned j = lrac.m_r_basis[i];
|
||||
if (column_is_int_inf(j)) {
|
||||
num++;
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ public:
|
|||
unsigned m_index;
|
||||
iterator(constraint_set const& cs, unsigned idx): cs(cs), m_index(idx) { forward(); }
|
||||
void next() { ++m_index; forward(); }
|
||||
void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); m_index++) ; }
|
||||
void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); ++m_index) ; }
|
||||
public:
|
||||
lar_base_constraint const& operator*() { return cs[m_index]; }
|
||||
lar_base_constraint const* operator->() const { return &cs[m_index]; }
|
||||
|
|
@ -231,7 +231,7 @@ public:
|
|||
unsigned m_index;
|
||||
iterator(constraint_set const& cs, unsigned idx): cs(cs), m_index(idx) { forward(); }
|
||||
void next() { ++m_index; forward(); }
|
||||
void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); m_index++) ; }
|
||||
void forward() { for (; m_index < cs.m_constraints.size() && !cs.is_active(m_index); ++m_index) ; }
|
||||
public:
|
||||
constraint_index operator*() { return m_index; }
|
||||
constraint_index const* operator->() const { return &m_index; }
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public:
|
|||
for (unsigned j : m_r_solver.m_basis) {
|
||||
SASSERT(m_r_solver.m_A.m_columns[j].size() == 1);
|
||||
}
|
||||
for (unsigned j =0; j < m_r_solver.m_basis_heading.size(); j++) {
|
||||
for (unsigned j =0; j < m_r_solver.m_basis_heading.size(); ++j) {
|
||||
if (m_r_solver.m_basis_heading[j] >= 0) continue;
|
||||
if (m_r_solver.m_column_types[j] == column_type::fixed) continue;
|
||||
SASSERT(static_cast<unsigned>(- m_r_solver.m_basis_heading[j] - 1) < m_r_solver.m_column_types.size());
|
||||
|
|
@ -199,7 +199,7 @@ public:
|
|||
|
||||
mpq find_delta_for_strict_boxed_bounds() const{
|
||||
mpq delta = numeric_traits<mpq>::one();
|
||||
for (unsigned j = 0; j < m_r_A.column_count(); j++ ) {
|
||||
for (unsigned j = 0; j < m_r_A.column_count(); ++j ) {
|
||||
if (m_column_types()[j] != column_type::boxed)
|
||||
continue;
|
||||
update_delta(delta, m_r_lower_bounds[j], m_r_upper_bounds[j]);
|
||||
|
|
@ -210,7 +210,7 @@ public:
|
|||
|
||||
mpq find_delta_for_strict_bounds(const mpq & initial_delta) const{
|
||||
mpq delta = initial_delta;
|
||||
for (unsigned j = 0; j < m_r_A.column_count(); j++ ) {
|
||||
for (unsigned j = 0; j < m_r_A.column_count(); ++j ) {
|
||||
if (lower_bound_is_set(j))
|
||||
update_delta(delta, m_r_lower_bounds[j], m_r_x[j]);
|
||||
if (upper_bound_is_set(j))
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void lar_core_solver::fill_not_improvable_zero_sum() {
|
|||
m_infeasible_linear_combination.push_back(std::make_pair(cost_j, j));
|
||||
}
|
||||
// m_costs are expressed by m_d ( additional costs), substructing the latter gives 0
|
||||
for (unsigned j = 0; j < m_r_solver.m_n(); j++) {
|
||||
for (unsigned j = 0; j < m_r_solver.m_n(); ++j) {
|
||||
if (m_r_solver.m_basis_heading[j] >= 0) continue;
|
||||
const mpq & d_j = m_r_solver.m_d[j];
|
||||
if (!numeric_traits<mpq>::is_zero(d_j))
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ namespace lp {
|
|||
}
|
||||
|
||||
std::ostream& lar_solver::print_values(std::ostream& out) const {
|
||||
for (unsigned i = 0; i < get_core_solver().r_x().size(); i++) {
|
||||
for (unsigned i = 0; i < get_core_solver().r_x().size(); ++i) {
|
||||
const numeric_pair<mpq>& rp = get_core_solver().r_x(i);
|
||||
out << this->get_variable_name(i) << " -> " << rp << "\n";
|
||||
}
|
||||
|
|
@ -564,7 +564,7 @@ namespace lp {
|
|||
SASSERT(get_core_solver().m_r_solver.m_basis.size() == A_r().row_count());
|
||||
SASSERT(get_core_solver().m_r_solver.basis_heading_is_correct());
|
||||
SASSERT(A_r().column_count() == n);
|
||||
TRACE(lar_solver_details, for (unsigned j = 0; j < n; j++) print_column_info(j, tout) << "\n";);
|
||||
TRACE(lar_solver_details, for (unsigned j = 0; j < n; ++j) print_column_info(j, tout) << "\n";);
|
||||
|
||||
get_core_solver().pop(k);
|
||||
remove_non_fixed_from_fixed_var_table();
|
||||
|
|
@ -689,13 +689,13 @@ namespace lp {
|
|||
}
|
||||
|
||||
bool lar_solver::costs_are_zeros_for_r_solver() const {
|
||||
for (unsigned j = 0; j < get_core_solver().m_r_solver.m_costs.size(); j++) {
|
||||
for (unsigned j = 0; j < get_core_solver().m_r_solver.m_costs.size(); ++j) {
|
||||
SASSERT(is_zero(get_core_solver().m_r_solver.m_costs[j]));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool lar_solver::reduced_costs_are_zeroes_for_r_solver() const {
|
||||
for (unsigned j = 0; j < get_core_solver().m_r_solver.m_d.size(); j++) {
|
||||
for (unsigned j = 0; j < get_core_solver().m_r_solver.m_d.size(); ++j) {
|
||||
SASSERT(is_zero(get_core_solver().m_r_solver.m_d[j]));
|
||||
}
|
||||
return true;
|
||||
|
|
@ -817,7 +817,7 @@ namespace lp {
|
|||
prepare_costs_for_r_solver(term);
|
||||
ret = maximize_term_on_tableau(term, term_max);
|
||||
if (ret && max_coeffs != nullptr) {
|
||||
for (unsigned j = 0; j < column_count(); j++) {
|
||||
for (unsigned j = 0; j < column_count(); ++j) {
|
||||
const mpq& d_j = get_core_solver().m_r_solver.m_d[j];
|
||||
if (d_j.is_zero())
|
||||
continue;
|
||||
|
|
@ -871,7 +871,7 @@ namespace lp {
|
|||
impq opt_val = term_max;
|
||||
|
||||
bool change = false;
|
||||
for (unsigned j = 0; j < get_core_solver().r_x().size(); j++) {
|
||||
for (unsigned j = 0; j < get_core_solver().r_x().size(); ++j) {
|
||||
if (!column_is_int(j))
|
||||
continue;
|
||||
if (column_value_is_integer(j))
|
||||
|
|
@ -1144,7 +1144,7 @@ namespace lp {
|
|||
}
|
||||
#ifdef Z3DEBUG
|
||||
bool lar_solver::fixed_base_removed_correctly() const {
|
||||
for (unsigned i = 0; i < A_r().row_count(); i++) {
|
||||
for (unsigned i = 0; i < A_r().row_count(); ++i) {
|
||||
unsigned j = get_base_column_in_row(i);
|
||||
if (column_is_fixed(j)) {
|
||||
for (const auto & c : A_r().m_rows[i] ) {
|
||||
|
|
@ -1181,7 +1181,7 @@ namespace lp {
|
|||
|
||||
|
||||
bool lar_solver::ax_is_correct() const {
|
||||
for (unsigned i = 0; i < A_r().row_count(); i++) {
|
||||
for (unsigned i = 0; i < A_r().row_count(); ++i) {
|
||||
if (!row_is_correct(i)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1500,7 +1500,7 @@ namespace lp {
|
|||
|
||||
unsigned n = get_core_solver().r_x().size();
|
||||
|
||||
for (unsigned j = 0; j < n; j++)
|
||||
for (unsigned j = 0; j < n; ++j)
|
||||
variable_values[j] = get_value(j);
|
||||
|
||||
TRACE(lar_solver_model, tout << "delta = " << m_imp->m_delta << "\nmodel:\n";
|
||||
|
|
@ -1529,7 +1529,7 @@ namespace lp {
|
|||
do {
|
||||
m_imp->m_set_of_different_pairs.clear();
|
||||
m_imp->m_set_of_different_singles.clear();
|
||||
for (j = 0; j < n; j++) {
|
||||
for (j = 0; j < n; ++j) {
|
||||
const numeric_pair<mpq>& rp = get_core_solver().r_x(j);
|
||||
mpq x = rp.x + m_imp->m_delta * rp.y;
|
||||
m_imp->m_set_of_different_pairs.insert(rp);
|
||||
|
|
@ -1546,7 +1546,7 @@ namespace lp {
|
|||
|
||||
void lar_solver::get_model_do_not_care_about_diff_vars(std::unordered_map<lpvar, mpq>& variable_values) const {
|
||||
mpq delta = get_core_solver().find_delta_for_strict_bounds(m_imp->m_settings.m_epsilon);
|
||||
for (unsigned i = 0; i < get_core_solver().r_x().size(); i++) {
|
||||
for (unsigned i = 0; i < get_core_solver().r_x().size(); ++i) {
|
||||
const impq& rp = get_core_solver().r_x(i);
|
||||
variable_values[i] = rp.x + delta * rp.y;
|
||||
}
|
||||
|
|
@ -1561,7 +1561,7 @@ namespace lp {
|
|||
|
||||
void lar_solver::get_rid_of_inf_eps() {
|
||||
bool y_is_zero = true;
|
||||
for (unsigned j = 0; j < number_of_vars(); j++) {
|
||||
for (unsigned j = 0; j < number_of_vars(); ++j) {
|
||||
if (!get_core_solver().r_x(j).y.is_zero()) {
|
||||
y_is_zero = false;
|
||||
break;
|
||||
|
|
@ -1570,7 +1570,7 @@ namespace lp {
|
|||
if (y_is_zero)
|
||||
return;
|
||||
mpq delta = get_core_solver().find_delta_for_strict_bounds(m_imp->m_settings.m_epsilon);
|
||||
for (unsigned j = 0; j < number_of_vars(); j++) {
|
||||
for (unsigned j = 0; j < number_of_vars(); ++j) {
|
||||
auto& v = get_core_solver().r_x(j);
|
||||
if (!v.y.is_zero()) {
|
||||
v = impq(v.x + delta * v.y);
|
||||
|
|
@ -1608,7 +1608,7 @@ namespace lp {
|
|||
out << constraints();
|
||||
print_terms(out);
|
||||
pp(out).print();
|
||||
for (unsigned j = 0; j < number_of_vars(); j++)
|
||||
for (unsigned j = 0; j < number_of_vars(); ++j)
|
||||
print_column_info(j, out);
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1666,7 +1666,7 @@ namespace lp {
|
|||
|
||||
void lar_solver::fill_var_set_for_random_update(unsigned sz, lpvar const* vars, vector<unsigned>& column_list) {
|
||||
TRACE(lar_solver_rand, tout << "sz = " << sz << "\n";);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
lpvar var = vars[i];
|
||||
if (column_has_term(var)) {
|
||||
if (m_imp->m_columns[var].associated_with_row()) {
|
||||
|
|
@ -1848,7 +1848,7 @@ namespace lp {
|
|||
|
||||
bool lar_solver::model_is_int_feasible() const {
|
||||
unsigned n = A_r().column_count();
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
if (column_is_int(j) && !column_value_is_integer(j))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2571,7 +2571,7 @@ namespace lp {
|
|||
|
||||
|
||||
void lar_solver::round_to_integer_solution() {
|
||||
for (unsigned j = 0; j < column_count(); j++) {
|
||||
for (unsigned j = 0; j < column_count(); ++j) {
|
||||
if (!column_is_int(j)) continue;
|
||||
if (column_has_term(j)) continue;
|
||||
impq & v = get_core_solver().r_x(j);
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ public:
|
|||
void collect_more_rows_for_lp_propagation();
|
||||
template <typename T>
|
||||
void check_missed_propagations(lp_bound_propagator<T>& bp) {
|
||||
for (unsigned i = 0; i < A_r().row_count(); i++)
|
||||
for (unsigned i = 0; i < A_r().row_count(); ++i)
|
||||
if (!touched_rows().contains(i))
|
||||
if (0 < calculate_implied_bounds_for_row(i, bp)) {
|
||||
verbose_stream() << i << ": " << get_row(i) << "\n";
|
||||
|
|
@ -522,7 +522,7 @@ public:
|
|||
bool has_int_var() const;
|
||||
|
||||
inline bool has_inf_int() const {
|
||||
for (unsigned j = 0; j < column_count(); j++) {
|
||||
for (unsigned j = 0; j < column_count(); ++j) {
|
||||
if (column_is_int(j) && !column_value_is_int(j))
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ public:
|
|||
auto it = m_coeffs.begin();
|
||||
r.add_var(it->m_key);
|
||||
it++;
|
||||
for(;it != m_coeffs.end(); it++) {
|
||||
for(;it != m_coeffs.end(); ++it) {
|
||||
r.add_monomial(it->m_value / a, it->m_key);
|
||||
}
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ template <typename T, typename X>
|
|||
X dot_product(const vector<T> & a, const vector<X> & b) {
|
||||
SASSERT(a.size() == b.size());
|
||||
auto r = zero_of_type<X>();
|
||||
for (unsigned i = 0; i < a.size(); i++) {
|
||||
for (unsigned i = 0; i < a.size(); ++i) {
|
||||
r += a[i] * b[i];
|
||||
}
|
||||
return r;
|
||||
|
|
@ -176,7 +176,7 @@ public:
|
|||
|
||||
bool need_to_pivot_to_basis_tableau() const {
|
||||
unsigned m = m_A.row_count();
|
||||
for (unsigned i = 0; i < m; i++) {
|
||||
for (unsigned i = 0; i < m; ++i) {
|
||||
unsigned bj = m_basis[i];
|
||||
SASSERT(m_A.m_columns[bj].size() > 0);
|
||||
if (m_A.m_columns[bj].size() > 1)
|
||||
|
|
@ -198,7 +198,7 @@ public:
|
|||
|
||||
|
||||
unsigned n = m_A.column_count();
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
if (m_basis_heading[j] >= 0) {
|
||||
if (!is_zero(m_d[j])) {
|
||||
return false;
|
||||
|
|
@ -337,7 +337,7 @@ public:
|
|||
bool pivot_column_general(unsigned j, unsigned j_basic, indexed_vector<T> & w);
|
||||
void init_basic_part_of_basis_heading() {
|
||||
unsigned m = m_basis.size();
|
||||
for (unsigned i = 0; i < m; i++) {
|
||||
for (unsigned i = 0; i < m; ++i) {
|
||||
unsigned column = m_basis[i];
|
||||
m_basis_heading[column] = i;
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ public:
|
|||
}
|
||||
|
||||
bool bounds_for_boxed_are_set_correctly() const {
|
||||
for (unsigned j = 0; j < m_column_types.size(); j++) {
|
||||
for (unsigned j = 0; j < m_column_types.size(); ++j) {
|
||||
if (m_column_types[j] != column_type::boxed) continue;
|
||||
if (m_lower_bounds[j] > m_upper_bounds[j])
|
||||
return false;
|
||||
|
|
@ -588,7 +588,7 @@ public:
|
|||
|
||||
bool costs_on_nbasis_are_zeros() const {
|
||||
SASSERT(this->basis_heading_is_correct());
|
||||
for (unsigned j = 0; j < this->m_n(); j++) {
|
||||
for (unsigned j = 0; j < this->m_n(); ++j) {
|
||||
if (this->m_basis_heading[j] < 0)
|
||||
SASSERT(is_zero(this->m_costs[j]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ template <typename T, typename X> bool lp_core_solver_base<T, X>::calc_current_x
|
|||
}
|
||||
|
||||
template <typename T, typename X> bool lp_core_solver_base<T, X>::inf_heap_is_correct() const {
|
||||
for (unsigned j = 0; j < this->m_n(); j++) {
|
||||
for (unsigned j = 0; j < this->m_n(); ++j) {
|
||||
bool belongs_to_set = m_inf_heap.contains(j);
|
||||
bool is_feas = column_is_feasible(j);
|
||||
if (is_feas == belongs_to_set) {
|
||||
|
|
@ -226,7 +226,7 @@ divide_row_by_pivot(unsigned pivot_row, unsigned pivot_col) {
|
|||
int pivot_index = -1;
|
||||
auto & row = m_A.m_rows[pivot_row];
|
||||
unsigned size = static_cast<unsigned>(row.size());
|
||||
for (unsigned j = 0; j < size; j++) {
|
||||
for (unsigned j = 0; j < size; ++j) {
|
||||
auto & c = row[j];
|
||||
if (c.var() == pivot_col) {
|
||||
pivot_index = static_cast<int>(j);
|
||||
|
|
@ -241,7 +241,7 @@ divide_row_by_pivot(unsigned pivot_row, unsigned pivot_col) {
|
|||
return false;
|
||||
|
||||
// this->m_b[pivot_row] /= coeff;
|
||||
for (unsigned j = 0; j < size; j++) {
|
||||
for (unsigned j = 0; j < size; ++j) {
|
||||
auto & c = row[j];
|
||||
if (c.var() != pivot_col) {
|
||||
c.coeff() /= coeff;
|
||||
|
|
@ -257,7 +257,7 @@ pivot_column_tableau(unsigned j, unsigned piv_row_index) {
|
|||
return false;
|
||||
auto &column = m_A.m_columns[j];
|
||||
int pivot_col_cell_index = -1;
|
||||
for (unsigned k = 0; k < column.size(); k++) {
|
||||
for (unsigned k = 0; k < column.size(); ++k) {
|
||||
if (column[k].var() == piv_row_index) {
|
||||
pivot_col_cell_index = k;
|
||||
break;
|
||||
|
|
@ -295,7 +295,7 @@ pivot_column_tableau(unsigned j, unsigned piv_row_index) {
|
|||
template <typename T, typename X> bool lp_core_solver_base<T, X>::
|
||||
basis_has_no_doubles() const {
|
||||
std::set<unsigned> bm;
|
||||
for (unsigned i = 0; i < m_m(); i++) {
|
||||
for (unsigned i = 0; i < m_m(); ++i) {
|
||||
bm.insert(m_basis[i]);
|
||||
}
|
||||
return bm.size() == m_m();
|
||||
|
|
@ -311,18 +311,18 @@ non_basis_has_no_doubles() const {
|
|||
|
||||
template <typename T, typename X> bool lp_core_solver_base<T, X>::
|
||||
basis_is_correctly_represented_in_heading() const {
|
||||
for (unsigned i = 0; i < m_m(); i++)
|
||||
for (unsigned i = 0; i < m_m(); ++i)
|
||||
if (m_basis_heading[m_basis[i]] != static_cast<int>(i))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
template <typename T, typename X> bool lp_core_solver_base<T, X>::
|
||||
non_basis_is_correctly_represented_in_heading(std::list<unsigned>* non_basis_list) const {
|
||||
for (unsigned i = 0; i < m_nbasis.size(); i++)
|
||||
for (unsigned i = 0; i < m_nbasis.size(); ++i)
|
||||
if (m_basis_heading[m_nbasis[i]] != - static_cast<int>(i) - 1)
|
||||
return false;
|
||||
|
||||
for (unsigned j = 0; j < m_A.column_count(); j++)
|
||||
for (unsigned j = 0; j < m_A.column_count(); ++j)
|
||||
if (m_basis_heading[j] >= 0)
|
||||
SASSERT(static_cast<unsigned>(m_basis_heading[j]) < m_A.row_count() && m_basis[m_basis_heading[j]] == j);
|
||||
|
||||
|
|
@ -336,7 +336,7 @@ non_basis_is_correctly_represented_in_heading(std::list<unsigned>* non_basis_lis
|
|||
TRACE(lp_core, tout << "non_basis_list.size() = " << non_basis_list->size() << ", nbasis_set.size() = " << nbasis_set.size() << "\n";);
|
||||
return false;
|
||||
}
|
||||
for (auto it = non_basis_list->begin(); it != non_basis_list->end(); it++) {
|
||||
for (auto it = non_basis_list->begin(); it != non_basis_list->end(); ++it) {
|
||||
if (nbasis_set.find(*it) == nbasis_set.end()) {
|
||||
TRACE(lp_core, tout << "column " << *it << " is in m_non_basis_list but not in m_nbasis\n";);
|
||||
return false;
|
||||
|
|
@ -345,7 +345,7 @@ non_basis_is_correctly_represented_in_heading(std::list<unsigned>* non_basis_lis
|
|||
|
||||
// check for duplicates in m_non_basis_list
|
||||
nbasis_set.clear();
|
||||
for (auto it = non_basis_list->begin(); it != non_basis_list->end(); it++) {
|
||||
for (auto it = non_basis_list->begin(); it != non_basis_list->end(); ++it) {
|
||||
if (nbasis_set.find(*it) != nbasis_set.end()) {
|
||||
TRACE(lp_core, tout << "column " << *it << " is in m_non_basis_list twice\n";);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ namespace lp {
|
|||
unsigned best_col_sz = -1;
|
||||
unsigned bj = this->m_basis[i];
|
||||
bool bj_needs_to_grow = needs_to_grow(bj);
|
||||
for (unsigned k = 0; k < this->m_A.m_rows[i].size(); k++) {
|
||||
for (unsigned k = 0; k < this->m_A.m_rows[i].size(); ++k) {
|
||||
const row_cell<T> &rc = this->m_A.m_rows[i][k];
|
||||
unsigned j = rc.var();
|
||||
if (j == bj)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ void lp_primal_core_solver<T, X>::sort_non_basis() {
|
|||
// initialize m_non_basis_list from m_nbasis by using an iterator on m_non_basis_list
|
||||
auto it = m_non_basis_list.begin();
|
||||
unsigned j = 0;
|
||||
for (; j < this->m_nbasis.size(); j++, ++it) {
|
||||
for (; j < this->m_nbasis.size(); ++j, ++it) {
|
||||
unsigned col = *it = this->m_nbasis[j];
|
||||
this->m_basis_heading[col] = -static_cast<int>(j) - 1;
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::check_Ax_e
|
|||
delete [] ls;
|
||||
}
|
||||
template <typename T, typename X> void lp_primal_core_solver<T, X>::check_the_bounds() {
|
||||
for (unsigned i = 0; i < this->m_n(); i++) {
|
||||
for (unsigned i = 0; i < this->m_n(); ++i) {
|
||||
check_bound(i);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
|
|||
m_leaving_candidates.clear();
|
||||
auto & col = this->m_A.m_columns[entering];
|
||||
unsigned col_size = static_cast<unsigned>(col.size());
|
||||
for (;k < col_size && unlimited; k++) {
|
||||
for (;k < col_size && unlimited; ++k) {
|
||||
const column_cell & c = col[k];
|
||||
unsigned i = c.var();
|
||||
const T & ed = this->m_A.get_val(c);
|
||||
|
|
@ -221,7 +221,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
|
|||
}
|
||||
|
||||
X ratio;
|
||||
for (;k < col_size; k++) {
|
||||
for (;k < col_size; ++k) {
|
||||
const column_cell & c = col[k];
|
||||
unsigned i = c.var();
|
||||
const T & ed = this->m_A.get_val(c);
|
||||
|
|
@ -290,7 +290,7 @@ update_x_tableau(unsigned entering, const X& delta) {
|
|||
template <typename T, typename X> void lp_primal_core_solver<T, X>::init_reduced_costs_tableau() {
|
||||
|
||||
unsigned size = this->m_basis_heading.size();
|
||||
for (unsigned j = 0; j < size; j++) {
|
||||
for (unsigned j = 0; j < size; ++j) {
|
||||
if (this->m_basis_heading[j] >= 0)
|
||||
this->m_d[j] = zero_of_type<T>();
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ template <typename T, typename K >
|
|||
bool vectors_are_equal_(const T & a, const K &b) {
|
||||
if (a.size() != b.size())
|
||||
return false;
|
||||
for (unsigned i = 0; i < a.size(); i++){
|
||||
for (unsigned i = 0; i < a.size(); ++i){
|
||||
if (a[i] != b[i]) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ bool contains(const C & collection, const D & key) {
|
|||
|
||||
template <typename C>
|
||||
std::ostream& print_vector(const C * t, unsigned size, std::ostream & out) {
|
||||
for (unsigned i = 0; i < size; i++ )
|
||||
for (unsigned i = 0; i < size; ++i )
|
||||
out << t[i] << " ";
|
||||
out << std::endl;
|
||||
return out;
|
||||
|
|
@ -77,7 +77,7 @@ bool is_non_decreasing(const K& v) {
|
|||
return true; // v is empty
|
||||
auto b = v.begin();
|
||||
b++;
|
||||
for (; b != v.end(); a++, b++) {
|
||||
for (; b != v.end(); ++a, ++b) {
|
||||
if (*a > *b)
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void print_matrix(matrix<T, X> const * m, std::ostream & out);
|
|||
template <typename T>
|
||||
void print_matrix(const vector<vector<T>> & A, std::ostream & out, unsigned blanks_in_front = 0) {
|
||||
vector<vector<std::string>> s(A.size());
|
||||
for (unsigned i = 0; i < A.size(); i++) {
|
||||
for (unsigned i = 0; i < A.size(); ++i) {
|
||||
for (const auto & v : A[i]) {
|
||||
s[i].push_back(T_to_string(v));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ template <typename T, typename X>
|
|||
bool matrix<T, X>::is_equal(const matrix<T, X>& other) {
|
||||
if (other.row_count() != row_count() || other.column_count() != column_count())
|
||||
return false;
|
||||
for (unsigned i = 0; i < row_count(); i++) {
|
||||
for (unsigned j = 0; j < column_count(); j++) {
|
||||
for (unsigned i = 0; i < row_count(); ++i) {
|
||||
for (unsigned j = 0; j < column_count(); ++j) {
|
||||
auto a = get_elem(i, j);
|
||||
auto b = other.get_elem(i, j);
|
||||
|
||||
|
|
@ -47,13 +47,13 @@ void apply_to_vector(matrix<T, X> & m, T * w) {
|
|||
|
||||
T * wc = new T[dim];
|
||||
|
||||
for (unsigned i = 0; i < dim; i++) {
|
||||
for (unsigned i = 0; i < dim; ++i) {
|
||||
wc[i] = w[i];
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < dim; i++) {
|
||||
for (unsigned i = 0; i < dim; ++i) {
|
||||
T t = numeric_traits<T>::zero();
|
||||
for (unsigned j = 0; j < dim; j++) {
|
||||
for (unsigned j = 0; j < dim; ++j) {
|
||||
t += m(i, j) * wc[j];
|
||||
}
|
||||
w[i] = t;
|
||||
|
|
@ -65,7 +65,7 @@ void apply_to_vector(matrix<T, X> & m, T * w) {
|
|||
|
||||
unsigned get_width_of_column(unsigned j, vector<vector<std::string>> & A) {
|
||||
unsigned r = 0;
|
||||
for (unsigned i = 0; i < A.size(); i++) {
|
||||
for (unsigned i = 0; i < A.size(); ++i) {
|
||||
vector<std::string> & t = A[i];
|
||||
std::string str = t[j];
|
||||
unsigned s = static_cast<unsigned>(str.size());
|
||||
|
|
@ -77,8 +77,8 @@ unsigned get_width_of_column(unsigned j, vector<vector<std::string>> & A) {
|
|||
}
|
||||
|
||||
void print_matrix_with_widths(vector<vector<std::string>> & A, vector<unsigned> & ws, std::ostream & out, unsigned blanks_in_front) {
|
||||
for (unsigned i = 0; i < A.size(); i++) {
|
||||
for (unsigned j = 0; j < static_cast<unsigned>(A[i].size()); j++) {
|
||||
for (unsigned i = 0; i < A.size(); ++i) {
|
||||
for (unsigned j = 0; j < static_cast<unsigned>(A[i].size()); ++j) {
|
||||
if (i != 0 && j == 0)
|
||||
print_blanks(blanks_in_front, out);
|
||||
print_blanks(ws[j] - static_cast<unsigned>(A[i][j].size()), out);
|
||||
|
|
@ -92,7 +92,7 @@ void print_string_matrix(vector<vector<std::string>> & A, std::ostream & out, un
|
|||
vector<unsigned> widths;
|
||||
|
||||
if (!A.empty())
|
||||
for (unsigned j = 0; j < A[0].size(); j++) {
|
||||
for (unsigned j = 0; j < A[0].size(); ++j) {
|
||||
widths.push_back(get_width_of_column(j, A));
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ void print_string_matrix(vector<vector<std::string>> & A, std::ostream & out, un
|
|||
template <typename T>
|
||||
void print_matrix(vector<vector<T>> & A, std::ostream & out, unsigned blanks_in_front = 0) {
|
||||
vector<vector<std::string>> s(A.size());
|
||||
for (unsigned i = 0; i < A.size(); i++) {
|
||||
for (unsigned i = 0; i < A.size(); ++i) {
|
||||
for (const auto & v : A[i]) {
|
||||
s[i].push_back(T_to_string(v));
|
||||
}
|
||||
|
|
@ -116,8 +116,8 @@ void print_matrix(vector<vector<T>> & A, std::ostream & out, unsigned blanks_in_
|
|||
template <typename T, typename X>
|
||||
void print_matrix(matrix<T, X> const * m, std::ostream & out) {
|
||||
vector<vector<std::string>> A(m->row_count());
|
||||
for (unsigned i = 0; i < m->row_count(); i++) {
|
||||
for (unsigned j = 0; j < m->column_count(); j++) {
|
||||
for (unsigned i = 0; i < m->row_count(); ++i) {
|
||||
for (unsigned j = 0; j < m->column_count(); ++j) {
|
||||
A[i].push_back(T_to_string(m->get_elem(i, j)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
const svector<lp::lpvar>& vars() const { return m_vs; }
|
||||
bool empty() const { return m_vs.empty(); }
|
||||
bool is_sorted() const {
|
||||
for (unsigned i = 0; i + 1 < size(); i++)
|
||||
for (unsigned i = 0; i + 1 < size(); ++i)
|
||||
if (m_vs[i] > m_vs[i + 1])
|
||||
return false;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ bool nex_creator::gt_on_mul_nex(nex_mul const& m, nex const& b) const {
|
|||
|
||||
bool nex_creator::gt_on_sum_sum(const nex_sum& a, const nex_sum& b) const {
|
||||
unsigned size = std::min(a.size(), b.size());
|
||||
for (unsigned j = 0; j < size; j++) {
|
||||
for (unsigned j = 0; j < size; ++j) {
|
||||
if (gt(a[j], b[j]))
|
||||
return true;
|
||||
if (gt(b[j], a[j]))
|
||||
|
|
@ -248,7 +248,7 @@ bool nex_creator::gt(const nex& a, const nex& b) const {
|
|||
}
|
||||
|
||||
bool nex_creator::is_sorted(const nex_mul& e) const {
|
||||
for (unsigned j = 0; j < e.size() - 1; j++) {
|
||||
for (unsigned j = 0; j < e.size() - 1; ++j) {
|
||||
if (!(gt_on_nex_pow(e[j], e[j+1]))) {
|
||||
TRACE(grobner_d, tout << "not sorted e " << e << "\norder is incorrect " <<
|
||||
e[j] << " >= " << e[j + 1]<< "\n";);
|
||||
|
|
@ -442,7 +442,7 @@ void nex_creator::sort_join_sum(nex_sum& sum) {
|
|||
void nex_creator::simplify_children_of_sum(nex_sum& s) {
|
||||
ptr_vector<nex> to_promote;
|
||||
unsigned k = 0;
|
||||
for (unsigned j = 0; j < s.size(); j++) {
|
||||
for (unsigned j = 0; j < s.size(); ++j) {
|
||||
nex* e = s[j] = simplify(s[j]);
|
||||
if (e->is_sum()) {
|
||||
to_promote.push_back(e);
|
||||
|
|
@ -594,7 +594,7 @@ bool nex_creator::is_simplified(const nex& e) const {
|
|||
}
|
||||
|
||||
unsigned nex_creator::find_sum_in_mul(const nex_mul* a) const {
|
||||
for (unsigned j = 0; j < a->size(); j++)
|
||||
for (unsigned j = 0; j < a->size(); ++j)
|
||||
if ((*a)[j].e()->is_sum())
|
||||
return j;
|
||||
|
||||
|
|
@ -617,7 +617,7 @@ nex* nex_creator::canonize_mul(nex_mul *a) {
|
|||
if (power > 1)
|
||||
mf *= nex_pow(sclone, power - 1);
|
||||
mf *= nex_pow(e, 1);
|
||||
for (unsigned k = 0; k < a->size(); k++) {
|
||||
for (unsigned k = 0; k < a->size(); ++k) {
|
||||
if (k == j)
|
||||
continue;
|
||||
mf *= nex_pow(clone((*a)[k].e()), (*a)[k].pow());
|
||||
|
|
@ -636,7 +636,7 @@ nex* nex_creator::canonize(const nex *a) {
|
|||
nex *t = simplify(clone(a));
|
||||
if (t->is_sum()) {
|
||||
nex_sum & s = t->to_sum();
|
||||
for (unsigned j = 0; j < s.size(); j++) {
|
||||
for (unsigned j = 0; j < s.size(); ++j) {
|
||||
s[j] = canonize(s[j]);
|
||||
}
|
||||
t = simplify(&s);
|
||||
|
|
@ -657,7 +657,7 @@ bool nex_creator::equal(const nex* a, const nex* b) {
|
|||
n = std::max(j + 1, n);
|
||||
}
|
||||
cn.set_number_of_vars(n);
|
||||
for (lpvar j = 0; j < n; j++) {
|
||||
for (lpvar j = 0; j < n; ++j) {
|
||||
cn.set_var_weight(j, j);
|
||||
}
|
||||
nex * ca = cn.canonize(a);
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ public:
|
|||
// NSB: we can use region allocation, but still need to invoke destructor
|
||||
// because of 'rational' (and m_children in nex_mul unless we get rid of this)
|
||||
void pop(unsigned sz) {
|
||||
for (unsigned j = sz; j < m_allocated.size(); j++)
|
||||
for (unsigned j = sz; j < m_allocated.size(); ++j)
|
||||
dealloc(m_allocated[j]);
|
||||
m_allocated.resize(sz);
|
||||
TRACE(grobner_stats_d, tout << "m_allocated.size() = " << m_allocated.size() << "\n";);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ bool core::canonize_sign(const factorization& f) const {
|
|||
|
||||
void core::add_monic(lpvar v, unsigned sz, lpvar const* vs) {
|
||||
m_add_buffer.resize(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m_add_buffer[i] = vs[i];
|
||||
}
|
||||
m_emons.add(v, m_add_buffer);
|
||||
|
|
@ -635,7 +635,7 @@ void core::init_to_refine() {
|
|||
TRACE(nla_solver_details, tout << "emons:" << pp_emons(*this, m_emons););
|
||||
m_to_refine.reset();
|
||||
unsigned r = random(), sz = m_emons.number_of_monics();
|
||||
for (unsigned k = 0; k < sz; k++) {
|
||||
for (unsigned k = 0; k < sz; ++k) {
|
||||
auto const & m = *(m_emons.begin() + (k + r)% sz);
|
||||
if (!check_monic(m))
|
||||
insert_to_refine(m.var());
|
||||
|
|
@ -811,7 +811,7 @@ bool core::find_bfc_to_refine_on_monic(const monic& m, factorization & bf) {
|
|||
bool core::find_bfc_to_refine(const monic* & m, factorization & bf){
|
||||
m = nullptr;
|
||||
unsigned r = random(), sz = m_to_refine.size();
|
||||
for (unsigned k = 0; k < sz; k++) {
|
||||
for (unsigned k = 0; k < sz; ++k) {
|
||||
lpvar i = m_to_refine[(k + r) % sz];
|
||||
m = &m_emons[i];
|
||||
SASSERT (!check_monic(*m));
|
||||
|
|
@ -1143,7 +1143,7 @@ bool in_power(const svector<lpvar>& vs, unsigned l) {
|
|||
}
|
||||
|
||||
bool core::to_refine_is_correct() const {
|
||||
for (unsigned j = 0; j < lra.number_of_vars(); j++) {
|
||||
for (unsigned j = 0; j < lra.number_of_vars(); ++j) {
|
||||
if (!is_monic_var(j)) continue;
|
||||
bool valid = check_monic(emon(j));
|
||||
if (valid == m_to_refine.contains(j)) {
|
||||
|
|
@ -1193,7 +1193,7 @@ void core::patch_monomial(lpvar j) {
|
|||
rational r = val(j) / v;
|
||||
SASSERT((*m_patched_monic).is_sorted());
|
||||
TRACE(nla_solver, tout << "r = " << r << ", v = " << v << "\n";);
|
||||
for (unsigned l = 0; l < (*m_patched_monic).size(); l++) {
|
||||
for (unsigned l = 0; l < (*m_patched_monic).size(); ++l) {
|
||||
m_patched_var = (*m_patched_monic).vars()[l];
|
||||
if (!in_power((*m_patched_monic).vars(), l) &&
|
||||
!var_breaks_correct_monic(m_patched_var) &&
|
||||
|
|
@ -1216,7 +1216,7 @@ void core::patch_monomials_on_to_refine() {
|
|||
unsigned sz = to_refine.size();
|
||||
|
||||
unsigned start = random();
|
||||
for (unsigned i = 0; i < sz && !m_to_refine.empty(); i++)
|
||||
for (unsigned i = 0; i < sz && !m_to_refine.empty(); ++i)
|
||||
patch_monomial(to_refine[(start + i) % sz]);
|
||||
|
||||
TRACE(nla_solver, tout << "sz = " << sz << ", m_to_refine = " << m_to_refine.size() <<
|
||||
|
|
@ -1264,7 +1264,7 @@ void core::check_bounded_divisions() {
|
|||
// looking for a free variable inside of a monic to split
|
||||
void core::add_bounds() {
|
||||
unsigned r = random(), sz = m_to_refine.size();
|
||||
for (unsigned k = 0; k < sz; k++) {
|
||||
for (unsigned k = 0; k < sz; ++k) {
|
||||
lpvar i = m_to_refine[(k + r) % sz];
|
||||
auto const& m = m_emons[i];
|
||||
for (lpvar j : m.vars()) {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ bool uniform_le(const T& a, const T& b, unsigned & strict_i) {
|
|||
strict_i = -1;
|
||||
bool z_b = false;
|
||||
|
||||
for (unsigned i = 0; i < a.size(); i++) {
|
||||
for (unsigned i = 0; i < a.size(); ++i) {
|
||||
if (a[i] > b[i]){
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ namespace nla {
|
|||
continue;
|
||||
bool gcd_fail = true;
|
||||
dd::pdd kx = m.mk_var(x) * m.mk_val(k);
|
||||
for (unsigned r = 0; gcd_fail && r < k; r++) {
|
||||
for (unsigned r = 0; gcd_fail && r < k; ++r) {
|
||||
dd::pdd kx_plus_r = kx + m.mk_val(r);
|
||||
auto q = p.subst_pdd(x, kx_plus_r);
|
||||
if (!fails_gcd_test(q))
|
||||
|
|
@ -917,13 +917,13 @@ namespace nla {
|
|||
void grobner::set_level2var() {
|
||||
unsigned n = lra.column_count();
|
||||
unsigned_vector sorted_vars(n), weighted_vars(n);
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
sorted_vars[j] = j;
|
||||
weighted_vars[j] = c().get_var_weight(j);
|
||||
}
|
||||
#if 1
|
||||
// potential update to weights
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
if (c().is_monic_var(j) && c().m_to_refine.contains(j)) {
|
||||
for (lpvar k : c().m_emons[j].vars()) {
|
||||
weighted_vars[k] += 6;
|
||||
|
|
@ -938,7 +938,7 @@ namespace nla {
|
|||
return wa < wb || (wa == wb && a < b); });
|
||||
|
||||
unsigned_vector l2v(n);
|
||||
for (unsigned j = 0; j < n; j++)
|
||||
for (unsigned j = 0; j < n; ++j)
|
||||
l2v[j] = sorted_vars[j];
|
||||
|
||||
m_pdd_manager.reset(l2v);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ lp::lar_term intervals::expression_to_normalized_term(const nex_sum* e, rational
|
|||
t.add_monomial(p.first, p.second);
|
||||
}
|
||||
} else {
|
||||
for (unsigned k = 0; k < v.size(); k++) {
|
||||
for (unsigned k = 0; k < v.size(); ++k) {
|
||||
auto& p = v[k];
|
||||
if (k != a_index)
|
||||
t.add_monomial(p.first/a, p.second);
|
||||
|
|
@ -314,7 +314,7 @@ bool intervals::interval_of_sum_no_term(const nex_sum& e, scoped_dep_interval &
|
|||
|
||||
if (!interval_of_expr<wd>(e[0], 1, sdi, f))
|
||||
return false;
|
||||
for (unsigned k = 1; k < e.size(); k++) {
|
||||
for (unsigned k = 1; k < e.size(); ++k) {
|
||||
TRACE(nla_intervals_details, tout << "e[" << k << "]= " << *e[k] << "\n";);
|
||||
scoped_dep_interval b(get_dep_intervals());
|
||||
if (!interval_of_expr<wd>(e[k], 1, b, f)) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ monotone::monotone(core * c) : common(c) {}
|
|||
void monotone::monotonicity_lemma() {
|
||||
unsigned shift = random();
|
||||
unsigned size = c().m_to_refine.size();
|
||||
for (unsigned i = 0; i < size && !done(); i++) {
|
||||
for (unsigned i = 0; i < size && !done(); ++i) {
|
||||
lpvar v = c().m_to_refine[(i + shift) % size];
|
||||
monotonicity_lemma(c().emons()[v]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,14 +226,14 @@ void order::order_lemma_on_factorization(const monic& m, const factorization& ab
|
|||
|
||||
if (mv != fv && !c().has_real(m)) {
|
||||
bool gt = mv > fv;
|
||||
for (unsigned j = 0, k = 1; j < 2; j++, k--) {
|
||||
for (unsigned j = 0, k = 1; j < 2; ++j, k--) {
|
||||
lemma_builder lemma(_(), __FUNCTION__);
|
||||
order_lemma_on_ab(lemma, m, rsign, var(ab[k]), var(ab[j]), gt);
|
||||
lemma &= ab;
|
||||
lemma &= m;
|
||||
}
|
||||
}
|
||||
for (unsigned j = 0, k = 1; j < 2; j++, k--) {
|
||||
for (unsigned j = 0, k = 1; j < 2; ++j, k--) {
|
||||
order_lemma_on_ac_explore(m, ab, j == 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ std::ostream& core::print_monic_with_vars(lpvar v, std::ostream& out) const {
|
|||
template <typename T>
|
||||
std::ostream& core::print_product_with_vars(const T& m, std::ostream& out) const {
|
||||
print_product(m, out) << "\n";
|
||||
for (unsigned k = 0; k < m.size(); k++) {
|
||||
for (unsigned k = 0; k < m.size(); ++k) {
|
||||
print_var(m[k], out);
|
||||
}
|
||||
return out;
|
||||
|
|
@ -153,7 +153,7 @@ std::ostream& core::print_ineqs(const lemma& l, std::ostream& out) const {
|
|||
if (l.ineqs().size() == 0) {
|
||||
out << "conflict\n";
|
||||
} else {
|
||||
for (unsigned i = 0; i < l.ineqs().size(); i++) {
|
||||
for (unsigned i = 0; i < l.ineqs().size(); ++i) {
|
||||
auto& in = l.ineqs()[i];
|
||||
print_ineq(in, out);
|
||||
if (i + 1 < l.ineqs().size()) out << " or ";
|
||||
|
|
@ -173,7 +173,7 @@ std::ostream& core::print_factorization(const factorization& f, std::ostream& ou
|
|||
if (f.is_mon()) {
|
||||
out << "is_mon " << pp_mon(*this, f.mon());
|
||||
} else {
|
||||
for (unsigned k = 0; k < f.size(); k++) {
|
||||
for (unsigned k = 0; k < f.size(); ++k) {
|
||||
out << "(" << pp(f[k]) << ")";
|
||||
if (k < f.size() - 1)
|
||||
out << "*";
|
||||
|
|
@ -202,7 +202,7 @@ void core::trace_print_rms(const T& p, std::ostream& out) {
|
|||
void core::print_monic_stats(const monic& m, std::ostream& out) {
|
||||
if (m.size() == 2) return;
|
||||
monic_coeff mc = canonize_monic(m);
|
||||
for (unsigned i = 0; i < mc.vars().size(); i++) {
|
||||
for (unsigned i = 0; i < mc.vars().size(); ++i) {
|
||||
if (abs(val(mc.vars()[i])) == rational(1)) {
|
||||
auto vv = mc.vars();
|
||||
vv.erase(vv.begin() + i);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ private:
|
|||
struct signature_hash {
|
||||
unsigned operator()(const signature& s) const {
|
||||
unsigned hash = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
hash = combine_hash(hash, s.m_values[i]);
|
||||
}
|
||||
return hash;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class permutation_matrix
|
|||
unsigned old_size = m_permutation.size();
|
||||
m_permutation.resize(size);
|
||||
m_rev.resize(size);
|
||||
for (unsigned i = old_size; i < size; i++) {
|
||||
for (unsigned i = old_size; i < size; ++i) {
|
||||
m_permutation[i] = m_rev[i] = i;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ Revision History:
|
|||
#include "math/lp/permutation_matrix.h"
|
||||
namespace lp {
|
||||
template <typename T, typename X> permutation_matrix<T, X>::permutation_matrix(unsigned length): m_permutation(length), m_rev(length) {
|
||||
for (unsigned i = 0; i < length; i++) { // do not change the direction of the loop because of the vectorization bug in clang3.3
|
||||
for (unsigned i = 0; i < length; ++i) { // do not change the direction of the loop because of the vectorization bug in clang3.3
|
||||
m_permutation[i] = m_rev[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename X> permutation_matrix<T, X>::permutation_matrix(unsigned length, vector<unsigned> const & values): m_permutation(length), m_rev(length) {
|
||||
for (unsigned i = 0; i < length; i++) {
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
set_val(i, values[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ template <typename T, typename X> permutation_matrix<T, X>::permutation_matrix(u
|
|||
template <typename T, typename X> void permutation_matrix<T, X>::init(unsigned length) {
|
||||
m_permutation.resize(length);
|
||||
m_rev.resize(length);
|
||||
for (unsigned i = 0; i < length; i++) {
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
m_permutation[i] = m_rev[i] = i;
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ template <typename T, typename X> void permutation_matrix<T, X>::init(unsigned l
|
|||
#ifdef Z3DEBUG
|
||||
template <typename T, typename X> void permutation_matrix<T, X>::print(std::ostream & out) const {
|
||||
out << "[";
|
||||
for (unsigned i = 0; i < size(); i++) {
|
||||
for (unsigned i = 0; i < size(); ++i) {
|
||||
out << m_permutation[i];
|
||||
if (i < size() - 1) {
|
||||
out << ",";
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ public:
|
|||
|
||||
unsigned number_of_non_zeroes() const {
|
||||
unsigned ret = 0;
|
||||
for (unsigned i = 0; i < row_count(); i++)
|
||||
for (unsigned i = 0; i < row_count(); ++i)
|
||||
ret += number_of_non_zeroes_in_row(i);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,17 +33,17 @@ namespace lp {
|
|||
template <typename T, typename X>
|
||||
void static_matrix<T, X>::init_row_columns(unsigned m, unsigned n) {
|
||||
SASSERT(m_rows.size() == 0 && m_columns.size() == 0);
|
||||
for (unsigned i = 0; i < m; i++) {
|
||||
for (unsigned i = 0; i < m; ++i) {
|
||||
m_rows.push_back(row_strip<T>());
|
||||
}
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
m_columns.push_back(column_strip());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T, typename X> void static_matrix<T, X>:: scan_row_strip_to_work_vector(const row_strip<T> & rvals) {
|
||||
for (unsigned j = 0; j < rvals.size(); j++)
|
||||
for (unsigned j = 0; j < rvals.size(); ++j)
|
||||
m_work_vector_of_row_offsets[rvals[j].var()] = j;
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ namespace lp {
|
|||
}
|
||||
}
|
||||
// clean the work vector
|
||||
for (unsigned k = 0; k < prev_size_ii; k++) {
|
||||
for (unsigned k = 0; k < prev_size_ii; ++k) {
|
||||
m_work_vector_of_row_offsets[rowii[k].var()] = -1;
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ namespace lp {
|
|||
}
|
||||
}
|
||||
// clean the work vector
|
||||
for (unsigned k = 0; k < prev_size_k; k++) {
|
||||
for (unsigned k = 0; k < prev_size_k; ++k) {
|
||||
m_work_vector_of_row_offsets[rowk[k].var()] = -1;
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ namespace lp {
|
|||
}
|
||||
}
|
||||
// clean the work vector
|
||||
for (unsigned k = 0; k < prev_size_ii; k++) {
|
||||
for (unsigned k = 0; k < prev_size_ii; ++k) {
|
||||
m_work_vector_of_row_offsets[rowii[k].var()] = -1;
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ namespace lp {
|
|||
}
|
||||
}
|
||||
// clean the work vector
|
||||
for (unsigned k = 0; k < prev_size_ii; k++) {
|
||||
for (unsigned k = 0; k < prev_size_ii; ++k) {
|
||||
m_work_vector_of_row_offsets[rowii[k].var()] = -1;
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ namespace lp {
|
|||
}
|
||||
}
|
||||
// clean the work vector
|
||||
for (unsigned k = 0; k < prev_size_ii; k++) {
|
||||
for (unsigned k = 0; k < prev_size_ii; ++k) {
|
||||
m_work_vector_of_row_offsets[rowii[k].var()] = -1;
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ namespace lp {
|
|||
template <typename T, typename X>
|
||||
std::set<std::pair<unsigned, unsigned>> static_matrix<T, X>::get_domain() {
|
||||
std::set<std::pair<unsigned, unsigned>> ret;
|
||||
for (unsigned i = 0; i < m_rows.size(); i++) {
|
||||
for (unsigned i = 0; i < m_rows.size(); ++i) {
|
||||
for (auto &cell : m_rows[i]) {
|
||||
ret.insert(std::make_pair(i, cell.var()));
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ namespace lp {
|
|||
#ifdef Z3DEBUG
|
||||
template <typename T, typename X> void static_matrix<T, X>::check_consistency() {
|
||||
std::unordered_map<std::pair<unsigned, unsigned>, T> by_rows;
|
||||
for (unsigned i = 0; i < m_rows.size(); i++) {
|
||||
for (unsigned i = 0; i < m_rows.size(); ++i) {
|
||||
for (auto & t : m_rows[i]) {
|
||||
std::pair<unsigned, unsigned> p(i, t.var());
|
||||
SASSERT(by_rows.find(p) == by_rows.end());
|
||||
|
|
@ -338,7 +338,7 @@ namespace lp {
|
|||
}
|
||||
}
|
||||
std::unordered_map<std::pair<unsigned, unsigned>, T> by_cols;
|
||||
for (unsigned i = 0; i < m_columns.size(); i++) {
|
||||
for (unsigned i = 0; i < m_columns.size(); ++i) {
|
||||
for (auto & t : m_columns[i]) {
|
||||
std::pair<unsigned, unsigned> p(t.var(), i);
|
||||
SASSERT(by_cols.find(p) == by_cols.end());
|
||||
|
|
@ -384,7 +384,7 @@ namespace lp {
|
|||
|
||||
template <typename T, typename X> void static_matrix<T, X>::cross_out_row_from_column(unsigned col, unsigned k) {
|
||||
auto & s = m_columns[col];
|
||||
for (unsigned i = 0; i < s.size(); i++) {
|
||||
for (unsigned i = 0; i < s.size(); ++i) {
|
||||
if (s[i].var() == k) {
|
||||
s.erase(s.begin() + i);
|
||||
break;
|
||||
|
|
@ -403,7 +403,7 @@ namespace lp {
|
|||
|
||||
template <typename T, typename X> T static_matrix<T, X>::get_balance() const {
|
||||
T ret = zero_of_type<T>();
|
||||
for (unsigned i = 0; i < row_count(); i++) {
|
||||
for (unsigned i = 0; i < row_count(); ++i) {
|
||||
ret += get_row_balance(i);
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public :
|
|||
void analyze() {
|
||||
// We have the equality sum by j of row[j]*x[j] = m_rs
|
||||
// We try to pin a var by pushing the total of the partial sum down, denoting the variable of this process by _u.
|
||||
for (unsigned i = 0; i < m_index.size(); i++) {
|
||||
for (unsigned i = 0; i < m_index.size(); ++i) {
|
||||
analyze_i(i);
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ public :
|
|||
mpq l;
|
||||
bool strict = false;
|
||||
SASSERT(is_zero(l));
|
||||
for (unsigned k = 0; k < m_index.size(); k++) {
|
||||
for (unsigned k = 0; k < m_index.size(); ++k) {
|
||||
if (k == i)
|
||||
continue;
|
||||
mpq lb;
|
||||
|
|
@ -181,7 +181,7 @@ public :
|
|||
mpq l;
|
||||
SASSERT(is_zero(l));
|
||||
bool strict = false;
|
||||
for (unsigned k = 0; k < m_index.size(); k++) {
|
||||
for (unsigned k = 0; k < m_index.size(); ++k) {
|
||||
if (k == i)
|
||||
continue;
|
||||
mpq lb;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
for (auto c: cs) {
|
||||
m_cs[i++] = c;
|
||||
}
|
||||
for (; i < 4; i++) {
|
||||
for (; i < 4; ++i) {
|
||||
m_cs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
void del_poly(algebraic_cell * c) {
|
||||
for (unsigned i = 0; i < c->m_p_sz; i++)
|
||||
for (unsigned i = 0; i < c->m_p_sz; ++i)
|
||||
qm().del(c->m_p[i]);
|
||||
m_allocator.deallocate(sizeof(mpz)*c->m_p_sz, c->m_p);
|
||||
c->m_p = nullptr;
|
||||
|
|
@ -406,7 +406,7 @@ namespace algebraic_numbers {
|
|||
algebraic_cell * c = new (mem) algebraic_cell();
|
||||
c->m_p_sz = sz;
|
||||
c->m_p = static_cast<mpz*>(m_allocator.allocate(sizeof(mpz)*sz));
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
new (c->m_p + i) mpz();
|
||||
qm().set(c->m_p[i], p[i]);
|
||||
}
|
||||
|
|
@ -450,7 +450,7 @@ namespace algebraic_numbers {
|
|||
SASSERT(c->m_p_sz == 0);
|
||||
c->m_p_sz = sz;
|
||||
c->m_p = static_cast<mpz*>(m_allocator.allocate(sizeof(mpz)*sz));
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
new (c->m_p + i) mpz();
|
||||
qm().set(c->m_p[i], p[i]);
|
||||
}
|
||||
|
|
@ -618,7 +618,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
unsigned num_factors = fs.distinct_factors();
|
||||
for (unsigned i = 0; i < num_factors; i++) {
|
||||
for (unsigned i = 0; i < num_factors; ++i) {
|
||||
upolynomial::numeral_vector const & f = fs[i];
|
||||
// polynomial f contains the non zero roots
|
||||
unsigned d = upm().degree(f);
|
||||
|
|
@ -641,14 +641,14 @@ namespace algebraic_numbers {
|
|||
// collect rational/basic roots
|
||||
unsigned sz = m_isolate_roots.size();
|
||||
TRACE(algebraic, tout << "isolated roots: " << sz << "\n";);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
to_mpq(qm(), m_isolate_roots[i], r);
|
||||
roots.push_back(numeral(mk_basic_cell(r)));
|
||||
}
|
||||
SASSERT(m_isolate_uppers.size() == m_isolate_lowers.size());
|
||||
// collect non-basic roots
|
||||
sz = m_isolate_lowers.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
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.data(), bqm(), lower, upper)) {
|
||||
|
|
@ -689,7 +689,7 @@ namespace algebraic_numbers {
|
|||
isolate_roots(up, roots);
|
||||
unsigned num_roots = roots.size();
|
||||
TRACE(algebraic, tout << "num-roots: " << num_roots << "\n";
|
||||
for (unsigned i = 0; i < num_roots; i++) {
|
||||
for (unsigned i = 0; i < num_roots; ++i) {
|
||||
display_interval(tout, roots[i]);
|
||||
tout << "\n";
|
||||
});
|
||||
|
|
@ -799,7 +799,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
|
||||
bool refine(numeral & a, unsigned k) {
|
||||
for (unsigned i = 0; i < k; i++)
|
||||
for (unsigned i = 0; i < k; ++i)
|
||||
if (!refine(a))
|
||||
return false;
|
||||
return true;
|
||||
|
|
@ -1058,7 +1058,7 @@ namespace algebraic_numbers {
|
|||
bool full_fact = factor(p, fs);
|
||||
unsigned num_fs = fs.distinct_factors();
|
||||
scoped_ptr_vector<typename upolynomial::scoped_upolynomial_sequence> seqs;
|
||||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
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].data(), *seq);
|
||||
|
|
@ -1079,7 +1079,7 @@ namespace algebraic_numbers {
|
|||
unsigned num_rem = 0; // number of remaining sequences
|
||||
unsigned target_i = UINT_MAX; // index of sequence that is isolating
|
||||
int target_lV = 0, target_uV = 0;
|
||||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
for (unsigned i = 0; i < num_fs; ++i) {
|
||||
if (seqs[i] == nullptr)
|
||||
continue; // sequence was discarded because it does not contain the root.
|
||||
TRACE(anum_mk_binary, tout << "sequence " << i << "\n"; upm().display(tout, *(seqs[i])); tout << "\n";);
|
||||
|
|
@ -1139,7 +1139,7 @@ namespace algebraic_numbers {
|
|||
bool full_fact = factor(p, fs);
|
||||
unsigned num_fs = fs.distinct_factors();
|
||||
scoped_ptr_vector<typename upolynomial::scoped_upolynomial_sequence> seqs;
|
||||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
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].data(), *seq);
|
||||
seqs.push_back(seq);
|
||||
|
|
@ -1157,7 +1157,7 @@ namespace algebraic_numbers {
|
|||
unsigned num_rem = 0; // number of remaining sequences
|
||||
unsigned target_i = UINT_MAX; // index of sequence that is isolating
|
||||
int target_lV = 0, target_uV = 0;
|
||||
for (unsigned i = 0; i < num_fs; i++) {
|
||||
for (unsigned i = 0; i < num_fs; ++i) {
|
||||
if (seqs[i] == nullptr)
|
||||
continue; // sequence was discarded because it does not contain the root.
|
||||
int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower());
|
||||
|
|
@ -1334,7 +1334,7 @@ namespace algebraic_numbers {
|
|||
p.push_back(mpz());
|
||||
qm().set(p.back(), a_val.numerator());
|
||||
qm().neg(p.back());
|
||||
for (unsigned i = 0; i < k; i++)
|
||||
for (unsigned i = 0; i < k; ++i)
|
||||
p.push_back(mpz());
|
||||
qm().set(p.back(), a_val.denominator());
|
||||
|
||||
|
|
@ -1841,7 +1841,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
if (target_m > m_min_magnitude) {
|
||||
int num_refinements = target_m - m_min_magnitude;
|
||||
for (int i = 0; i < num_refinements; i++) {
|
||||
for (int i = 0; i < num_refinements; ++i) {
|
||||
if (!refine(a) || !refine(b))
|
||||
return compare(a, b);
|
||||
m_compare_refine++;
|
||||
|
|
@ -2131,7 +2131,7 @@ namespace algebraic_numbers {
|
|||
}
|
||||
// refine intervals if magnitude > m_min_magnitude
|
||||
bool refined = false;
|
||||
for (unsigned i = 0; i < xs.size(); i++) {
|
||||
for (unsigned i = 0; i < xs.size(); ++i) {
|
||||
polynomial::var x = xs[i];
|
||||
SASSERT(x2v.contains(x));
|
||||
anum const & v = x2v(x);
|
||||
|
|
@ -2220,7 +2220,7 @@ namespace algebraic_numbers {
|
|||
// compute the resultants
|
||||
polynomial_ref q_i(pm());
|
||||
std::stable_sort(xs.begin(), xs.end(), var_degree_lt(*this, x2v));
|
||||
for (unsigned i = 0; i < xs.size(); i++) {
|
||||
for (unsigned i = 0; i < xs.size(); ++i) {
|
||||
checkpoint();
|
||||
polynomial::var x_i = xs[i];
|
||||
SASSERT(x2v.contains(x_i));
|
||||
|
|
@ -2249,7 +2249,7 @@ namespace algebraic_numbers {
|
|||
// The invervals (for the values of the variables in xs) are going to get too small.
|
||||
// So, we save them before refining...
|
||||
scoped_ptr_vector<save_intervals> saved_intervals;
|
||||
for (unsigned i = 0; i < xs.size(); i++) {
|
||||
for (unsigned i = 0; i < xs.size(); ++i) {
|
||||
polynomial::var x_i = xs[i];
|
||||
SASSERT(x2v.contains(x_i));
|
||||
anum const & v_i = x2v(x_i);
|
||||
|
|
@ -2334,13 +2334,13 @@ namespace algebraic_numbers {
|
|||
// Remove from roots any solution r such that p does not evaluate to 0 at x2v extended with x->r.
|
||||
void filter_roots(polynomial_ref const & p, polynomial::var2anum const & x2v, polynomial::var x, numeral_vector & roots) {
|
||||
TRACE(isolate_roots, tout << "before filtering roots, x: x" << x << "\n";
|
||||
for (unsigned i = 0; i < roots.size(); i++) {
|
||||
for (unsigned i = 0; i < roots.size(); ++i) {
|
||||
display_root(tout, roots[i]); tout << "\n";
|
||||
});
|
||||
|
||||
unsigned sz = roots.size();
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
checkpoint();
|
||||
ext_var2num ext_x2v(m_wrapper, x2v, x, roots[i]);
|
||||
TRACE(isolate_roots, tout << "filter_roots i: " << i << ", ext_x2v: x" << x << " -> "; display_root(tout, roots[i]); tout << "\n";);
|
||||
|
|
@ -2352,12 +2352,12 @@ namespace algebraic_numbers {
|
|||
set(roots[j], roots[i]);
|
||||
j++;
|
||||
}
|
||||
for (unsigned i = j; i < sz; i++)
|
||||
for (unsigned i = j; i < sz; ++i)
|
||||
del(roots[i]);
|
||||
roots.shrink(j);
|
||||
|
||||
TRACE(isolate_roots, tout << "after filtering roots:\n";
|
||||
for (unsigned i = 0; i < roots.size(); i++) {
|
||||
for (unsigned i = 0; i < roots.size(); ++i) {
|
||||
display_root(tout, roots[i]); tout << "\n";
|
||||
});
|
||||
}
|
||||
|
|
@ -2366,7 +2366,7 @@ namespace algebraic_numbers {
|
|||
static polynomial::var get_max_var(polynomial::var_vector const & xs) {
|
||||
SASSERT(!xs.empty());
|
||||
polynomial::var x = xs[0];
|
||||
for (unsigned i = 1; i < xs.size(); i++) {
|
||||
for (unsigned i = 1; i < xs.size(); ++i) {
|
||||
if (xs[i] > x)
|
||||
x = xs[i];
|
||||
}
|
||||
|
|
@ -2445,7 +2445,7 @@ namespace algebraic_numbers {
|
|||
polynomial_ref q(ext_pm);
|
||||
q = p_prime;
|
||||
polynomial_ref p_y(ext_pm);
|
||||
for (unsigned i = 0; i + 1 < xs.size(); i++) {
|
||||
for (unsigned i = 0; i + 1 < xs.size(); ++i) {
|
||||
checkpoint();
|
||||
polynomial::var y = xs[i];
|
||||
SASSERT(x2v.contains(y));
|
||||
|
|
@ -2678,7 +2678,7 @@ namespace algebraic_numbers {
|
|||
TRACE(isolate_roots_bug, tout << "p: " << p << "\n";
|
||||
polynomial::var_vector xs;
|
||||
p.m().vars(p, xs);
|
||||
for (unsigned i = 0; i < xs.size(); i++) {
|
||||
for (unsigned i = 0; i < xs.size(); ++i) {
|
||||
if (x2v.contains(xs[i])) {
|
||||
tout << "x" << xs[i] << " -> ";
|
||||
display_root(tout, x2v(xs[i]));
|
||||
|
|
@ -2687,10 +2687,10 @@ namespace algebraic_numbers {
|
|||
tout << "\n";
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < roots.size(); i++) {
|
||||
for (unsigned i = 0; i < roots.size(); ++i) {
|
||||
tout << "root[i]: "; display_root(tout, roots[i]); tout << "\n";
|
||||
});
|
||||
for (unsigned i = 0; i < num_roots; i++)
|
||||
for (unsigned i = 0; i < num_roots; ++i)
|
||||
refine_until_prec(roots[i], DEFAULT_PRECISION);
|
||||
|
||||
scoped_anum w(m_wrapper);
|
||||
|
|
@ -2703,7 +2703,7 @@ namespace algebraic_numbers {
|
|||
signs.push_back(s);
|
||||
}
|
||||
|
||||
for (unsigned i = 1; i < num_roots; i++) {
|
||||
for (unsigned i = 1; i < num_roots; ++i) {
|
||||
numeral & prev = roots[i-1];
|
||||
numeral & curr = roots[i];
|
||||
select(prev, curr, w);
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ public:
|
|||
void flush() {
|
||||
SASSERT(b.size() == A.size());
|
||||
auto sz = A.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
svector<numeral> & as = A[i];
|
||||
m.del(b[i]);
|
||||
SASSERT(as.size() == n);
|
||||
for (unsigned j = 0; j < n; j++)
|
||||
for (unsigned j = 0; j < n; ++j)
|
||||
m.del(as[j]);
|
||||
}
|
||||
A.reset();
|
||||
|
|
@ -51,10 +51,10 @@ public:
|
|||
if (n != _n) {
|
||||
flush();
|
||||
n = _n;
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
A.push_back(svector<numeral>());
|
||||
svector<numeral> & as = A.back();
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
as.push_back(numeral());
|
||||
}
|
||||
b.push_back(numeral());
|
||||
|
|
@ -63,9 +63,9 @@ public:
|
|||
}
|
||||
|
||||
void reset() {
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
svector<numeral> & A_i = A[i];
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
m.set(A_i[j], 0);
|
||||
}
|
||||
m.set(b[i], 0);
|
||||
|
|
@ -77,7 +77,7 @@ public:
|
|||
SASSERT(i < n);
|
||||
m.set(b[i], _b);
|
||||
svector<numeral> & A_i = A[i];
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
m.set(A_i[j], _as[j]);
|
||||
}
|
||||
}
|
||||
|
|
@ -85,11 +85,11 @@ public:
|
|||
// Return true if the system of equations has a solution.
|
||||
// Return false if the matrix is singular
|
||||
bool solve(numeral * xs) {
|
||||
for (unsigned k = 0; k < n; k++) {
|
||||
for (unsigned k = 0; k < n; ++k) {
|
||||
TRACE(linear_eq_solver, tout << "iteration " << k << "\n"; display(tout););
|
||||
// find pivot
|
||||
unsigned i = k;
|
||||
for (; i < n; i++) {
|
||||
for (; i < n; ++i) {
|
||||
if (!m.is_zero(A[i][k]))
|
||||
break;
|
||||
}
|
||||
|
|
@ -100,17 +100,17 @@ public:
|
|||
numeral & A_k_k = A_k[k];
|
||||
SASSERT(!m.is_zero(A_k_k));
|
||||
// normalize row
|
||||
for (unsigned i = k+1; i < n; i++)
|
||||
for (unsigned i = k+1; i < n; ++i)
|
||||
m.div(A_k[i], A_k_k, A_k[i]);
|
||||
m.div(b[k], A_k_k, b[k]);
|
||||
m.set(A_k_k, 1);
|
||||
// check if first k-1 positions are zero
|
||||
DEBUG_CODE({ for (unsigned i = 0; i < k; i++) { SASSERT(m.is_zero(A_k[i])); } });
|
||||
DEBUG_CODE({ for (unsigned i = 0; i < k; ++i) { SASSERT(m.is_zero(A_k[i])); } });
|
||||
// for all rows below pivot
|
||||
for (unsigned i = k+1; i < n; i++) {
|
||||
for (unsigned i = k+1; i < n; ++i) {
|
||||
svector<numeral> & A_i = A[i];
|
||||
numeral & A_i_k = A_i[k];
|
||||
for (unsigned j = k+1; j < n; j++) {
|
||||
for (unsigned j = k+1; j < n; ++j) {
|
||||
m.submul(A_i[j], A_i_k, A_k[j], A_i[j]);
|
||||
}
|
||||
m.submul(b[i], A_i_k, b[k], b[i]);
|
||||
|
|
@ -136,9 +136,9 @@ public:
|
|||
}
|
||||
|
||||
void display(std::ostream & out) const {
|
||||
for (unsigned i = 0; i < A.size(); i++) {
|
||||
for (unsigned i = 0; i < A.size(); ++i) {
|
||||
SASSERT(A[i].size() == n);
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
m.display(out, A[i][j]);
|
||||
out << " ";
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -151,7 +151,7 @@ namespace polynomial {
|
|||
entry->~psc_chain_entry();
|
||||
m_allocator.deallocate(sizeof(psc_chain_entry), entry);
|
||||
S.reset();
|
||||
for (unsigned i = 0; i < old_entry->m_result_sz; i++) {
|
||||
for (unsigned i = 0; i < old_entry->m_result_sz; ++i) {
|
||||
S.push_back(old_entry->m_result[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ namespace polynomial {
|
|||
unsigned sz = S.size();
|
||||
entry->m_result_sz = sz;
|
||||
entry->m_result = static_cast<polynomial**>(m_allocator.allocate(sizeof(polynomial*)*sz));
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
polynomial * h = mk_unique(S.get(i));
|
||||
S.set(i, h);
|
||||
entry->m_result[i] = h;
|
||||
|
|
@ -178,7 +178,7 @@ namespace polynomial {
|
|||
entry->~factor_entry();
|
||||
m_allocator.deallocate(sizeof(factor_entry), entry);
|
||||
distinct_factors.reset();
|
||||
for (unsigned i = 0; i < old_entry->m_result_sz; i++) {
|
||||
for (unsigned i = 0; i < old_entry->m_result_sz; ++i) {
|
||||
distinct_factors.push_back(old_entry->m_result[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ namespace polynomial {
|
|||
unsigned sz = fs.distinct_factors();
|
||||
entry->m_result_sz = sz;
|
||||
entry->m_result = static_cast<polynomial**>(m_allocator.allocate(sizeof(polynomial*)*sz));
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
polynomial * h = mk_unique(fs[i]);
|
||||
distinct_factors.push_back(h);
|
||||
entry->m_result[i] = h;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace polynomial {
|
|||
ValManager & m() const override { return m_vs.m(); }
|
||||
bool contains(var x) const override { return std::find(m_xs.begin(), m_xs.end(), x) != m_xs.end(); }
|
||||
typename ValManager::numeral const & operator()(var x) const override {
|
||||
for (unsigned i = 0; i < m_xs.size(); i++)
|
||||
for (unsigned i = 0; i < m_xs.size(); ++i)
|
||||
if (m_xs[i] == x)
|
||||
return m_vs[i];
|
||||
UNREACHABLE();
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ namespace rpolynomial {
|
|||
p = todo.back();
|
||||
todo.pop_back();
|
||||
unsigned sz = p->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
poly_or_num * pn = p->arg(i);
|
||||
if (pn == nullptr)
|
||||
continue;
|
||||
|
|
@ -152,7 +152,7 @@ namespace rpolynomial {
|
|||
if (is_const(p))
|
||||
return false;
|
||||
unsigned sz = p->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
poly_or_num * pn = p->arg(i);
|
||||
if (pn == nullptr)
|
||||
continue;
|
||||
|
|
@ -168,7 +168,7 @@ namespace rpolynomial {
|
|||
unsigned sz = p->size();
|
||||
SASSERT(sz > 0);
|
||||
SASSERT(p->arg(sz - 1) != 0);
|
||||
for (unsigned i = 0; i < sz - 1; i++) {
|
||||
for (unsigned i = 0; i < sz - 1; ++i) {
|
||||
if (p->arg(i) != nullptr)
|
||||
return false;
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ namespace rpolynomial {
|
|||
if (p1->max_var() != p2->max_var())
|
||||
return false;
|
||||
unsigned sz = p1->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
poly_or_num * pn1 = p1->arg(i);
|
||||
poly_or_num * pn2 = p2->arg(i);
|
||||
if (pn1 == nullptr && pn2 == nullptr)
|
||||
|
|
@ -215,7 +215,7 @@ namespace rpolynomial {
|
|||
}
|
||||
|
||||
void inc_ref_args(unsigned sz, poly_or_num * const * args) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
poly_or_num * pn = args[i];
|
||||
if (pn == nullptr || is_num(pn))
|
||||
continue;
|
||||
|
|
@ -224,7 +224,7 @@ namespace rpolynomial {
|
|||
}
|
||||
|
||||
void dec_ref_args(unsigned sz, poly_or_num * const * args) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
poly_or_num * pn = args[i];
|
||||
if (pn == nullptr || is_num(pn))
|
||||
continue;
|
||||
|
|
@ -251,7 +251,7 @@ namespace rpolynomial {
|
|||
new_pol->m_ref_count = 0;
|
||||
new_pol->m_var = max_var;
|
||||
new_pol->m_size = sz;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
poly_or_num * pn = args[i];
|
||||
if (is_poly(pn)) {
|
||||
inc_ref(to_poly(pn));
|
||||
|
|
@ -313,7 +313,7 @@ namespace rpolynomial {
|
|||
return mk_const(one);
|
||||
}
|
||||
ptr_buffer<poly_or_num> new_args;
|
||||
for (unsigned i = 0; i < k; i++)
|
||||
for (unsigned i = 0; i < k; ++i)
|
||||
new_args.push_back(0);
|
||||
numeral * new_arg = mk_numeral();
|
||||
m_manager.set(*new_arg, 1);
|
||||
|
|
@ -358,7 +358,7 @@ namespace rpolynomial {
|
|||
unsigned sz = _p->size();
|
||||
SASSERT(sz > 1);
|
||||
ptr_buffer<poly_or_num> new_args;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
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.data(), _p->max_var());
|
||||
|
|
@ -399,7 +399,7 @@ namespace rpolynomial {
|
|||
SASSERT(sz > 1);
|
||||
ptr_buffer<poly_or_num> new_args;
|
||||
new_args.push_back(add_core(c, _p->arg(0)));
|
||||
for (unsigned i = 1; i < sz; i++)
|
||||
for (unsigned i = 1; i < sz; ++i)
|
||||
new_args.push_back(_p->arg(1));
|
||||
return mk_poly_core(new_args.size(), new_args.data(), _p->max_var());
|
||||
}
|
||||
|
|
@ -434,7 +434,7 @@ namespace rpolynomial {
|
|||
polynomial * new_arg = add(p1, to_poly(pn0));
|
||||
new_args.push_back(to_poly_or_num(new_arg));
|
||||
}
|
||||
for (unsigned i = 1; i < sz; i++)
|
||||
for (unsigned i = 1; i < sz; ++i)
|
||||
new_args.push_back(p2->arg(i));
|
||||
return mk_poly(sz, new_args.c_ptr(), p2->max_var());
|
||||
}
|
||||
|
|
@ -463,7 +463,7 @@ namespace rpolynomial {
|
|||
unsigned sz2 = p2->size();
|
||||
unsigned msz = std::min(sz1, sz2);
|
||||
ptr_buffer<poly_or_num> new_args;
|
||||
for (unsigned i = 0; i < msz; i++) {
|
||||
for (unsigned i = 0; i < msz; ++i) {
|
||||
poly_or_num * pn1 = p1->arg(i);
|
||||
poly_or_num * pn2 = p2->arg(i);
|
||||
if (pn1 == 0) {
|
||||
|
|
@ -506,10 +506,10 @@ namespace rpolynomial {
|
|||
}
|
||||
}
|
||||
SASSERT(new_args.size() == sz1 || new_args.size() == sz2);
|
||||
for (unsigned i = msz; i < sz1; i++) {
|
||||
for (unsigned i = msz; i < sz1; ++i) {
|
||||
new_args.push_back(p1->arg(i));
|
||||
}
|
||||
for (unsigned i = msz; i < sz2; i++) {
|
||||
for (unsigned i = msz; i < sz2; ++i) {
|
||||
new_args.push_back(p2->arg(i));
|
||||
}
|
||||
SASSERT(new_args.size() == std::max(sz1, sz2));
|
||||
|
|
@ -612,11 +612,11 @@ namespace rpolynomial {
|
|||
mul_buffer.resize(sz);
|
||||
unsigned sz1 = p1->size();
|
||||
unsigned sz2 = p2->size();
|
||||
for (unsigned i1 = 0; i1 < sz1; i1++) {
|
||||
for (unsigned i1 = 0; i1 < sz1; ++i1) {
|
||||
poly_or_num * pn1 = p1->arg(i1);
|
||||
if (pn1 == 0)
|
||||
continue;
|
||||
for (unsigned i2 = 0; i2 < sz2; i2++) {
|
||||
for (unsigned i2 = 0; i2 < sz2; ++i2) {
|
||||
poly_or_num * pn2 = p2->arg(i2);
|
||||
if (pn2 == 0)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ void sexpr2upolynomial(upolynomial::manager & m, sexpr const * s, upolynomial::n
|
|||
throw sexpr2upolynomial_exception("invalid univariate polynomial, '+' operator expects at least one argument", s);
|
||||
sexpr2upolynomial(m, s->get_child(1), p, depth+1);
|
||||
upolynomial::scoped_numeral_vector arg(m);
|
||||
for (unsigned i = 2; i < num; i++) {
|
||||
for (unsigned i = 2; i < num; ++i) {
|
||||
m.reset(arg);
|
||||
sexpr2upolynomial(m, s->get_child(i), arg, depth+1);
|
||||
m.add(arg.size(), arg.data(), p.size(), p.data(), p);
|
||||
|
|
@ -57,7 +57,7 @@ void sexpr2upolynomial(upolynomial::manager & m, sexpr const * s, upolynomial::n
|
|||
return;
|
||||
}
|
||||
upolynomial::scoped_numeral_vector arg(m);
|
||||
for (unsigned i = 2; i < num; i++) {
|
||||
for (unsigned i = 2; i < num; ++i) {
|
||||
m.reset(arg);
|
||||
sexpr2upolynomial(m, s->get_child(i), arg, depth+1);
|
||||
m.sub(p.size(), p.data(), arg.size(), arg.data(), p);
|
||||
|
|
@ -68,7 +68,7 @@ void sexpr2upolynomial(upolynomial::manager & m, sexpr const * s, upolynomial::n
|
|||
throw sexpr2upolynomial_exception("invalid univariate polynomial, '*' operator expects at least one argument", s);
|
||||
sexpr2upolynomial(m, s->get_child(1), p, depth+1);
|
||||
upolynomial::scoped_numeral_vector arg(m);
|
||||
for (unsigned i = 2; i < num; i++) {
|
||||
for (unsigned i = 2; i < num; ++i) {
|
||||
m.reset(arg);
|
||||
sexpr2upolynomial(m, s->get_child(i), arg, depth+1);
|
||||
m.mul(arg.size(), arg.data(), p.size(), p.data(), p);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ namespace upolynomial {
|
|||
reset(m_gcd_tmp1);
|
||||
reset(m_gcd_tmp2);
|
||||
reset(m_CRA_tmp);
|
||||
for (unsigned i = 0; i < UPOLYNOMIAL_MGCD_TMPS; i++) reset(m_mgcd_tmp[i]);
|
||||
for (unsigned i = 0; i < UPOLYNOMIAL_MGCD_TMPS; ++i) reset(m_mgcd_tmp[i]);
|
||||
reset(m_sqf_tmp1);
|
||||
reset(m_sqf_tmp2);
|
||||
reset(m_pw_tmp);
|
||||
|
|
@ -174,7 +174,7 @@ namespace upolynomial {
|
|||
unsigned old_sz = buffer.size();
|
||||
SASSERT(old_sz >= sz);
|
||||
// delete old entries
|
||||
for (unsigned i = sz; i < old_sz; i++) {
|
||||
for (unsigned i = sz; i < old_sz; ++i) {
|
||||
m().del(buffer[i]);
|
||||
}
|
||||
buffer.shrink(sz);
|
||||
|
|
@ -193,7 +193,7 @@ namespace upolynomial {
|
|||
return;
|
||||
}
|
||||
buffer.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m().set(buffer[i], p[i]);
|
||||
}
|
||||
set_size(sz, buffer);
|
||||
|
|
@ -201,7 +201,7 @@ namespace upolynomial {
|
|||
|
||||
void core_manager::set(unsigned sz, rational const * p, numeral_vector & buffer) {
|
||||
buffer.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
SASSERT(p[i].is_int());
|
||||
m().set(buffer[i], p[i].to_mpq().numerator());
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ namespace upolynomial {
|
|||
}
|
||||
else {
|
||||
pp.reserve(f_sz);
|
||||
for (unsigned i = 0; i < f_sz; i++) {
|
||||
for (unsigned i = 0; i < f_sz; ++i) {
|
||||
if (!m().is_zero(f[i])) {
|
||||
m().div(f[i], cont, pp[i]);
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@ namespace upolynomial {
|
|||
|
||||
// Negate coefficients of p.
|
||||
void core_manager::neg(unsigned sz, numeral * p) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m().neg(p[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ namespace upolynomial {
|
|||
void core_manager::neg_core(unsigned sz, numeral const * p, numeral_vector & buffer) {
|
||||
SASSERT(!is_alias(p, buffer));
|
||||
buffer.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m().set(buffer[i], p[i]);
|
||||
m().neg(buffer[i]);
|
||||
}
|
||||
|
|
@ -260,13 +260,13 @@ namespace upolynomial {
|
|||
unsigned max_sz = std::max(sz1, sz2);
|
||||
unsigned i = 0;
|
||||
buffer.reserve(max_sz);
|
||||
for (; i < min_sz; i++) {
|
||||
for (; i < min_sz; ++i) {
|
||||
m().add(p1[i], p2[i], buffer[i]);
|
||||
}
|
||||
for (; i < sz1; i++) {
|
||||
for (; i < sz1; ++i) {
|
||||
m().set(buffer[i], p1[i]);
|
||||
}
|
||||
for (; i < sz2; i++) {
|
||||
for (; i < sz2; ++i) {
|
||||
m().set(buffer[i], p2[i]);
|
||||
}
|
||||
set_size(max_sz, buffer);
|
||||
|
|
@ -285,13 +285,13 @@ namespace upolynomial {
|
|||
unsigned max_sz = std::max(sz1, sz2);
|
||||
unsigned i = 0;
|
||||
buffer.reserve(max_sz);
|
||||
for (; i < min_sz; i++) {
|
||||
for (; i < min_sz; ++i) {
|
||||
m().sub(p1[i], p2[i], buffer[i]);
|
||||
}
|
||||
for (; i < sz1; i++) {
|
||||
for (; i < sz1; ++i) {
|
||||
m().set(buffer[i], p1[i]);
|
||||
}
|
||||
for (; i < sz2; i++) {
|
||||
for (; i < sz2; ++i) {
|
||||
m().set(buffer[i], p2[i]);
|
||||
m().neg(buffer[i]);
|
||||
}
|
||||
|
|
@ -317,19 +317,19 @@ namespace upolynomial {
|
|||
else {
|
||||
unsigned new_sz = sz1 + sz2 - 1;
|
||||
buffer.reserve(new_sz);
|
||||
for (unsigned i = 0; i < new_sz; i++) {
|
||||
for (unsigned i = 0; i < new_sz; ++i) {
|
||||
m().reset(buffer[i]);
|
||||
}
|
||||
if (sz1 < sz2) {
|
||||
std::swap(sz1, sz2);
|
||||
std::swap(p1, p2);
|
||||
}
|
||||
for (unsigned i = 0; i < sz1; i++) {
|
||||
for (unsigned i = 0; i < sz1; ++i) {
|
||||
checkpoint();
|
||||
numeral const & a_i = p1[i];
|
||||
if (m().is_zero(a_i))
|
||||
continue;
|
||||
for (unsigned j = 0; j < sz2; j++) {
|
||||
for (unsigned j = 0; j < sz2; ++j) {
|
||||
numeral const & b_j = p2[j];
|
||||
if (m().is_zero(b_j))
|
||||
continue;
|
||||
|
|
@ -352,7 +352,7 @@ namespace upolynomial {
|
|||
return;
|
||||
}
|
||||
buffer.reserve(sz - 1);
|
||||
for (unsigned i = 1; i < sz; i++) {
|
||||
for (unsigned i = 1; i < sz; ++i) {
|
||||
numeral d;
|
||||
m().set(d, i);
|
||||
m().mul(p[i], d, buffer[i-1]);
|
||||
|
|
@ -375,7 +375,7 @@ namespace upolynomial {
|
|||
m().gcd(sz, p, g);
|
||||
if (m().is_one(g))
|
||||
return;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
#ifdef Z3DEBUG
|
||||
scoped_numeral old_p_i(m());
|
||||
old_p_i = p[i];
|
||||
|
|
@ -402,7 +402,7 @@ namespace upolynomial {
|
|||
SASSERT(!m().is_zero(b));
|
||||
if (m().is_one(b))
|
||||
return;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
CTRACE(upolynomial, !m().divides(b, p[i]), tout << "b: " << m().to_string(b) << ", p[i]: " << m().to_string(p[i]) << "\n";);
|
||||
SASSERT(m().divides(b, p[i]));
|
||||
m().div(p[i], b, p[i]);
|
||||
|
|
@ -413,7 +413,7 @@ namespace upolynomial {
|
|||
SASSERT(!m().is_zero(b));
|
||||
if (m().is_one(b))
|
||||
return;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m().mul(p[i], b, p[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -468,21 +468,21 @@ namespace upolynomial {
|
|||
numeral & ratio = a_m;
|
||||
m().div(r[sz1 - 1], b_n, ratio);
|
||||
m().add(q[m_n], ratio, q[m_n]);
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
m().submul(r[i + m_n], ratio, p2[i], r[i + m_n]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
d++;
|
||||
m().set(a_m, r[sz1 - 1]);
|
||||
for (unsigned i = 0; i < sz1 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz1 - 1; ++i) {
|
||||
m().mul(r[i], b_n, r[i]);
|
||||
}
|
||||
for (unsigned i = 0; i < qsz; i++) {
|
||||
for (unsigned i = 0; i < qsz; ++i) {
|
||||
m().mul(q[i], b_n, q[i]);
|
||||
}
|
||||
m().add(q[m_n], a_m, q[m_n]);
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
m().submul(r[i + m_n], a_m, p2[i], r[i + m_n]);
|
||||
}
|
||||
}
|
||||
|
|
@ -537,7 +537,7 @@ namespace upolynomial {
|
|||
if (field()) {
|
||||
numeral & ratio = a_m;
|
||||
m().div(buffer[sz1 - 1], b_n, ratio);
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
m().submul(buffer[i + m_n], ratio, p2[i], buffer[i + m_n]);
|
||||
}
|
||||
}
|
||||
|
|
@ -548,12 +548,12 @@ namespace upolynomial {
|
|||
m().set(a_m, buffer[sz1 - 1]);
|
||||
TRACE(rem_bug, tout << "a_m: " << m().to_string(a_m) << ", b_n: " << m().to_string(b_n) << "\n";);
|
||||
// don't need to update position sz1 - 1, since it will become 0
|
||||
for (unsigned i = 0; i < sz1 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz1 - 1; ++i) {
|
||||
m().mul(buffer[i], b_n, buffer[i]);
|
||||
}
|
||||
// buffer: a_m * x^m + b_n * a_{m-1} * x^{m-1} + ... + b_n * a_0
|
||||
// don't need to process i = sz2 - 1, because buffer[sz1 - 1] will become 0.
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
m().submul(buffer[i + m_n], a_m, p2[i], buffer[i + m_n]);
|
||||
}
|
||||
}
|
||||
|
|
@ -591,7 +591,7 @@ namespace upolynomial {
|
|||
return false;
|
||||
unsigned delta = sz1 - sz2;
|
||||
m().div(_p1[sz1-1], p2[sz2-1], b);
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
if (!m().is_zero(p2[i]))
|
||||
m().submul(_p1[i+delta], b, p2[i], _p1[i+delta]);
|
||||
}
|
||||
|
|
@ -637,7 +637,7 @@ namespace upolynomial {
|
|||
unsigned delta = sz1 - sz2;
|
||||
numeral & a_r = _r[delta];
|
||||
m().div(_p1[sz1-1], p2[sz2-1], a_r);
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
if (!m().is_zero(p2[i]))
|
||||
m().submul(_p1[i+delta], a_r, p2[i], _p1[i+delta]);
|
||||
}
|
||||
|
|
@ -653,7 +653,7 @@ namespace upolynomial {
|
|||
if (sz == 0)
|
||||
return;
|
||||
if (m().is_neg(buffer[sz - 1])) {
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
m().neg(buffer[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -705,13 +705,13 @@ namespace upolynomial {
|
|||
unsigned sz1 = C1.size();
|
||||
unsigned sz2 = C2.size();
|
||||
unsigned sz = std::min(sz1, sz2);
|
||||
for (; i < sz; i++) {
|
||||
for (; i < sz; ++i) {
|
||||
ADD(C1[i], C2[i]);
|
||||
}
|
||||
for (; i < sz1; i++) {
|
||||
for (; i < sz1; ++i) {
|
||||
ADD(C1[i], zero);
|
||||
}
|
||||
for (; i < sz2; i++) {
|
||||
for (; i < sz2; ++i) {
|
||||
ADD(zero, C2[i]);
|
||||
}
|
||||
m().set(b2, new_bound);
|
||||
|
|
@ -745,7 +745,7 @@ namespace upolynomial {
|
|||
numeral_vector & q = m_mgcd_tmp[4];
|
||||
numeral_vector & C = m_mgcd_tmp[5];
|
||||
|
||||
for (unsigned i = 0; i < NUM_BIG_PRIMES; i++) {
|
||||
for (unsigned i = 0; i < NUM_BIG_PRIMES; ++i) {
|
||||
m().set(p, polynomial::g_big_primes[i]);
|
||||
TRACE(mgcd, tout << "trying prime: " << p << "\n";);
|
||||
{
|
||||
|
|
@ -1005,7 +1005,7 @@ namespace upolynomial {
|
|||
|
||||
numeral_vector & result = m_pw_tmp;
|
||||
set(sz, p, result);
|
||||
for (unsigned i = 1; i < k; i++)
|
||||
for (unsigned i = 1; i < k; ++i)
|
||||
mul(m_pw_tmp.size(), m_pw_tmp.data(), sz, p, m_pw_tmp);
|
||||
r.swap(result);
|
||||
#if 0
|
||||
|
|
@ -1205,7 +1205,7 @@ namespace upolynomial {
|
|||
|
||||
unsigned non_zero_idx = UINT_MAX;
|
||||
unsigned num_non_zeros = 0;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (cm.m().is_zero(p[i]))
|
||||
continue;
|
||||
non_zero_idx = i;
|
||||
|
|
@ -1245,7 +1245,7 @@ namespace upolynomial {
|
|||
bool core_manager::eq(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2) {
|
||||
if (sz1 != sz2)
|
||||
return false;
|
||||
for (unsigned i = 0; i < sz1; i++) {
|
||||
for (unsigned i = 0; i < sz1; ++i) {
|
||||
if (!m().eq(p1[i], p2[i]))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1255,7 +1255,7 @@ namespace upolynomial {
|
|||
void upolynomial_sequence::push(unsigned sz, numeral * p) {
|
||||
m_begins.push_back(m_seq_coeffs.size());
|
||||
m_szs.push_back(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m_seq_coeffs.push_back(numeral());
|
||||
swap(m_seq_coeffs.back(), p[i]);
|
||||
}
|
||||
|
|
@ -1264,7 +1264,7 @@ namespace upolynomial {
|
|||
void upolynomial_sequence::push(numeral_manager & m, unsigned sz, numeral const * p) {
|
||||
m_begins.push_back(m_seq_coeffs.size());
|
||||
m_szs.push_back(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m_seq_coeffs.push_back(numeral());
|
||||
m.set(m_seq_coeffs.back(), p[i]);
|
||||
}
|
||||
|
|
@ -1310,7 +1310,7 @@ namespace upolynomial {
|
|||
}
|
||||
unsigned new_sz = sz - i;
|
||||
buffer.reserve(new_sz);
|
||||
for (unsigned j = 0; j < new_sz; j++) {
|
||||
for (unsigned j = 0; j < new_sz; ++j) {
|
||||
m().set(buffer[j], p[j + i]);
|
||||
}
|
||||
set_size(new_sz, buffer);
|
||||
|
|
@ -1363,7 +1363,7 @@ namespace upolynomial {
|
|||
unsigned r = 0;
|
||||
auto prev_sign = sign_zero;
|
||||
unsigned i = 0;
|
||||
for (; i < sz; i++) {
|
||||
for (; i < sz; ++i) {
|
||||
auto sign = sign_of(p[i]);
|
||||
if (sign == sign_zero)
|
||||
continue;
|
||||
|
|
@ -1390,7 +1390,7 @@ namespace upolynomial {
|
|||
// slow version
|
||||
unsigned n = Q.size() - 1;
|
||||
unsigned i;
|
||||
for (unsigned i = 1; i <= n; i++) {
|
||||
for (unsigned i = 1; i <= n; ++i) {
|
||||
for (unsigned k = i; k >= 1; k--) {
|
||||
m().add(Q[k], Q[k-1], Q[k]);
|
||||
}
|
||||
|
|
@ -1404,10 +1404,10 @@ namespace upolynomial {
|
|||
// a0 2a0+a1 3a0+2a1+a2
|
||||
// a0 3a0+a1
|
||||
// a0
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
checkpoint();
|
||||
unsigned k;
|
||||
for (k = 1; k < sz - i; k++) {
|
||||
for (k = 1; k < sz - i; ++k) {
|
||||
m().add(Q[k], Q[k-1], Q[k]);
|
||||
}
|
||||
auto sign = sign_of(Q[k-1]);
|
||||
|
|
@ -1480,9 +1480,9 @@ namespace upolynomial {
|
|||
if (sz <= 1)
|
||||
return;
|
||||
unsigned n = sz - 1;
|
||||
for (unsigned i = 1; i <= n; i++) {
|
||||
for (unsigned i = 1; i <= n; ++i) {
|
||||
checkpoint();
|
||||
for (unsigned k = n-i; k <= n-1; k++)
|
||||
for (unsigned k = n-i; k <= n-1; ++k)
|
||||
m().add(p[k], p[k+1], p[k]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1493,9 +1493,9 @@ namespace upolynomial {
|
|||
return;
|
||||
scoped_numeral aux(m());
|
||||
unsigned n = sz - 1;
|
||||
for (unsigned i = 1; i <= n; i++) {
|
||||
for (unsigned i = 1; i <= n; ++i) {
|
||||
checkpoint();
|
||||
for (unsigned k = n-i; k <= n-1; k++) {
|
||||
for (unsigned k = n-i; k <= n-1; ++k) {
|
||||
m().mul2k(p[k+1], k, aux);
|
||||
m().add(p[k], aux, p[k]);
|
||||
}
|
||||
|
|
@ -1507,9 +1507,9 @@ namespace upolynomial {
|
|||
if (sz <= 1)
|
||||
return;
|
||||
unsigned n = sz - 1;
|
||||
for (unsigned i = 1; i <= n; i++) {
|
||||
for (unsigned i = 1; i <= n; ++i) {
|
||||
checkpoint();
|
||||
for (unsigned k = n-i; k <= n-1; k++)
|
||||
for (unsigned k = n-i; k <= n-1; ++k)
|
||||
m().addmul(p[k], c, p[k+1], p[k]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1564,10 +1564,10 @@ namespace upolynomial {
|
|||
// Step 2
|
||||
numeral const & c = b.numerator();
|
||||
unsigned n = sz - 1;
|
||||
for (unsigned i = 1; i <= n; i++) {
|
||||
for (unsigned i = 1; i <= n; ++i) {
|
||||
checkpoint();
|
||||
m().addmul(p[n - i], c, p[n - i + 1], p[n - i]);
|
||||
for (unsigned k = n - i + 1; k <= n - 1; k++) {
|
||||
for (unsigned k = n - i + 1; k <= n - 1; ++k) {
|
||||
m().mul2k(p[k], b.k());
|
||||
m().addmul(p[k], c, p[k + 1], p[k]);
|
||||
}
|
||||
|
|
@ -1586,10 +1586,10 @@ namespace upolynomial {
|
|||
// Step 2
|
||||
numeral const & c = b.numerator();
|
||||
unsigned n = sz - 1;
|
||||
for (unsigned i = 1; i <= n; i++) {
|
||||
for (unsigned i = 1; i <= n; ++i) {
|
||||
checkpoint();
|
||||
m().addmul(p[n - i], c, p[n - i + 1], p[n - i]);
|
||||
for (unsigned k = n - i + 1; k <= n - 1; k++) {
|
||||
for (unsigned k = n - i + 1; k <= n - 1; ++k) {
|
||||
m().mul(p[k], b.denominator(), p[k]);
|
||||
m().addmul(p[k], c, p[k + 1], p[k]);
|
||||
}
|
||||
|
|
@ -1604,7 +1604,7 @@ namespace upolynomial {
|
|||
return;
|
||||
// a_n * x^n + 2 * a_{n-1} * x^{n-1} + ... + (2^n)*a_0
|
||||
unsigned k = sz-1; // k = n
|
||||
for (unsigned i = 0; i < sz - 1; i++) {
|
||||
for (unsigned i = 0; i < sz - 1; ++i) {
|
||||
m().mul2k(p[i], k);
|
||||
k--;
|
||||
}
|
||||
|
|
@ -1612,7 +1612,7 @@ namespace upolynomial {
|
|||
|
||||
// p(x) := p(-x)
|
||||
void manager::p_minus_x(unsigned sz, numeral * p) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (m().is_zero(p[i]))
|
||||
continue;
|
||||
if (i % 2 == 0)
|
||||
|
|
@ -1642,7 +1642,7 @@ namespace upolynomial {
|
|||
if (sz <= 1)
|
||||
return;
|
||||
unsigned k_i = k;
|
||||
for (unsigned i = 1; i < sz; i++) {
|
||||
for (unsigned i = 1; i < sz; ++i) {
|
||||
m().mul2k(p[i], k_i);
|
||||
k_i += k;
|
||||
}
|
||||
|
|
@ -1659,7 +1659,7 @@ namespace upolynomial {
|
|||
if (sz <= 1)
|
||||
return;
|
||||
unsigned k_i = k*sz;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
k_i -= k;
|
||||
if (!m().is_zero(p[i]))
|
||||
m().mul2k(p[i], k_i);
|
||||
|
|
@ -1688,7 +1688,7 @@ namespace upolynomial {
|
|||
return;
|
||||
scoped_numeral b_i(m());
|
||||
m().set(b_i, b);
|
||||
for (unsigned i = 1; i < sz; i++) {
|
||||
for (unsigned i = 1; i < sz; ++i) {
|
||||
if (!m().is_zero(p[i]))
|
||||
m().mul(p[i], b_i, p[i]);
|
||||
m().mul(b_i, b, b_i);
|
||||
|
|
@ -1711,7 +1711,7 @@ namespace upolynomial {
|
|||
scoped_numeral c_i(m());
|
||||
m().set(c_i, 1);
|
||||
unsigned k_i = k*sz;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
k_i -= k;
|
||||
if (!m().is_zero(p[i])) {
|
||||
m().mul2k(p[i], k_i);
|
||||
|
|
@ -1739,7 +1739,7 @@ namespace upolynomial {
|
|||
numeral const & c = q.denominator();
|
||||
scoped_numeral bc(m());
|
||||
m().power(c, sz-1, bc); // bc = b^n
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (!m().is_zero(p[i]))
|
||||
m().mul(p[i], bc, p[i]);
|
||||
if (i < sz - 1) {
|
||||
|
|
@ -1871,7 +1871,7 @@ namespace upolynomial {
|
|||
sign = 0;
|
||||
prev_sign = 0;
|
||||
unsigned i = 0;
|
||||
for (; i < sz; i++) {
|
||||
for (; i < sz; ++i) {
|
||||
// find next nonzero
|
||||
unsigned psz = seq.size(i);
|
||||
numeral const * p = seq.coeffs(i);
|
||||
|
|
@ -1940,7 +1940,7 @@ namespace upolynomial {
|
|||
m().set(a_n, p[sz - 1]);
|
||||
m().abs(a_n);
|
||||
scoped_numeral c(m());
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (m().is_zero(p[i]))
|
||||
continue;
|
||||
m().set(c, p[i]);
|
||||
|
|
@ -2019,7 +2019,7 @@ namespace upolynomial {
|
|||
unsigned n = sz - 1;
|
||||
bool pos_a_n = m().is_pos(p[n]);
|
||||
unsigned log2_a_n = pos_a_n ? m().log2(p[n]) : m().mlog2(p[n]);
|
||||
for (unsigned k = 1; k <= n; k++) {
|
||||
for (unsigned k = 1; k <= n; ++k) {
|
||||
numeral const & a_n_k = p[n - k];
|
||||
if (m().is_zero(a_n_k))
|
||||
continue;
|
||||
|
|
@ -2116,7 +2116,7 @@ namespace upolynomial {
|
|||
SASSERT(!frame_stack.empty());
|
||||
unsigned sz = frame_stack.back().m_size;
|
||||
SASSERT(sz <= p_stack.size());
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m().del(p_stack.back());
|
||||
p_stack.pop_back();
|
||||
}
|
||||
|
|
@ -2142,7 +2142,7 @@ namespace upolynomial {
|
|||
set(sz, p, p_aux);
|
||||
compose_2n_p_x_div_2(p_aux.size(), p_aux.data());
|
||||
normalize(p_aux);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
p_stack.push_back(numeral());
|
||||
m().set(p_stack.back(), p_aux[i]);
|
||||
}
|
||||
|
|
@ -2150,7 +2150,7 @@ namespace upolynomial {
|
|||
// right child
|
||||
translate(sz, p_stack.data() + p_stack.size() - sz, p_aux);
|
||||
normalize(p_aux);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
p_stack.push_back(numeral());
|
||||
swap(p_stack.back(), p_aux[i]);
|
||||
}
|
||||
|
|
@ -2286,14 +2286,14 @@ namespace upolynomial {
|
|||
// Foreach i in [starting_at, v.size()) v[i] := 2^k*v[i]
|
||||
static void adjust_pos(mpbq_manager & bqm, mpbq_vector & v, unsigned starting_at, unsigned k) {
|
||||
unsigned sz = v.size();
|
||||
for (unsigned i = starting_at; i < sz; i++)
|
||||
for (unsigned i = starting_at; i < sz; ++i)
|
||||
bqm.mul2k(v[i], k);
|
||||
}
|
||||
|
||||
// Foreach i in [starting_at, v.size()) v[i] := -2^k*v[i]
|
||||
static void adjust_neg(mpbq_manager & bqm, mpbq_vector & v, unsigned starting_at, unsigned k) {
|
||||
unsigned sz = v.size();
|
||||
for (unsigned i = starting_at; i < sz; i++) {
|
||||
for (unsigned i = starting_at; i < sz; ++i) {
|
||||
bqm.mul2k(v[i], k);
|
||||
bqm.neg(v[i]);
|
||||
}
|
||||
|
|
@ -2302,7 +2302,7 @@ namespace upolynomial {
|
|||
static void swap_lowers_uppers(unsigned starting_at, mpbq_vector & lowers, mpbq_vector & uppers) {
|
||||
SASSERT(lowers.size() == uppers.size());
|
||||
unsigned sz = lowers.size();
|
||||
for (unsigned i = starting_at; i < sz; i++) {
|
||||
for (unsigned i = starting_at; i < sz; ++i) {
|
||||
swap(lowers[i], uppers[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -2581,7 +2581,7 @@ namespace upolynomial {
|
|||
if (sz == 0)
|
||||
return;
|
||||
unsigned degree = sz - 1;
|
||||
for (unsigned i = 0; i < degree; i++) {
|
||||
for (unsigned i = 0; i < degree; ++i) {
|
||||
unsigned sz = seq.size();
|
||||
derivative(seq.size(sz-1), seq.coeffs(sz-1), p_prime);
|
||||
normalize(p_prime);
|
||||
|
|
@ -3046,7 +3046,7 @@ namespace upolynomial {
|
|||
if (sz == 0)
|
||||
return;
|
||||
if (m().is_neg(p[sz - 1])) {
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
m().neg(p[i]);
|
||||
if (k % 2 == 1)
|
||||
flip_sign(r);
|
||||
|
|
@ -3132,7 +3132,7 @@ namespace upolynomial {
|
|||
}
|
||||
|
||||
std::ostream& manager::display(std::ostream & out, upolynomial_sequence const & seq, char const * var_name) const {
|
||||
for (unsigned i = 0; i < seq.size(); i++) {
|
||||
for (unsigned i = 0; i < seq.size(); ++i) {
|
||||
display(out, seq.size(i), seq.coeffs(i), var_name);
|
||||
out << "\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -406,10 +406,10 @@ namespace upolynomial {
|
|||
unsigned sz = pm.size(p);
|
||||
unsigned deg = pm.total_degree(p);
|
||||
r.reserve(deg+1);
|
||||
for (unsigned i = 0; i <= deg; i++) {
|
||||
for (unsigned i = 0; i <= deg; ++i) {
|
||||
m().reset(r[i]);
|
||||
}
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
unsigned k = pm.total_degree(pm.get_monomial(p, i));
|
||||
SASSERT(k <= deg);
|
||||
m().set(r[k], pm.coeff(p, i));
|
||||
|
|
@ -429,10 +429,10 @@ namespace upolynomial {
|
|||
unsigned sz = pm.size(p);
|
||||
unsigned deg = pm.degree(p, x);
|
||||
r.reserve(deg+1);
|
||||
for (unsigned i = 0; i <= deg; i++) {
|
||||
for (unsigned i = 0; i <= deg; ++i) {
|
||||
m().reset(r[i]);
|
||||
}
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
typename polynomial::monomial * mon = pm.get_monomial(p, i);
|
||||
if (pm.size(mon) == 0) {
|
||||
m().set(r[0], pm.coeff(p, i));
|
||||
|
|
|
|||
|
|
@ -1038,7 +1038,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
|
|||
|
||||
// make sure the leading coefficient is positive
|
||||
if (!f_pp.empty() && nm.is_neg(f_pp[f_pp.size() - 1])) {
|
||||
for (unsigned i = 0; i < f_pp.size(); i++)
|
||||
for (unsigned i = 0; i < f_pp.size(); ++i)
|
||||
nm.neg(f_pp[i]);
|
||||
// flip sign constant if k is odd
|
||||
if (k % 2 == 1) {
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ void mpz_matrix_manager::mk(unsigned m, unsigned n, mpz_matrix & A) {
|
|||
|
||||
void mpz_matrix_manager::del(mpz_matrix & A) {
|
||||
if (A.a_ij != nullptr) {
|
||||
for (unsigned i = 0; i < A.m; i++)
|
||||
for (unsigned j = 0; j < A.n; j++)
|
||||
for (unsigned i = 0; i < A.m; ++i)
|
||||
for (unsigned j = 0; j < A.n; ++j)
|
||||
nm().del(A(i,j));
|
||||
unsigned sz = sizeof(mpz) * A.m * A.n;
|
||||
m_allocator.deallocate(sz, A.a_ij);
|
||||
|
|
@ -66,16 +66,16 @@ void mpz_matrix_manager::set(mpz_matrix & A, mpz_matrix const & B) {
|
|||
mk(B.m, B.n, A);
|
||||
}
|
||||
SASSERT(A.m == B.m && A.n == B.n);
|
||||
for (unsigned i = 0; i < B.m; i++)
|
||||
for (unsigned j = 0; j < B.n; j++)
|
||||
for (unsigned i = 0; i < B.m; ++i)
|
||||
for (unsigned j = 0; j < B.n; ++j)
|
||||
nm().set(A(i, j), B(i, j));
|
||||
}
|
||||
|
||||
void mpz_matrix_manager::tensor_product(mpz_matrix const & A, mpz_matrix const & B, mpz_matrix & C) {
|
||||
scoped_mpz_matrix CC(*this);
|
||||
mk(A.m * B.m, A.n * B.n, CC);
|
||||
for (unsigned i = 0; i < CC.m(); i++)
|
||||
for (unsigned j = 0; j < CC.n(); j++)
|
||||
for (unsigned i = 0; i < CC.m(); ++i)
|
||||
for (unsigned j = 0; j < CC.n(); ++j)
|
||||
nm().mul(A(i / B.m, j / B.n),
|
||||
B(i % B.m, j % B.n),
|
||||
CC(i, j));
|
||||
|
|
@ -84,7 +84,7 @@ void mpz_matrix_manager::tensor_product(mpz_matrix const & A, mpz_matrix const &
|
|||
|
||||
void mpz_matrix_manager::swap_rows(mpz_matrix & A, unsigned i, unsigned j) {
|
||||
if (i != j) {
|
||||
for (unsigned k = 0; k < A.n; k++)
|
||||
for (unsigned k = 0; k < A.n; ++k)
|
||||
::swap(A(i, k), A(j, k));
|
||||
}
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ void mpz_matrix_manager::swap_rows(mpz_matrix & A, unsigned i, unsigned j) {
|
|||
bool mpz_matrix_manager::normalize_row(mpz * A_i, unsigned n, mpz * b_i, bool int_solver) {
|
||||
scoped_mpz g(nm());
|
||||
bool first = true;
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
if (nm().is_zero(A_i[j]))
|
||||
continue;
|
||||
if (first) {
|
||||
|
|
@ -117,7 +117,7 @@ bool mpz_matrix_manager::normalize_row(mpz * A_i, unsigned n, mpz * b_i, bool in
|
|||
if (!nm().is_one(g)) {
|
||||
if (b_i) {
|
||||
if (nm().divides(g, *b_i)) {
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
nm().div(A_i[j], g, A_i[j]);
|
||||
}
|
||||
nm().div(*b_i, g, *b_i);
|
||||
|
|
@ -128,7 +128,7 @@ bool mpz_matrix_manager::normalize_row(mpz * A_i, unsigned n, mpz * b_i, bool in
|
|||
}
|
||||
}
|
||||
else {
|
||||
for (unsigned j = 0; j < n; j++) {
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
nm().div(A_i[j], g, A_i[j]);
|
||||
}
|
||||
}
|
||||
|
|
@ -174,15 +174,15 @@ k1=> 0 0 ... 0 X ... X
|
|||
*/
|
||||
bool mpz_matrix_manager::eliminate(mpz_matrix & A, mpz * b, unsigned k1, unsigned k2, bool int_solver) {
|
||||
// check if first k2-1 positions of row k1 are 0
|
||||
DEBUG_CODE(for (unsigned j = 0; j < k2; j++) { SASSERT(nm().is_zero(A(k1, j))); });
|
||||
DEBUG_CODE(for (unsigned j = 0; j < k2; ++j) { SASSERT(nm().is_zero(A(k1, j))); });
|
||||
mpz & a_kk = A(k1, k2);
|
||||
SASSERT(!nm().is_zero(a_kk));
|
||||
scoped_mpz t1(nm()), t2(nm());
|
||||
scoped_mpz a_ik_prime(nm()), a_kk_prime(nm()), lcm_a_kk_a_ik(nm());
|
||||
// for all rows below pivot
|
||||
for (unsigned i = k1+1; i < A.m; i++) {
|
||||
for (unsigned i = k1+1; i < A.m; ++i) {
|
||||
// check if first k-1 positions of row k are 0
|
||||
DEBUG_CODE(for (unsigned j = 0; j < k2; j++) { SASSERT(nm().is_zero(A(i, j))); });
|
||||
DEBUG_CODE(for (unsigned j = 0; j < k2; ++j) { SASSERT(nm().is_zero(A(i, j))); });
|
||||
mpz & a_ik = A(i, k2);
|
||||
if (!nm().is_zero(a_ik)) {
|
||||
// a_ik' = lcm(a_kk, a_ik)/a_kk
|
||||
|
|
@ -190,7 +190,7 @@ bool mpz_matrix_manager::eliminate(mpz_matrix & A, mpz * b, unsigned k1, unsigne
|
|||
nm().lcm(a_kk, a_ik, lcm_a_kk_a_ik);
|
||||
nm().div(lcm_a_kk_a_ik, a_kk, a_ik_prime);
|
||||
nm().div(lcm_a_kk_a_ik, a_ik, a_kk_prime);
|
||||
for (unsigned j = k2+1; j < A.n; j++) {
|
||||
for (unsigned j = k2+1; j < A.n; ++j) {
|
||||
// a_ij <- a_kk' * a_ij - a_ik' * a_kj
|
||||
nm().mul(a_ik_prime, A(k1, j), t1);
|
||||
nm().mul(a_kk_prime, A(i, j), t2);
|
||||
|
|
@ -217,18 +217,18 @@ bool mpz_matrix_manager::solve_core(mpz_matrix const & _A, mpz * b, bool int_sol
|
|||
SASSERT(_A.n == _A.m);
|
||||
scoped_mpz_matrix A(*this);
|
||||
set(A, _A);
|
||||
for (unsigned k = 0; k < A.m(); k++) {
|
||||
for (unsigned k = 0; k < A.m(); ++k) {
|
||||
TRACE(mpz_matrix,
|
||||
tout << "k: " << k << "\n" << A;
|
||||
tout << "b:";
|
||||
for (unsigned i = 0; i < A.m(); i++) {
|
||||
for (unsigned i = 0; i < A.m(); ++i) {
|
||||
tout << " ";
|
||||
nm().display(tout, b[i]);
|
||||
}
|
||||
tout << "\n";);
|
||||
// find pivot
|
||||
unsigned i = k;
|
||||
for (; i < A.m(); i++) {
|
||||
for (; i < A.m(); ++i) {
|
||||
if (!nm().is_zero(A(i, k)))
|
||||
break;
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@ bool mpz_matrix_manager::solve_core(mpz_matrix const & _A, mpz * b, bool int_sol
|
|||
unsigned k = A.m();
|
||||
while (k > 0) {
|
||||
--k;
|
||||
DEBUG_CODE(for (unsigned j = 0; j < A.n(); j++) { SASSERT(j == k || nm().is_zero(A(k, j))); });
|
||||
DEBUG_CODE(for (unsigned j = 0; j < A.n(); ++j) { SASSERT(j == k || nm().is_zero(A(k, j))); });
|
||||
SASSERT(!nm().is_zero(A(k, k)));
|
||||
if (nm().divides(A(k, k), b[k])) {
|
||||
nm().div(b[k], A(k, k), b[k]);
|
||||
|
|
@ -283,7 +283,7 @@ bool mpz_matrix_manager::solve_core(mpz_matrix const & _A, mpz * b, bool int_sol
|
|||
}
|
||||
|
||||
bool mpz_matrix_manager::solve(mpz_matrix const & A, mpz * b, mpz const * c) {
|
||||
for (unsigned i = 0; i < A.n; i++)
|
||||
for (unsigned i = 0; i < A.n; ++i)
|
||||
nm().set(b[i], c[i]);
|
||||
return solve_core(A, b, true);
|
||||
}
|
||||
|
|
@ -291,11 +291,11 @@ bool mpz_matrix_manager::solve(mpz_matrix const & A, mpz * b, mpz const * c) {
|
|||
bool mpz_matrix_manager::solve(mpz_matrix const & A, int * b, int const * c) {
|
||||
scoped_mpz_matrix _b(*this);
|
||||
mk(A.n, 1, _b);
|
||||
for (unsigned i = 0; i < A.n; i++)
|
||||
for (unsigned i = 0; i < A.n; ++i)
|
||||
nm().set(_b(i,0), c[i]);
|
||||
bool r = solve_core(A, _b.A.a_ij, true);
|
||||
if (r) {
|
||||
for (unsigned i = 0; i < A.n; i++)
|
||||
for (unsigned i = 0; i < A.n; ++i)
|
||||
b[i] = _b.get_int(i, 0);
|
||||
}
|
||||
return r;
|
||||
|
|
@ -321,8 +321,8 @@ void mpz_matrix_manager::filter_cols(mpz_matrix const & A, unsigned num_cols, un
|
|||
SASSERT(num_cols < A.n);
|
||||
scoped_mpz_matrix C(*this);
|
||||
mk(A.m, num_cols, C);
|
||||
for (unsigned i = 0; i < A.m; i++)
|
||||
for (unsigned j = 0; j < num_cols; j++)
|
||||
for (unsigned i = 0; i < A.m; ++i)
|
||||
for (unsigned j = 0; j < num_cols; ++j)
|
||||
nm().set(C(i, j), A(i, cols[j]));
|
||||
B.swap(C);
|
||||
}
|
||||
|
|
@ -333,7 +333,7 @@ void mpz_matrix_manager::permute_rows(mpz_matrix const & A, unsigned const * p,
|
|||
DEBUG_CODE({
|
||||
buffer<bool> seen;
|
||||
seen.resize(A.m, false);
|
||||
for (unsigned i = 0; i < A.m; i++) {
|
||||
for (unsigned i = 0; i < A.m; ++i) {
|
||||
SASSERT(p[i] < A.m);
|
||||
SASSERT(!seen[p[i]]);
|
||||
seen[p[i]] = true;
|
||||
|
|
@ -341,8 +341,8 @@ void mpz_matrix_manager::permute_rows(mpz_matrix const & A, unsigned const * p,
|
|||
});
|
||||
scoped_mpz_matrix C(*this);
|
||||
mk(A.m, A.n, C);
|
||||
for (unsigned i = 0; i < A.m; i++)
|
||||
for (unsigned j = 0; j < A.n; j++)
|
||||
for (unsigned i = 0; i < A.m; ++i)
|
||||
for (unsigned j = 0; j < A.n; ++j)
|
||||
nm().set(C(i, j), A(p[i], j));
|
||||
B.swap(C);
|
||||
}
|
||||
|
|
@ -356,13 +356,13 @@ unsigned mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsi
|
|||
set(A, _A);
|
||||
sbuffer<unsigned, 128> rows;
|
||||
rows.resize(A.m(), 0);
|
||||
for (unsigned i = 0; i < A.m(); i++)
|
||||
for (unsigned i = 0; i < A.m(); ++i)
|
||||
rows[i] = i;
|
||||
for (unsigned k1 = 0, k2 = 0; k1 < A.m(); k1++) {
|
||||
for (unsigned k1 = 0, k2 = 0; k1 < A.m(); ++k1) {
|
||||
TRACE(mpz_matrix, tout << "k1: " << k1 << ", k2: " << k2 << "\n" << A;);
|
||||
// find pivot
|
||||
unsigned pivot = UINT_MAX;
|
||||
for (unsigned i = k1; i < A.m(); i++) {
|
||||
for (unsigned i = k1; i < A.m(); ++i) {
|
||||
if (!nm().is_zero(A(i, k2))) {
|
||||
if (pivot == UINT_MAX) {
|
||||
pivot = i;
|
||||
|
|
@ -390,8 +390,8 @@ unsigned mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsi
|
|||
// Copy linear independent rows to B
|
||||
mpz_matrix & C = A;
|
||||
mk(r_sz, _A.n, C);
|
||||
for (unsigned i = 0; i < r_sz; i++ ) {
|
||||
for (unsigned j = 0; j < _A.n; j++) {
|
||||
for (unsigned i = 0; i < r_sz; ++i ) {
|
||||
for (unsigned j = 0; j < _A.n; ++j) {
|
||||
nm().set(C(i, j), _A(r[i], j));
|
||||
}
|
||||
}
|
||||
|
|
@ -401,14 +401,14 @@ unsigned mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsi
|
|||
|
||||
void mpz_matrix_manager::display(std::ostream & out, mpz_matrix const & A, unsigned cell_width) const {
|
||||
out << A.m << " x " << A.n << " Matrix\n";
|
||||
for (unsigned i = 0; i < A.m; i++) {
|
||||
for (unsigned j = 0; j < A.n; j++) {
|
||||
for (unsigned i = 0; i < A.m; ++i) {
|
||||
for (unsigned j = 0; j < A.n; ++j) {
|
||||
if (j > 0)
|
||||
out << " ";
|
||||
std::string s = nm().to_string(A(i, j));
|
||||
if (s.size() < cell_width) {
|
||||
unsigned space = cell_width - static_cast<unsigned>(s.size());
|
||||
for (unsigned k = 0; k < space; k++)
|
||||
for (unsigned k = 0; k < space; ++k)
|
||||
out << " ";
|
||||
}
|
||||
out << s;
|
||||
|
|
|
|||
|
|
@ -689,7 +689,7 @@ namespace realclosure {
|
|||
template<typename T>
|
||||
void restore_saved_intervals(ptr_vector<T> & to_restore) {
|
||||
unsigned sz = to_restore.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
T * v = to_restore[i];
|
||||
set_interval(v->m_interval, *(v->m_old_interval));
|
||||
bqim().del(*(v->m_old_interval));
|
||||
|
|
@ -772,7 +772,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void finalize(array<polynomial> & ps) {
|
||||
for (unsigned i = 0; i < ps.size(); i++)
|
||||
for (unsigned i = 0; i < ps.size(); ++i)
|
||||
reset_p(ps[i]);
|
||||
ps.finalize(allocator());
|
||||
}
|
||||
|
|
@ -783,7 +783,7 @@ namespace realclosure {
|
|||
|
||||
void del_sign_conditions(unsigned sz, sign_condition * const * to_delete) {
|
||||
ptr_buffer<sign_condition> all_to_delete;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
sign_condition * sc = to_delete[i];
|
||||
while (sc && sc->m_mark == false) {
|
||||
sc->m_mark = true;
|
||||
|
|
@ -791,7 +791,7 @@ namespace realclosure {
|
|||
sc = sc->m_prev;
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < all_to_delete.size(); i++) {
|
||||
for (unsigned i = 0; i < all_to_delete.size(); ++i) {
|
||||
del_sign_condition(all_to_delete[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -863,7 +863,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void inc_ref(unsigned sz, value * const * p) {
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
inc_ref(p[i]);
|
||||
}
|
||||
|
||||
|
|
@ -877,7 +877,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void dec_ref(unsigned sz, value * const * p) {
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
dec_ref(p[i]);
|
||||
}
|
||||
|
||||
|
|
@ -887,7 +887,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void del(numeral_vector & v) {
|
||||
for (unsigned i = 0; i < v.size(); i++)
|
||||
for (unsigned i = 0; i < v.size(); ++i)
|
||||
del(v[i]);
|
||||
}
|
||||
|
||||
|
|
@ -1104,7 +1104,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
bool depends_on_infinitesimals(unsigned sz, value * const * p) const {
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
if (depends_on_infinitesimals(p[i]))
|
||||
return true;
|
||||
return false;
|
||||
|
|
@ -1466,7 +1466,7 @@ namespace realclosure {
|
|||
if (!abs_lower_magnitude(interval(p[n-1]), lc_mag))
|
||||
return false;
|
||||
N = -static_cast<int>(m_ini_precision);
|
||||
for (unsigned k = 2; k <= n; k++) {
|
||||
for (unsigned k = 2; k <= n; ++k) {
|
||||
value * a = p[n - k];
|
||||
if (!is_zero(a) && sign(a) != lc_sign) {
|
||||
int a_mag;
|
||||
|
|
@ -1512,7 +1512,7 @@ namespace realclosure {
|
|||
if (!abs_lower_magnitude(aux, lc_mag))
|
||||
return false;
|
||||
N = -static_cast<int>(m_ini_precision);
|
||||
for (unsigned k = 2; k <= n; k++) {
|
||||
for (unsigned k = 2; k <= n; ++k) {
|
||||
value * a = as[n - k];
|
||||
if (!is_zero(a)) {
|
||||
neg_root_adjust(interval(as[n-k]), n-k, aux);
|
||||
|
|
@ -1590,7 +1590,7 @@ namespace realclosure {
|
|||
derivative(n, p, p_prime);
|
||||
ds.push(p_prime.size(), p_prime.data());
|
||||
SASSERT(n >= 3);
|
||||
for (unsigned i = 0; i < n - 2; i++) {
|
||||
for (unsigned i = 0; i < n - 2; ++i) {
|
||||
SASSERT(ds.size() > 0);
|
||||
unsigned prev = ds.size() - 1;
|
||||
n = ds.size(prev);
|
||||
|
|
@ -1710,7 +1710,7 @@ namespace realclosure {
|
|||
) {
|
||||
SASSERT(taqrs.size() == prs.size());
|
||||
new_taqrs.reset(); new_prs.reset();
|
||||
for (unsigned i = 0; i < taqrs.size(); i++) {
|
||||
for (unsigned i = 0; i < taqrs.size(); ++i) {
|
||||
// Add prs * 1
|
||||
new_taqrs.push_back(taqrs[i]);
|
||||
new_prs.push(prs.size(i), prs.coeffs(i));
|
||||
|
|
@ -1776,7 +1776,7 @@ namespace realclosure {
|
|||
void set_array_p(array<polynomial> & ps, scoped_polynomial_seq const & prs) {
|
||||
unsigned sz = prs.size();
|
||||
ps.set(allocator(), sz, polynomial());
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
unsigned pi_sz = prs.size(i);
|
||||
value * const * pi = prs.coeffs(i);
|
||||
set_p(ps[i], pi_sz, pi);
|
||||
|
|
@ -1991,12 +1991,12 @@ namespace realclosure {
|
|||
SASSERT(M_s.m() == scs.size());
|
||||
TRACE(rcf_sign_det,
|
||||
tout << M_s;
|
||||
for (unsigned j = 0; j < scs.size(); j++) {
|
||||
for (unsigned j = 0; j < scs.size(); ++j) {
|
||||
display_sign_conditions(tout, scs[j]);
|
||||
tout << " = " << taqrs[j] << "\n";
|
||||
}
|
||||
tout << "qs:\n";
|
||||
for (unsigned j = 0; j < qs.size(); j++) {
|
||||
for (unsigned j = 0; j < qs.size(); ++j) {
|
||||
display_poly(tout, qs.size(j), qs.coeffs(j)); tout << "\n";
|
||||
});
|
||||
// We keep executing this loop until we have only one root for each sign condition in scs.
|
||||
|
|
@ -2028,9 +2028,9 @@ namespace realclosure {
|
|||
// Solve
|
||||
// new_M_s * sc_cardinalities = new_taqrs
|
||||
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";);
|
||||
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); });
|
||||
DEBUG_CODE(for (unsigned j = 0; j < sc_cardinalities.size(); ++j) { SASSERT(0 <= sc_cardinalities[j] && sc_cardinalities[j] <= num_roots); });
|
||||
// We should keep q only if it discriminated something.
|
||||
// That is,
|
||||
// If !use_q2, then There is an i s.t. sc_cardinalities[2*i] > 0 && sc_cardinalities[2*i] > 0
|
||||
|
|
@ -2051,7 +2051,7 @@ namespace realclosure {
|
|||
while (j < sc_cardinalities.size()) {
|
||||
sign_condition * sc = scs[k];
|
||||
k++;
|
||||
for (unsigned s = 0; s < step_sz; s++) {
|
||||
for (unsigned s = 0; s < step_sz; ++s) {
|
||||
// Remark: the second row of M contains the sign for q
|
||||
if (sc_cardinalities[j] > 0) {
|
||||
new_scs.push_back(mk_sign_condition(q_idx, M.get_int(1, s), sc));
|
||||
|
|
@ -2074,7 +2074,7 @@ namespace realclosure {
|
|||
// Update taqrs and prs
|
||||
prs.reset();
|
||||
taqrs.reset();
|
||||
for (unsigned j = 0; j < new_num_rows; j++) {
|
||||
for (unsigned j = 0; j < new_num_rows; ++j) {
|
||||
unsigned rid = new_row_idxs[j];
|
||||
prs.push(new_prs.size(rid), new_prs.coeffs(rid));
|
||||
taqrs.push_back(new_taqrs[rid]);
|
||||
|
|
@ -2089,21 +2089,21 @@ namespace realclosure {
|
|||
tout << "Final state\n";
|
||||
display_poly(tout, p_sz, p); tout << "\n";
|
||||
tout << M_s;
|
||||
for (unsigned j = 0; j < scs.size(); j++) {
|
||||
for (unsigned j = 0; j < scs.size(); ++j) {
|
||||
display_sign_conditions(tout, scs[j]);
|
||||
tout << " = " << taqrs[j] << "\n";
|
||||
}
|
||||
tout << "qs:\n";
|
||||
for (unsigned j = 0; j < qs.size(); j++) {
|
||||
for (unsigned j = 0; j < qs.size(); ++j) {
|
||||
display_poly(tout, qs.size(j), qs.coeffs(j)); tout << "\n";
|
||||
}
|
||||
tout << "prs:\n";
|
||||
for (unsigned j = 0; j < prs.size(); j++) {
|
||||
for (unsigned j = 0; j < prs.size(); ++j) {
|
||||
display_poly(tout, prs.size(j), prs.coeffs(j)); tout << "\n";
|
||||
});
|
||||
SASSERT(M_s.n() == M_s.m()); SASSERT(M_s.n() == static_cast<unsigned>(num_roots));
|
||||
sign_det * sd = mk_sign_det(M_s, prs, taqrs, qs, scs);
|
||||
for (unsigned idx = 0; idx < static_cast<unsigned>(num_roots); idx++) {
|
||||
for (unsigned idx = 0; idx < static_cast<unsigned>(num_roots); ++idx) {
|
||||
add_root(p_sz, p, interval, iso_interval, sd, idx, roots);
|
||||
}
|
||||
}
|
||||
|
|
@ -2115,7 +2115,7 @@ namespace realclosure {
|
|||
SASSERT(n >= 2);
|
||||
SASSERT(!is_zero(p[0]));
|
||||
SASSERT(!is_zero(p[n-1]));
|
||||
for (unsigned i = 1; i < n - 1; i++) {
|
||||
for (unsigned i = 1; i < n - 1; ++i) {
|
||||
if (!is_zero(p[i]))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2410,7 +2410,7 @@ namespace realclosure {
|
|||
\brief Root isolation entry point.
|
||||
*/
|
||||
void isolate_roots(unsigned n, numeral const * p, numeral_vector & roots) {
|
||||
TRACE(rcf_isolate_bug, tout << "isolate_roots: "; for (unsigned i = 0; i < n; i++) { display(tout, p[i]); tout << " "; } tout << "\n";);
|
||||
TRACE(rcf_isolate_bug, tout << "isolate_roots: "; for (unsigned i = 0; i < n; ++i) { display(tout, p[i]); tout << " "; } tout << "\n";);
|
||||
SASSERT(n > 0);
|
||||
SASSERT(!is_zero(p[n-1]));
|
||||
if (n == 1) {
|
||||
|
|
@ -2418,14 +2418,14 @@ namespace realclosure {
|
|||
return;
|
||||
}
|
||||
unsigned i = 0;
|
||||
for (; i < n; i++) {
|
||||
for (; i < n; ++i) {
|
||||
if (!is_zero(p[i]))
|
||||
break;
|
||||
}
|
||||
SASSERT(i < n);
|
||||
SASSERT(!is_zero(p[i]));
|
||||
ptr_buffer<value> nz_p;
|
||||
for (; i < n; i++)
|
||||
for (; i < n; ++i)
|
||||
nz_p.push_back(p[i].m_value);
|
||||
nz_isolate_roots(nz_p.size(), nz_p.data(), roots);
|
||||
if (nz_p.size() < n) {
|
||||
|
|
@ -2705,13 +2705,13 @@ namespace realclosure {
|
|||
value_ref a_i(*this);
|
||||
unsigned min = std::min(sz1, sz2);
|
||||
unsigned i = 0;
|
||||
for (; i < min; i++) {
|
||||
for (; i < min; ++i) {
|
||||
add(p1[i], p2[i], a_i);
|
||||
r.push_back(a_i);
|
||||
}
|
||||
for (; i < sz1; i++)
|
||||
for (; i < sz1; ++i)
|
||||
r.push_back(p1[i]);
|
||||
for (; i < sz2; i++)
|
||||
for (; i < sz2; ++i)
|
||||
r.push_back(p2[i]);
|
||||
SASSERT(r.size() == std::max(sz1, sz2));
|
||||
adjust_size(r);
|
||||
|
|
@ -2741,13 +2741,13 @@ namespace realclosure {
|
|||
value_ref a_i(*this);
|
||||
unsigned min = std::min(sz1, sz2);
|
||||
unsigned i = 0;
|
||||
for (; i < min; i++) {
|
||||
for (; i < min; ++i) {
|
||||
sub(p1[i], p2[i], a_i);
|
||||
r.push_back(a_i);
|
||||
}
|
||||
for (; i < sz1; i++)
|
||||
for (; i < sz1; ++i)
|
||||
r.push_back(p1[i]);
|
||||
for (; i < sz2; i++) {
|
||||
for (; i < sz2; ++i) {
|
||||
neg(p2[i], a_i);
|
||||
r.push_back(a_i);
|
||||
}
|
||||
|
|
@ -2778,7 +2778,7 @@ namespace realclosure {
|
|||
if (a == nullptr)
|
||||
return;
|
||||
value_ref a_i(*this);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
mul(a, p[i], a_i);
|
||||
r.push_back(a_i);
|
||||
}
|
||||
|
|
@ -2798,11 +2798,11 @@ namespace realclosure {
|
|||
std::swap(p1, p2);
|
||||
}
|
||||
value_ref tmp(*this);
|
||||
for (unsigned i = 0; i < sz1; i++) {
|
||||
for (unsigned i = 0; i < sz1; ++i) {
|
||||
checkpoint();
|
||||
if (p1[i] == nullptr)
|
||||
continue;
|
||||
for (unsigned j = 0; j < sz2; j++) {
|
||||
for (unsigned j = 0; j < sz2; ++j) {
|
||||
// r[i+j] <- r[i+j] + p1[i]*p2[j]
|
||||
mul(p1[i], p2[j], tmp);
|
||||
add(r[i+j], tmp, tmp);
|
||||
|
|
@ -2821,7 +2821,7 @@ namespace realclosure {
|
|||
return;
|
||||
value_ref a_i(*this);
|
||||
unsigned sz = p.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
div(p[i], a, a_i);
|
||||
p.set(i, a_i);
|
||||
}
|
||||
|
|
@ -2864,7 +2864,7 @@ namespace realclosure {
|
|||
// q[m_n] <- q[m_n] + r[sz1 - 1]/b_n
|
||||
add(q[m_n], ratio, aux);
|
||||
q.set(m_n, aux);
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
// r[i + m_n] <- r[i + m_n] - ratio * p2[i]
|
||||
mul(ratio, p2[i], aux);
|
||||
sub(r[i + m_n], aux, aux);
|
||||
|
|
@ -2891,7 +2891,7 @@ namespace realclosure {
|
|||
void div(unsigned sz, value * const * p, value * a, value_ref_buffer & r) {
|
||||
r.reset();
|
||||
value_ref a_i(*this);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
div(p[i], a, a_i);
|
||||
r.push_back(a_i);
|
||||
}
|
||||
|
|
@ -2927,7 +2927,7 @@ namespace realclosure {
|
|||
}
|
||||
unsigned m_n = sz1 - sz2;
|
||||
div(r[sz1 - 1], b_n, ratio);
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
mul(ratio, p2[i], new_a);
|
||||
sub(r[i + m_n], new_a, new_a);
|
||||
r.set(i + m_n, new_a);
|
||||
|
|
@ -2977,14 +2977,14 @@ namespace realclosure {
|
|||
a_m = r[sz1 - 1];
|
||||
// don't need to update position sz1 - 1, since it will become 0
|
||||
if (!is_rational_one(b_n)) {
|
||||
for (unsigned i = 0; i < sz1 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz1 - 1; ++i) {
|
||||
mul(r[i], b_n, new_a);
|
||||
r.set(i, new_a);
|
||||
}
|
||||
}
|
||||
// buffer: a_m * x^m + b_n * a_{m-1} * x^{m-1} + ... + b_n * a_0
|
||||
// don't need to process i = sz2 - 1, because r[sz1 - 1] will become 0.
|
||||
for (unsigned i = 0; i < sz2 - 1; i++) {
|
||||
for (unsigned i = 0; i < sz2 - 1; ++i) {
|
||||
mul(a_m, p2[i], new_a);
|
||||
sub(r[i + m_n], new_a, new_a);
|
||||
r.set(i + m_n, new_a);
|
||||
|
|
@ -3006,7 +3006,7 @@ namespace realclosure {
|
|||
SASSERT(p != r.data());
|
||||
r.reset();
|
||||
value_ref a_i(*this);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
neg(p[i], a_i);
|
||||
r.push_back(a_i);
|
||||
}
|
||||
|
|
@ -3018,7 +3018,7 @@ namespace realclosure {
|
|||
void neg(value_ref_buffer & r) {
|
||||
value_ref a_i(*this);
|
||||
unsigned sz = r.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
neg(r[i], a_i);
|
||||
r.set(i, a_i);
|
||||
}
|
||||
|
|
@ -3030,7 +3030,7 @@ namespace realclosure {
|
|||
void neg(polynomial & p) {
|
||||
value_ref a_i(*this);
|
||||
unsigned sz = p.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
neg(p[i], a_i);
|
||||
inc_ref(a_i.get());
|
||||
dec_ref(p[i]);
|
||||
|
|
@ -3106,7 +3106,7 @@ namespace realclosure {
|
|||
bool struct_eq(unsigned sz_a, value * const * p_a, unsigned sz_b, value * const * p_b) const {
|
||||
if (sz_a != sz_b)
|
||||
return false;
|
||||
for (unsigned i = 0; i < sz_a; i++) {
|
||||
for (unsigned i = 0; i < sz_a; ++i) {
|
||||
if (!struct_eq(p_a[i], p_b[i]))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3148,7 +3148,7 @@ namespace realclosure {
|
|||
\brief See comment at has_clean_denominators(value * a)
|
||||
*/
|
||||
bool has_clean_denominators(unsigned sz, value * const * p) const {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (!has_clean_denominators(p[i]))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3218,7 +3218,7 @@ namespace realclosure {
|
|||
value_ref_buffer nums(*this), dens(*this);
|
||||
value_ref a_n(*this), a_d(*this);
|
||||
bool all_one = true;
|
||||
for (unsigned i = 0; i < p_sz; i++) {
|
||||
for (unsigned i = 0; i < p_sz; ++i) {
|
||||
if (p[i]) {
|
||||
clean_denominators_core(p[i], a_n, a_d);
|
||||
nums.push_back(a_n);
|
||||
|
|
@ -3243,7 +3243,7 @@ namespace realclosure {
|
|||
bool found_z = false;
|
||||
SASSERT(nums.size() == p_sz);
|
||||
SASSERT(dens.size() == p_sz);
|
||||
for (unsigned i = 0; i < p_sz; i++) {
|
||||
for (unsigned i = 0; i < p_sz; ++i) {
|
||||
if (!dens[i])
|
||||
continue;
|
||||
if (is_nz_rational(dens[i])) {
|
||||
|
|
@ -3278,7 +3278,7 @@ namespace realclosure {
|
|||
d = lcm;
|
||||
value_ref_buffer multipliers(*this);
|
||||
value_ref m(*this);
|
||||
for (unsigned i = 0; i < p_sz; i++) {
|
||||
for (unsigned i = 0; i < p_sz; ++i) {
|
||||
if (!nums[i]) {
|
||||
norm_p.push_back(nullptr);
|
||||
}
|
||||
|
|
@ -3297,7 +3297,7 @@ namespace realclosure {
|
|||
is_z = true;
|
||||
}
|
||||
bool found_lt_eq = false;
|
||||
for (unsigned j = 0; j < p_sz; j++) {
|
||||
for (unsigned j = 0; j < p_sz; ++j) {
|
||||
TRACE(rcf_clean_bug, tout << "j: " << j << " "; display(tout, m, false); tout << "\n";);
|
||||
if (!dens[j])
|
||||
continue;
|
||||
|
|
@ -3547,7 +3547,7 @@ namespace realclosure {
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
for (unsigned i = 0; i < p_sz; i++) {
|
||||
for (unsigned i = 0; i < p_sz; ++i) {
|
||||
if (p[i]) {
|
||||
if (!gcd_int_coeffs(p[i], g))
|
||||
return false;
|
||||
|
|
@ -3574,7 +3574,7 @@ namespace realclosure {
|
|||
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++) {
|
||||
for (unsigned i = 0; i < p.size(); ++i) {
|
||||
if (p[i]) {
|
||||
a = p[i];
|
||||
p.set(i, nullptr);
|
||||
|
|
@ -3608,7 +3608,7 @@ namespace realclosure {
|
|||
value_ref_buffer new_ais(*this);
|
||||
value_ref ai(*this);
|
||||
polynomial const & p = rf->num();
|
||||
for (unsigned i = 0; i < p.size(); i++) {
|
||||
for (unsigned i = 0; i < p.size(); ++i) {
|
||||
if (p[i]) {
|
||||
ai = p[i];
|
||||
exact_div_z(ai, b);
|
||||
|
|
@ -3649,7 +3649,7 @@ namespace realclosure {
|
|||
value_ref a_i(*this);
|
||||
SASSERT(p[sz-1] != 0);
|
||||
if (!is_rational_one(p[sz-1])) {
|
||||
for (unsigned i = 0; i < sz - 1; i++) {
|
||||
for (unsigned i = 0; i < sz - 1; ++i) {
|
||||
div(p[i], p[sz-1], a_i);
|
||||
p.set(i, a_i);
|
||||
}
|
||||
|
|
@ -3759,7 +3759,7 @@ namespace realclosure {
|
|||
void derivative(unsigned sz, value * const * p, value_ref_buffer & r) {
|
||||
r.reset();
|
||||
if (sz > 1) {
|
||||
for (unsigned i = 1; i < sz; i++) {
|
||||
for (unsigned i = 1; i < sz; ++i) {
|
||||
value_ref a_i(*this);
|
||||
a_i = mk_rational(mpq(i));
|
||||
mul(a_i, p[i], a_i);
|
||||
|
|
@ -3937,7 +3937,7 @@ namespace realclosure {
|
|||
approximating the coefficients do not have -oo or oo as lower/upper bounds.
|
||||
*/
|
||||
bool has_refineable_approx_coeffs(unsigned n, value * const * p) {
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
if (p[i] != nullptr) {
|
||||
mpbqi & a_i = interval(p[i]);
|
||||
if (a_i.lower_is_inf() || a_i.upper_is_inf())
|
||||
|
|
@ -4021,7 +4021,7 @@ namespace realclosure {
|
|||
*/
|
||||
int find_biggest_interval_magnitude(unsigned n, value * const * p) {
|
||||
int r = INT_MIN;
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
if (p[i] != nullptr) {
|
||||
mpbqi & a_i = interval(p[i]);
|
||||
SASSERT(!a_i.lower_is_inf() && !a_i.upper_is_inf());
|
||||
|
|
@ -4109,7 +4109,7 @@ namespace realclosure {
|
|||
sign = 0;
|
||||
prev_sign = 0;
|
||||
unsigned i = 0;
|
||||
for (; i < sz; i++) {
|
||||
for (; i < sz; ++i) {
|
||||
// find next nonzero
|
||||
unsigned psz = seq.size(i);
|
||||
value * const * p = seq.coeffs(i);
|
||||
|
|
@ -4254,7 +4254,7 @@ namespace realclosure {
|
|||
\brief Refine the interval for each coefficient of in the polynomial p.
|
||||
*/
|
||||
bool refine_coeffs_interval(unsigned n, value * const * p, unsigned prec) {
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
if (p[i] != nullptr && !refine_interval(p[i], prec))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -4517,7 +4517,7 @@ namespace realclosure {
|
|||
*/
|
||||
static unsigned first_non_zero(polynomial const & p) {
|
||||
unsigned sz = p.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (p[i] != 0)
|
||||
return i;
|
||||
}
|
||||
|
|
@ -4531,7 +4531,7 @@ namespace realclosure {
|
|||
int sign_of_first_non_zero(polynomial const & p, unsigned start_idx) {
|
||||
unsigned sz = p.size();
|
||||
SASSERT(start_idx < sz);
|
||||
for (unsigned i = start_idx; i < sz; i++) {
|
||||
for (unsigned i = start_idx; i < sz; ++i) {
|
||||
if (p[i] != 0)
|
||||
return sign(p[i]);
|
||||
}
|
||||
|
|
@ -4810,7 +4810,7 @@ namespace realclosure {
|
|||
int_buffer new_taqrs;
|
||||
value_ref_buffer prq(*this);
|
||||
// fill new_taqrs using taqrs and the new tarski queries containing q (and q^2 when use_q2 == true).
|
||||
for (unsigned i = 0; i < taqrs.size(); i++) {
|
||||
for (unsigned i = 0; i < taqrs.size(); ++i) {
|
||||
// Add TaQ(p, prs[i] * 1; x->iso_interval())
|
||||
new_taqrs.push_back(taqrs[i]);
|
||||
// Add TaQ(p, prs[i] * q; x->iso_interval())
|
||||
|
|
@ -4832,16 +4832,16 @@ namespace realclosure {
|
|||
// - contains only 0 or 1
|
||||
// - !use_q2 IMPLIES for all i in [0, taqrs.size()) (sc_cardinalities[2*i] == 1) + (sc_cardinalities[2*i + 1] == 1) == 1
|
||||
// - use_q2 IMPLIES for all i in [0, taqrs.size()) (sc_cardinalities[3*i] == 1) + (sc_cardinalities[3*i + 1] == 1) + (sc_cardinalities[3*i + 2] == 1) == 1
|
||||
for (unsigned i = 0; i < sc_cardinalities.size(); i++) {
|
||||
for (unsigned i = 0; i < sc_cardinalities.size(); ++i) {
|
||||
SASSERT(sc_cardinalities[i] == 0 || sc_cardinalities[i] == 1);
|
||||
}
|
||||
if (!use_q2) {
|
||||
for (unsigned i = 0; i < taqrs.size(); i++) {
|
||||
for (unsigned i = 0; i < taqrs.size(); ++i) {
|
||||
SASSERT((sc_cardinalities[2*i] == 1) + (sc_cardinalities[2*i + 1] == 1) == 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (unsigned i = 0; i < taqrs.size(); i++) {
|
||||
for (unsigned i = 0; i < taqrs.size(); ++i) {
|
||||
SASSERT((sc_cardinalities[3*i] == 1) + (sc_cardinalities[3*i + 1] == 1) + (sc_cardinalities[3*i + 2] == 1) == 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -5667,7 +5667,7 @@ namespace realclosure {
|
|||
alpha_val = mk_rational_function_value(alpha);
|
||||
// search for the root that is equal to alpha
|
||||
unsigned i = 0;
|
||||
for (i = 0; i < roots.size(); i++) {
|
||||
for (i = 0; i < roots.size(); ++i) {
|
||||
if (compare(alpha_val, roots[i].m_value) == 0) {
|
||||
// found it;
|
||||
break;
|
||||
|
|
@ -5809,7 +5809,7 @@ namespace realclosure {
|
|||
value_ref neg_a(*this);
|
||||
neg(a.m_value, neg_a);
|
||||
p.push_back(neg_a);
|
||||
for (unsigned i = 0; i < k - 1; i++)
|
||||
for (unsigned i = 0; i < k - 1; ++i)
|
||||
p.push_back(nullptr);
|
||||
p.push_back(one());
|
||||
|
||||
|
|
@ -5904,7 +5904,7 @@ namespace realclosure {
|
|||
}
|
||||
|
||||
void mark(polynomial const & p) {
|
||||
for (unsigned i = 0; i < p.size(); i++) {
|
||||
for (unsigned i = 0; i < p.size(); ++i) {
|
||||
mark(p[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -5921,7 +5921,7 @@ namespace realclosure {
|
|||
|
||||
static unsigned num_nz_coeffs(polynomial const & p) {
|
||||
unsigned r = 0;
|
||||
for (unsigned i = 0; i < p.size(); i++) {
|
||||
for (unsigned i = 0; i < p.size(); ++i) {
|
||||
if (p[i])
|
||||
r++;
|
||||
}
|
||||
|
|
@ -6068,11 +6068,11 @@ namespace realclosure {
|
|||
|
||||
void display_poly(std::ostream & out, unsigned n, value * const * p) const {
|
||||
collect_algebraic_refs c;
|
||||
for (unsigned i = 0; i < n; i++)
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
c.mark(p[i]);
|
||||
display_polynomial(out, n, p, display_free_var_proc(), true, false);
|
||||
std::sort(c.m_found.begin(), c.m_found.end(), rank_lt_proc());
|
||||
for (unsigned i = 0; i < c.m_found.size(); i++) {
|
||||
for (unsigned i = 0; i < c.m_found.size(); ++i) {
|
||||
algebraic * ext = c.m_found[i];
|
||||
out << "\n r!" << ext->idx() << " := ";
|
||||
display_algebraic_def(out, ext, true, false);
|
||||
|
|
@ -6131,7 +6131,7 @@ namespace realclosure {
|
|||
std::sort(c.m_found.begin(), c.m_found.end(), rank_lt_proc());
|
||||
out << "[";
|
||||
display(out, a, true, pp);
|
||||
for (unsigned i = 0; i < c.m_found.size(); i++) {
|
||||
for (unsigned i = 0; i < c.m_found.size(); ++i) {
|
||||
algebraic * ext = c.m_found[i];
|
||||
if (pp)
|
||||
out << "; α<sub>" << ext->idx() << "</sub> := ";
|
||||
|
|
@ -6502,12 +6502,12 @@ void pp(realclosure::manager::imp * imp, realclosure::value * v) {
|
|||
}
|
||||
|
||||
void pp(realclosure::manager::imp * imp, unsigned sz, realclosure::value * const * p) {
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
pp(imp, p[i]);
|
||||
}
|
||||
|
||||
void pp(realclosure::manager::imp * imp, realclosure::manager::imp::value_ref_buffer const & p) {
|
||||
for (unsigned i = 0; i < p.size(); i++)
|
||||
for (unsigned i = 0; i < p.size(); ++i)
|
||||
pp(imp, p[i]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace simplex {
|
|||
unsigned i = 0;
|
||||
unsigned j = 0;
|
||||
unsigned sz = m_entries.size();
|
||||
for (; i < sz; i++) {
|
||||
for (; i < sz; ++i) {
|
||||
_row_entry & t1 = m_entries[i];
|
||||
if (!t1.is_dead()) {
|
||||
if (i != j) {
|
||||
|
|
@ -178,7 +178,7 @@ namespace simplex {
|
|||
unsigned i = 0;
|
||||
unsigned j = 0;
|
||||
unsigned sz = m_entries.size();
|
||||
for (; i < sz; i++) {
|
||||
for (; i < sz; ++i) {
|
||||
col_entry & e1 = m_entries[i];
|
||||
if (!e1.is_dead()) {
|
||||
if (i != j) {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace subpaving {
|
|||
|
||||
var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override {
|
||||
m_as.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m_ctx.nm().set(m_as[i], as[i]);
|
||||
}
|
||||
m_ctx.nm().set(m_c, c);
|
||||
|
|
@ -110,7 +110,7 @@ namespace subpaving {
|
|||
var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override {
|
||||
try {
|
||||
m_as.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
int2mpf(as[i], m_as[i]);
|
||||
}
|
||||
int2mpf(c, m_c);
|
||||
|
|
@ -165,7 +165,7 @@ namespace subpaving {
|
|||
var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override {
|
||||
try {
|
||||
m_as.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
int2hwf(as[i], m_as[i]);
|
||||
}
|
||||
int2hwf(c, m_c);
|
||||
|
|
@ -221,7 +221,7 @@ namespace subpaving {
|
|||
var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override {
|
||||
try {
|
||||
m_as.reserve(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
int2fpoint(as[i], m_as[i]);
|
||||
}
|
||||
int2fpoint(c, m_c);
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public:
|
|||
nm.set(penalty, m_penalty);
|
||||
nm.set(one, 1);
|
||||
unsigned num = this->ctx()->num_vars();
|
||||
for (var x = 0; x < num; x++) {
|
||||
for (var x = 0; x < num; ++x) {
|
||||
if (m_only_non_def && this->ctx()->is_definition(x))
|
||||
continue;
|
||||
typename context_t<C>::bound * l = n->lower(x);
|
||||
|
|
@ -283,7 +283,7 @@ void context_t<C>::bound::display(std::ostream & out, numeral_manager & nm, disp
|
|||
|
||||
template<typename C>
|
||||
void context_t<C>::clause::display(std::ostream & out, numeral_manager & nm, display_var_proc const & proc) {
|
||||
for (unsigned i = 0; i < size(); i++) {
|
||||
for (unsigned i = 0; i < size(); ++i) {
|
||||
if (i > 0)
|
||||
out << " or ";
|
||||
m_atoms[i]->display(out, nm, proc);
|
||||
|
|
@ -305,7 +305,7 @@ context_t<C>::node::node(context_t & s, unsigned id):
|
|||
m_next = nullptr;
|
||||
bm().mk(m_lowers);
|
||||
bm().mk(m_uppers);
|
||||
for (unsigned i = 0; i < num_vars; i++) {
|
||||
for (unsigned i = 0; i < num_vars; ++i) {
|
||||
bm().push_back(m_lowers, nullptr);
|
||||
bm().push_back(m_uppers, nullptr);
|
||||
}
|
||||
|
|
@ -378,7 +378,7 @@ context_t<C>::monomial::monomial(unsigned sz, power const * pws):
|
|||
template<typename C>
|
||||
void context_t<C>::monomial::display(std::ostream & out, display_var_proc const & proc, bool use_star) const {
|
||||
SASSERT(m_size > 0);
|
||||
for (unsigned i = 0; i < m_size; i++) {
|
||||
for (unsigned i = 0; i < m_size; ++i) {
|
||||
if (i > 0) {
|
||||
if (use_star)
|
||||
out << "*";
|
||||
|
|
@ -399,7 +399,7 @@ void context_t<C>::polynomial::display(std::ostream & out, numeral_manager & nm,
|
|||
first = false;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < m_size; i++) {
|
||||
for (unsigned i = 0; i < m_size; ++i) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
|
|
@ -637,7 +637,7 @@ void context_t<C>::display(std::ostream & out, constraint * c, bool use_star) co
|
|||
template<typename C>
|
||||
void context_t<C>::display_bounds(std::ostream & out, node * n) const {
|
||||
unsigned num = num_vars();
|
||||
for (unsigned x = 0; x < num; x++) {
|
||||
for (unsigned x = 0; x < num; ++x) {
|
||||
bound * l = n->lower(x);
|
||||
bound * u = n->upper(x);
|
||||
if (l != nullptr) {
|
||||
|
|
@ -657,7 +657,7 @@ void context_t<C>::display_bounds(std::ostream & out, node * n) const {
|
|||
*/
|
||||
template<typename C>
|
||||
bool context_t<C>::is_int(monomial const * m) const {
|
||||
for (unsigned i = 0; i < m->size(); i++) {
|
||||
for (unsigned i = 0; i < m->size(); ++i) {
|
||||
if (is_int(m->x(i)))
|
||||
return true;
|
||||
}
|
||||
|
|
@ -669,7 +669,7 @@ bool context_t<C>::is_int(monomial const * m) const {
|
|||
*/
|
||||
template<typename C>
|
||||
bool context_t<C>::is_int(polynomial const * p) const {
|
||||
for (unsigned i = 0; i < p->size(); i++) {
|
||||
for (unsigned i = 0; i < p->size(); ++i) {
|
||||
if (!is_int(p->x(i)) || !nm().is_int(p->a(i))) {
|
||||
TRACE(subpaving_is_int, tout << "polynomial is not integer due to monomial at i: " << i << "\n"; tout.flush();
|
||||
display(tout, p->x(i)); tout << " "; nm().display(tout, p->a(i)); tout << "\n";);
|
||||
|
|
@ -703,7 +703,7 @@ var context_t<C>::mk_monomial(unsigned sz, power const * pws) {
|
|||
m_pws.append(sz, pws);
|
||||
std::sort(m_pws.begin(), m_pws.end(), power::lt_proc());
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 1; i < sz; i++) {
|
||||
for (unsigned i = 1; i < sz; ++i) {
|
||||
if (m_pws[j].x() == m_pws[i].x()) {
|
||||
m_pws[j].degree() += m_pws[i].degree();
|
||||
}
|
||||
|
|
@ -720,7 +720,7 @@ var context_t<C>::mk_monomial(unsigned sz, power const * pws) {
|
|||
monomial * r = new (mem) monomial(sz, pws);
|
||||
var new_var = mk_var(is_int(r));
|
||||
m_defs[new_var] = r;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = pws[i].x();
|
||||
m_wlist[x].push_back(watched(new_var));
|
||||
}
|
||||
|
|
@ -731,7 +731,7 @@ template<typename C>
|
|||
void context_t<C>::del_sum(polynomial * p) {
|
||||
unsigned sz = p->size();
|
||||
unsigned mem_sz = polynomial::get_obj_size(sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
nm().del(p->m_as[i]);
|
||||
}
|
||||
nm().del(p->m_c);
|
||||
|
|
@ -742,7 +742,7 @@ void context_t<C>::del_sum(polynomial * p) {
|
|||
template<typename C>
|
||||
var context_t<C>::mk_sum(numeral const & c, unsigned sz, numeral const * as, var const * xs) {
|
||||
m_num_buffer.reserve(num_vars());
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
SASSERT(xs[i] < num_vars());
|
||||
nm().set(m_num_buffer[xs[i]], as[i]);
|
||||
}
|
||||
|
|
@ -755,7 +755,7 @@ var context_t<C>::mk_sum(numeral const & c, unsigned sz, numeral const * as, var
|
|||
p->m_xs = reinterpret_cast<var*>(reinterpret_cast<char*>(p->m_as) + sizeof(numeral)*sz);
|
||||
memcpy(p->m_xs, xs, sizeof(var)*sz);
|
||||
std::sort(p->m_xs, p->m_xs+sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
numeral * curr = p->m_as + i;
|
||||
new (curr) numeral();
|
||||
var x = p->m_xs[i];
|
||||
|
|
@ -763,7 +763,7 @@ var context_t<C>::mk_sum(numeral const & c, unsigned sz, numeral const * as, var
|
|||
}
|
||||
TRACE(subpaving_mk_sum, tout << "new variable is integer: " << is_int(p) << "\n";);
|
||||
var new_var = mk_var(is_int(p));
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = p->m_xs[i];
|
||||
m_wlist[x].push_back(watched(new_var));
|
||||
}
|
||||
|
|
@ -819,13 +819,13 @@ void context_t<C>::add_clause_core(unsigned sz, ineq * const * atoms, bool lemma
|
|||
void * mem = allocator().allocate(clause::get_obj_size(sz));
|
||||
clause * c = new (mem) clause();
|
||||
c->m_size = sz;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
inc_ref(atoms[i]);
|
||||
c->m_atoms[i] = atoms[i];
|
||||
}
|
||||
std::stable_sort(c->m_atoms, c->m_atoms + sz, typename ineq::lt_var_proc());
|
||||
if (watch) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = c->m_atoms[i]->x();
|
||||
if (x != null_var && (i == 0 || x != c->m_atoms[i-1]->x()))
|
||||
m_wlist[x].push_back(watched(c));
|
||||
|
|
@ -849,7 +849,7 @@ void context_t<C>::del_clause(clause * c) {
|
|||
bool watch = c->watched();
|
||||
var prev_x = null_var;
|
||||
unsigned sz = c->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = c->m_atoms[i]->x();
|
||||
if (watch) {
|
||||
if (x != prev_x)
|
||||
|
|
@ -1092,7 +1092,7 @@ void context_t<C>::collect_leaves(ptr_vector<node> & leaves) const {
|
|||
template<typename C>
|
||||
void context_t<C>::del_unit_clauses() {
|
||||
unsigned sz = m_unit_clauses.size();
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
dec_ref(UNTAG(ineq*, m_unit_clauses[i]));
|
||||
m_unit_clauses.reset();
|
||||
}
|
||||
|
|
@ -1100,7 +1100,7 @@ void context_t<C>::del_unit_clauses() {
|
|||
template<typename C>
|
||||
void context_t<C>::del_clauses(ptr_vector<clause> & cs) {
|
||||
unsigned sz = cs.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
del_clause(cs[i]);
|
||||
}
|
||||
cs.reset();
|
||||
|
|
@ -1115,7 +1115,7 @@ void context_t<C>::del_clauses() {
|
|||
template<typename C>
|
||||
void context_t<C>::del_definitions() {
|
||||
unsigned sz = num_vars();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
definition * d = m_defs[i];
|
||||
if (d == nullptr)
|
||||
continue;
|
||||
|
|
@ -1136,7 +1136,7 @@ void context_t<C>::del_definitions() {
|
|||
template<typename C>
|
||||
void context_t<C>::display_constraints(std::ostream & out, bool use_star) const {
|
||||
// display definitions
|
||||
for (unsigned i = 0; i < num_vars(); i++) {
|
||||
for (unsigned i = 0; i < num_vars(); ++i) {
|
||||
if (is_definition(i)) {
|
||||
(*m_display_proc)(out, i);
|
||||
out << " = ";
|
||||
|
|
@ -1145,12 +1145,12 @@ void context_t<C>::display_constraints(std::ostream & out, bool use_star) const
|
|||
}
|
||||
}
|
||||
// display units
|
||||
for (unsigned i = 0; i < m_unit_clauses.size(); i++) {
|
||||
for (unsigned i = 0; i < m_unit_clauses.size(); ++i) {
|
||||
ineq * a = UNTAG(ineq*, m_unit_clauses[i]);
|
||||
a->display(out, nm(), *m_display_proc); out << "\n";
|
||||
}
|
||||
// display clauses
|
||||
for (unsigned i = 0; i < m_clauses.size(); i++) {
|
||||
for (unsigned i = 0; i < m_clauses.size(); ++i) {
|
||||
m_clauses[i]->display(out, nm(), *m_display_proc); out << "\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -1380,7 +1380,7 @@ void context_t<C>::propagate_clause(clause * c, node * n) {
|
|||
c->set_visited(m_timestamp);
|
||||
unsigned sz = c->size();
|
||||
unsigned j = UINT_MAX;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
ineq * atom = (*c)[i];
|
||||
switch (value(atom, n)) {
|
||||
case l_true:
|
||||
|
|
@ -1416,7 +1416,7 @@ void context_t<C>::propagate_polynomial(var x, node * n, var y) {
|
|||
interval & v = m_i_tmp2;
|
||||
interval & av = m_i_tmp3; av.set_mutable();
|
||||
if (x == y) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var z = p->x(i);
|
||||
v.set_constant(n, z);
|
||||
im().mul(p->a(i), v, av);
|
||||
|
|
@ -1431,7 +1431,7 @@ void context_t<C>::propagate_polynomial(var x, node * n, var y) {
|
|||
v.set_constant(n, x);
|
||||
numeral & a = m_tmp1;
|
||||
im().set(r, v);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var z = p->x(i);
|
||||
if (z != y) {
|
||||
v.set_constant(n, z);
|
||||
|
|
@ -1475,7 +1475,7 @@ void context_t<C>::propagate_polynomial(var x, node * n) {
|
|||
if (is_unbounded(x, n))
|
||||
unbounded_var = x;
|
||||
unsigned sz = p->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var y = p->x(i);
|
||||
if (is_unbounded(y, n)) {
|
||||
if (unbounded_var != null_var)
|
||||
|
|
@ -1490,7 +1490,7 @@ void context_t<C>::propagate_polynomial(var x, node * n) {
|
|||
}
|
||||
else {
|
||||
propagate_polynomial(x, n, x);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (inconsistent(n))
|
||||
return;
|
||||
propagate_polynomial(x, n, p->x(i));
|
||||
|
|
@ -1509,7 +1509,7 @@ void context_t<C>::propagate_monomial(var x, node * n) {
|
|||
bool found_zero = false;
|
||||
bool x_is_unbounded = false;
|
||||
unsigned sz = m->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var y = m->x(i);
|
||||
if (is_zero(y, n)) {
|
||||
found_zero = true;
|
||||
|
|
@ -1546,7 +1546,7 @@ void context_t<C>::propagate_monomial(var x, node * n) {
|
|||
if (!x_is_unbounded) {
|
||||
unsigned bad_pos = UINT_MAX;
|
||||
interval & aux = m_i_tmp1;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
aux.set_constant(n, m->x(i));
|
||||
if (im().contains_zero(aux)) {
|
||||
if (bad_pos != UINT_MAX)
|
||||
|
|
@ -1556,7 +1556,7 @@ void context_t<C>::propagate_monomial(var x, node * n) {
|
|||
}
|
||||
if (bad_pos == UINT_MAX) {
|
||||
// we can use all variables for downward propagation.
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (inconsistent(n))
|
||||
return;
|
||||
propagate_monomial_downward(x, n, i);
|
||||
|
|
@ -1576,7 +1576,7 @@ void context_t<C>::propagate_monomial_upward(var x, node * n) {
|
|||
interval & r = m_i_tmp1; r.set_mutable();
|
||||
interval & y = m_i_tmp2;
|
||||
interval & yk = m_i_tmp3; yk.set_mutable();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
y.set_constant(n, m->x(i));
|
||||
im().power(y, m->degree(i), yk);
|
||||
if (i == 0)
|
||||
|
|
@ -1615,7 +1615,7 @@ void context_t<C>::propagate_monomial_downward(var x, node * n, unsigned j) {
|
|||
interval & y = m_i_tmp2;
|
||||
interval & yk = m_i_tmp3; yk.set_mutable();
|
||||
bool first = true;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (i == j)
|
||||
continue;
|
||||
y.set_constant(n, m->x(i));
|
||||
|
|
@ -1765,7 +1765,7 @@ void context_t<C>::propagate(node * n) {
|
|||
template<typename C>
|
||||
void context_t<C>::propagate_all_definitions(node * n) {
|
||||
unsigned num = num_vars();
|
||||
for (unsigned x = 0; x < num; x++) {
|
||||
for (unsigned x = 0; x < num; ++x) {
|
||||
if (inconsistent(n))
|
||||
break;
|
||||
if (is_definition(x))
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ struct expr2subpaving::imp {
|
|||
scoped_mpz n_arg(qm());
|
||||
scoped_mpz d_arg(qm());
|
||||
sbuffer<subpaving::power> pws;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
expr * arg = margs[i];
|
||||
unsigned k;
|
||||
as_power(arg, arg, k);
|
||||
|
|
@ -227,7 +227,7 @@ struct expr2subpaving::imp {
|
|||
var_buffer xs;
|
||||
scoped_mpq c(qm()), c_arg(qm());
|
||||
scoped_mpz n_arg(qm()), d_arg(qm());
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
expr * arg = t->get_arg(i);
|
||||
subpaving::var x_arg = process(arg, depth+1, n_arg, d_arg);
|
||||
if (x_arg == subpaving::null_var) {
|
||||
|
|
@ -242,14 +242,14 @@ struct expr2subpaving::imp {
|
|||
}
|
||||
qm().set(d, c.get().denominator());
|
||||
unsigned sz = xs.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
qm().lcm(d, ds[i], d);
|
||||
}
|
||||
scoped_mpz & k = d_arg;
|
||||
qm().div(d, c.get().denominator(), k);
|
||||
scoped_mpz sum_c(qm());
|
||||
qm().mul(c.get().numerator(), k, sum_c);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
qm().div(d, ds[i], k);
|
||||
qm().mul(ns[i], k, ns[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class subpaving_tactic : public tactic {
|
|||
sz = 1;
|
||||
}
|
||||
ref_buffer<subpaving::ineq, subpaving::context> ineq_buffer(*m_ctx);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
ineq_buffer.push_back(mk_ineq(args[i]));
|
||||
}
|
||||
m_ctx->add_clause(sz, ineq_buffer.data());
|
||||
|
|
@ -178,7 +178,7 @@ class subpaving_tactic : public tactic {
|
|||
|
||||
void internalize(goal const & g) {
|
||||
try {
|
||||
for (unsigned i = 0; i < g.size(); i++) {
|
||||
for (unsigned i = 0; i < g.size(); ++i) {
|
||||
process_clause(g.form(i));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue