mirror of
https://github.com/Z3Prover/z3
synced 2026-02-10 11:00:52 +00:00
do not refactor again multivariate polynomials
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
3db21b90f3
commit
aa6dae8f5f
2 changed files with 24 additions and 44 deletions
|
|
@ -23,33 +23,7 @@ namespace nlsat {
|
|||
*/
|
||||
void factor(polynomial_ref & p, polynomial::cache& cache, polynomial_ref_vector & fs) {
|
||||
TRACE(nlsat_factor, tout << "factor\n" << p << "\n";);
|
||||
fs.reset();
|
||||
// Use a todo list to iteratively factor polynomials until every
|
||||
// polynomial in fs is irreducible (cache.factor returns a single factor).
|
||||
// Start with the input polynomial on the queue.
|
||||
polynomial_ref_vector todo(fs.m());
|
||||
todo.push_back(p.get());
|
||||
for (unsigned idx = 0; idx < todo.size(); ++idx) {
|
||||
polynomial_ref_vector tmp(fs.m());
|
||||
polynomial_ref cur_ref(todo.get(idx), fs.m());
|
||||
cache.factor(cur_ref.get(), tmp);
|
||||
if (tmp.size() == 1) {
|
||||
// single factor -> consider it irreducible and add to output
|
||||
fs.push_back(tmp.get(0));
|
||||
}
|
||||
else {
|
||||
// Only multivariate factors are queued for further factoring.
|
||||
// Univariate factors are considered final and pushed directly to the output vector `fs`.
|
||||
for (unsigned i = 0; i < tmp.size(); ++i) {
|
||||
if (polynomial::manager::is_univariate(tmp.get(i)))
|
||||
fs.push_back(tmp.get(i));
|
||||
else
|
||||
todo.push_back(tmp.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
TRACE(nlsat_factor, tout << fs.size() << " factors:\n";
|
||||
::nlsat::display(tout, fs.m(), fs, polynomial::display_var_proc()) << "\n";
|
||||
);
|
||||
fs.reset();
|
||||
cache.factor(p.get(), fs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue