3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-02 05:16:08 +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:
Copilot 2026-01-14 19:55:31 -08:00 committed by Nikolaj Bjorner
parent 851b8ea31c
commit 317dd92105
475 changed files with 3237 additions and 3237 deletions

View file

@ -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))

View file

@ -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*> &copy, 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];
}

View file

@ -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);

View file

@ -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));

View file

@ -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) {

View file

@ -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++;

View file

@ -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

View file

@ -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;

View file

@ -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();

View file

@ -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;

View file

@ -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++;

View file

@ -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;

View file

@ -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;

View file

@ -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();
);

View file

@ -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;

View file

@ -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++;

View file

@ -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; }

View file

@ -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))

View file

@ -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))

View file

@ -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);

View file

@ -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;
}

View file

@ -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;

View file

@ -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]));
}

View file

@ -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;

View file

@ -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)

View file

@ -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);
}
}

View file

@ -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 {

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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));
}

View file

@ -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)));
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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";);

View file

@ -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()) {

View file

@ -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;
}

View file

@ -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);

View file

@ -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)) {

View file

@ -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]);
}

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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 << ",";

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
}
}