mirror of
https://github.com/Z3Prover/z3
synced 2025-07-23 12:48:53 +00:00
tidy
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
7387fc9dec
commit
180fb3abf6
1 changed files with 49 additions and 68 deletions
|
@ -88,12 +88,10 @@ static_matrix<T, X>::static_matrix(static_matrix const &A, unsigned * /* basis *
|
||||||
m_vector_of_row_offsets(A.column_count(), numeric_traits<T>::zero()) {
|
m_vector_of_row_offsets(A.column_count(), numeric_traits<T>::zero()) {
|
||||||
unsigned m = A.row_count();
|
unsigned m = A.row_count();
|
||||||
init_row_columns(m, m);
|
init_row_columns(m, m);
|
||||||
while (m--) {
|
for (; m-- > 0; )
|
||||||
for (auto & col : A.m_columns[m]){
|
for (auto & col : A.m_columns[m])
|
||||||
set(col.var(), m, A.get_value_of_column_cell(col));
|
set(col.var(), m, A.get_value_of_column_cell(col));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename X> void static_matrix<T, X>::clear() {
|
template <typename T, typename X> void static_matrix<T, X>::clear() {
|
||||||
m_vector_of_row_offsets.clear();
|
m_vector_of_row_offsets.clear();
|
||||||
|
@ -132,7 +130,7 @@ template <typename T, typename X> void static_matrix<T, X>::add_columns_at_th
|
||||||
template <typename T, typename X> void static_matrix<T, X>::forget_last_columns(unsigned how_many_to_forget) {
|
template <typename T, typename X> void static_matrix<T, X>::forget_last_columns(unsigned how_many_to_forget) {
|
||||||
lp_assert(m_columns.size() >= how_many_to_forget);
|
lp_assert(m_columns.size() >= how_many_to_forget);
|
||||||
unsigned j = column_count() - 1;
|
unsigned j = column_count() - 1;
|
||||||
for (; how_many_to_forget > 0; how_many_to_forget--) {
|
for (; how_many_to_forget-- > 0; ) {
|
||||||
remove_last_column(j --);
|
remove_last_column(j --);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,15 +152,12 @@ template <typename T, typename X> void static_matrix<T, X>::remove_last_column(u
|
||||||
m_vector_of_row_offsets.pop_back();
|
m_vector_of_row_offsets.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename X> void static_matrix<T, X>::set(unsigned row, unsigned col, T const & val) {
|
template <typename T, typename X> void static_matrix<T, X>::set(unsigned row, unsigned col, T const & val) {
|
||||||
if (numeric_traits<T>::is_zero(val)) return;
|
if (numeric_traits<T>::is_zero(val)) return;
|
||||||
lp_assert(row < row_count() && col < column_count());
|
lp_assert(row < row_count() && col < column_count());
|
||||||
auto & r = m_rows[row];
|
auto & r = m_rows[row];
|
||||||
unsigned offs_in_cols = static_cast<unsigned>(m_columns[col].size());
|
unsigned offs_in_cols = m_columns[col].size();
|
||||||
m_columns[col].push_back(make_column_cell(row, static_cast<unsigned>(r.size())));
|
m_columns[col].push_back(make_column_cell(row, r.size()));
|
||||||
r.push_back(make_row_cell(col, offs_in_cols, val));
|
r.push_back(make_row_cell(col, offs_in_cols, val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,14 +165,13 @@ template <typename T, typename X>
|
||||||
std::set<std::pair<unsigned, unsigned>> static_matrix<T, X>::get_domain() {
|
std::set<std::pair<unsigned, unsigned>> static_matrix<T, X>::get_domain() {
|
||||||
std::set<std::pair<unsigned, unsigned>> ret;
|
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 &it : m_rows[i]) {
|
for (auto &cell : m_rows[i]) {
|
||||||
ret.insert(std::make_pair(i, it.var()));
|
ret.insert(std::make_pair(i, cell.var()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename X> void static_matrix<T, X>::copy_column_to_indexed_vector (unsigned j, indexed_vector<T> & v) const {
|
template <typename T, typename X> void static_matrix<T, X>::copy_column_to_indexed_vector (unsigned j, indexed_vector<T> & v) const {
|
||||||
lp_assert(j < m_columns.size());
|
lp_assert(j < m_columns.size());
|
||||||
for (auto & it : m_columns[j]) {
|
for (auto & it : m_columns[j]) {
|
||||||
|
@ -187,8 +181,6 @@ template <typename T, typename X> void static_matrix<T, X>::copy_column_to_in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename X> T static_matrix<T, X>::get_max_abs_in_row(unsigned row) const {
|
template <typename T, typename X> T static_matrix<T, X>::get_max_abs_in_row(unsigned row) const {
|
||||||
T ret = numeric_traits<T>::zero();
|
T ret = numeric_traits<T>::zero();
|
||||||
for (auto & t : m_rows[row]) {
|
for (auto & t : m_rows[row]) {
|
||||||
|
@ -245,7 +237,7 @@ template <typename T, typename X> T static_matrix<T, X>::get_min_abs_in_colu
|
||||||
#ifdef Z3DEBUG
|
#ifdef Z3DEBUG
|
||||||
template <typename T, typename X> void static_matrix<T, X>::check_consistency() {
|
template <typename T, typename X> void static_matrix<T, X>::check_consistency() {
|
||||||
std::unordered_map<std::pair<unsigned, unsigned>, T> by_rows;
|
std::unordered_map<std::pair<unsigned, unsigned>, T> by_rows;
|
||||||
for (int i = 0; i < m_rows.size(); i++){
|
for (unsigned i = 0; i < m_rows.size(); i++) {
|
||||||
for (auto & t : m_rows[i]) {
|
for (auto & t : m_rows[i]) {
|
||||||
std::pair<unsigned, unsigned> p(i, t.var());
|
std::pair<unsigned, unsigned> p(i, t.var());
|
||||||
lp_assert(by_rows.find(p) == by_rows.end());
|
lp_assert(by_rows.find(p) == by_rows.end());
|
||||||
|
@ -253,7 +245,7 @@ template <typename T, typename X> void static_matrix<T, X>::check_consistency
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::unordered_map<std::pair<unsigned, unsigned>, T> by_cols;
|
std::unordered_map<std::pair<unsigned, unsigned>, T> by_cols;
|
||||||
for (int i = 0; i < m_columns.size(); i++){
|
for (unsigned i = 0; i < m_columns.size(); i++) {
|
||||||
for (auto & t : m_columns[i]) {
|
for (auto & t : m_columns[i]) {
|
||||||
std::pair<unsigned, unsigned> p(t.var(), i);
|
std::pair<unsigned, unsigned> p(t.var(), i);
|
||||||
lp_assert(by_cols.find(p) == by_cols.end());
|
lp_assert(by_cols.find(p) == by_cols.end());
|
||||||
|
@ -284,16 +276,11 @@ template <typename T, typename X> void static_matrix<T, X>::cross_out_row(uns
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename X> void static_matrix<T, X>::fix_row_indices_in_each_column_for_crossed_row(unsigned k) {
|
template <typename T, typename X> void static_matrix<T, X>::fix_row_indices_in_each_column_for_crossed_row(unsigned k) {
|
||||||
for (unsigned j = 0; j < m_columns.size(); j++) {
|
for (auto & column : m_columns)
|
||||||
auto & col = m_columns[j];
|
for (auto& cell : column)
|
||||||
for (int i = 0; i < col.size(); i++) {
|
if (cell.var() > k)
|
||||||
if (col[i].var() > k) {
|
cell.var()--;
|
||||||
col[i].var()--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X> void static_matrix<T, X>::cross_out_row_from_columns(unsigned k, row_strip<T> & row) {
|
template <typename T, typename X> void static_matrix<T, X>::cross_out_row_from_columns(unsigned k, row_strip<T> & row) {
|
||||||
|
@ -321,7 +308,6 @@ template <typename T, typename X> T static_matrix<T, X>::get_elem(unsigned i,
|
||||||
return numeric_traits<T>::zero();
|
return numeric_traits<T>::zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename X> T static_matrix<T, X>::get_balance() const {
|
template <typename T, typename X> T static_matrix<T, X>::get_balance() const {
|
||||||
T ret = zero_of_type<T>();
|
T ret = zero_of_type<T>();
|
||||||
for (unsigned i = 0; i < row_count(); i++) {
|
for (unsigned i = 0; i < row_count(); i++) {
|
||||||
|
@ -342,13 +328,11 @@ template <typename T, typename X> T static_matrix<T, X>::get_row_balance(unsi
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X> bool static_matrix<T, X>::is_correct() const {
|
template <typename T, typename X> bool static_matrix<T, X>::is_correct() const {
|
||||||
for (unsigned i = 0; i < m_rows.size(); i++) {
|
for (auto & row : m_rows) {
|
||||||
auto &r = m_rows[i];
|
|
||||||
std::unordered_set<unsigned> s;
|
std::unordered_set<unsigned> s;
|
||||||
for (auto & rc : r) {
|
for (auto & rc : row) {
|
||||||
if (s.find(rc.var()) != s.end()) {
|
if (s.find(rc.var()) != s.end())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
s.insert(rc.var());
|
s.insert(rc.var());
|
||||||
if (rc.var() >= m_columns.size())
|
if (rc.var() >= m_columns.size())
|
||||||
return false;
|
return false;
|
||||||
|
@ -356,20 +340,16 @@ template <typename T, typename X> bool static_matrix<T, X>::is_correct() const {
|
||||||
return false;
|
return false;
|
||||||
if (rc.coeff() != get_val(m_columns[rc.var()][rc.offset()]))
|
if (rc.coeff() != get_val(m_columns[rc.var()][rc.offset()]))
|
||||||
return false;
|
return false;
|
||||||
if (is_zero(rc.coeff())) {
|
if (is_zero(rc.coeff()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned j = 0; j < m_columns.size(); j++) {
|
for (auto & column : m_columns) {
|
||||||
auto & c = m_columns[j];
|
|
||||||
std::unordered_set<unsigned> s;
|
std::unordered_set<unsigned> s;
|
||||||
for (auto & cc : c) {
|
for (auto & cc : column) {
|
||||||
if (s.find(cc.var()) != s.end()) {
|
if (s.find(cc.var()) != s.end())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
s.insert(cc.var());
|
s.insert(cc.var());
|
||||||
if (cc.var() >= m_rows.size())
|
if (cc.var() >= m_rows.size())
|
||||||
return false;
|
return false;
|
||||||
|
@ -401,12 +381,13 @@ void static_matrix<T, X>::remove_element(vector<row_cell<T>> & row_vals, row_cel
|
||||||
column_vals.pop_back();
|
column_vals.pop_back();
|
||||||
row_vals.pop_back();
|
row_vals.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X>
|
template <typename T, typename X>
|
||||||
void static_matrix<T, X>::add_new_element(unsigned row, unsigned col, const T& val) {
|
void static_matrix<T, X>::add_new_element(unsigned row, unsigned col, const T& val) {
|
||||||
auto & row_vals = m_rows[row];
|
auto & row_vals = m_rows[row];
|
||||||
auto & col_vals = m_columns[col];
|
auto & col_vals = m_columns[col];
|
||||||
unsigned row_el_offs = static_cast<unsigned>(row_vals.size());
|
unsigned row_el_offs = row_vals.size();
|
||||||
unsigned col_el_offs = static_cast<unsigned>(col_vals.size());
|
unsigned col_el_offs = col_vals.size();
|
||||||
row_vals.push_back(row_cell<T>(col, col_el_offs, val));
|
row_vals.push_back(row_cell<T>(col, col_el_offs, val));
|
||||||
col_vals.push_back(column_cell(row, row_el_offs));
|
col_vals.push_back(column_cell(row, row_el_offs));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue