3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-03 21:01:22 +00:00

Add non naive sign determination algorithm

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-01-09 22:35:39 -08:00
parent 1712f0a33b
commit d644b37ac1
3 changed files with 708 additions and 42 deletions

View file

@ -349,8 +349,8 @@ void mpz_matrix_manager::permute_rows(mpz_matrix const & A, unsigned const * p,
B.swap(C); B.swap(C);
} }
void mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsigned_vector & r) { unsigned mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsigned * r) {
r.reset(); unsigned r_sz = 0;
scoped_mpz_matrix A(*this); scoped_mpz_matrix A(*this);
scoped_mpz g(nm()); scoped_mpz g(nm());
scoped_mpz t1(nm()), t2(nm()); scoped_mpz t1(nm()), t2(nm());
@ -381,13 +381,15 @@ void mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsigned
swap_rows(A, k1, pivot); swap_rows(A, k1, pivot);
std::swap(rows[k1], rows[pivot]); std::swap(rows[k1], rows[pivot]);
// //
r.push_back(rows[k1]); r[r_sz] = rows[k1];
if (r.size() >= A.n()) r_sz++;
if (r_sz >= A.n())
break; break;
eliminate(A, 0, k1, k2, false); eliminate(A, 0, k1, k2, false);
k2++; k2++;
} }
std::sort(r.begin(), r.end()); std::sort(r, r + r_sz);
return r_sz;
} }
void mpz_matrix_manager::display(std::ostream & out, mpz_matrix const & A, unsigned cell_width) const { void mpz_matrix_manager::display(std::ostream & out, mpz_matrix const & A, unsigned cell_width) const {

View file

@ -105,8 +105,11 @@ public:
\remark If there is an option between rows i and j, \remark If there is an option between rows i and j,
this method will give preference to the row that occurs first. this method will give preference to the row that occurs first.
\remark The vector r must have at least A.n() capacity
The numer of linear independent rows is returned.
*/ */
void linear_independent_rows(mpz_matrix const & A, unsigned_vector & r); unsigned linear_independent_rows(mpz_matrix const & A, unsigned * r);
// method for debugging purposes // method for debugging purposes
void display(std::ostream & out, mpz_matrix const & A, unsigned cell_width=4) const; void display(std::ostream & out, mpz_matrix const & A, unsigned cell_width=4) const;

File diff suppressed because it is too large Load diff