mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
patch for Sturm sequence bug #4961
This commit is contained in:
parent
2d1684bc2d
commit
7d60d8462d
4 changed files with 124 additions and 114 deletions
|
@ -57,9 +57,8 @@ mpbq_manager::~mpbq_manager() {
|
|||
}
|
||||
|
||||
void mpbq_manager::reset(mpbq_vector & v) {
|
||||
unsigned sz = v.size();
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
reset(v[i]);
|
||||
for (auto & e : v)
|
||||
reset(e);
|
||||
v.reset();
|
||||
}
|
||||
|
||||
|
@ -391,23 +390,25 @@ std::string mpbq_manager::to_string(mpbq const & a) {
|
|||
return buffer.str();
|
||||
}
|
||||
|
||||
void mpbq_manager::display(std::ostream & out, mpbq const & a) {
|
||||
std::ostream& mpbq_manager::display(std::ostream & out, mpbq const & a) {
|
||||
out << m_manager.to_string(a.m_num);
|
||||
if (a.m_k > 0)
|
||||
out << "/2";
|
||||
if (a.m_k > 1)
|
||||
out << "^" << a.m_k;
|
||||
return out;
|
||||
}
|
||||
|
||||
void mpbq_manager::display_pp(std::ostream & out, mpbq const & a) {
|
||||
std::ostream& mpbq_manager::display_pp(std::ostream & out, mpbq const & a) {
|
||||
out << m_manager.to_string(a.m_num);
|
||||
if (a.m_k > 0)
|
||||
out << "/2";
|
||||
if (a.m_k > 1)
|
||||
out << "<sup>" << a.m_k << "</sup>";
|
||||
return out;
|
||||
}
|
||||
|
||||
void mpbq_manager::display_smt2(std::ostream & out, mpbq const & a, bool decimal) {
|
||||
std::ostream& mpbq_manager::display_smt2(std::ostream & out, mpbq const & a, bool decimal) {
|
||||
if (a.m_k == 0) {
|
||||
m_manager.display_smt2(out, a.m_num, decimal);
|
||||
}
|
||||
|
@ -421,12 +422,12 @@ void mpbq_manager::display_smt2(std::ostream & out, mpbq const & a, bool decimal
|
|||
if (decimal) out << ".0";
|
||||
out << "))";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void mpbq_manager::display_decimal(std::ostream & out, mpbq const & a, unsigned prec) {
|
||||
std::ostream& mpbq_manager::display_decimal(std::ostream & out, mpbq const & a, unsigned prec) {
|
||||
if (is_int(a)) {
|
||||
out << m_manager.to_string(a.m_num);
|
||||
return;
|
||||
return out << m_manager.to_string(a.m_num);
|
||||
}
|
||||
mpz two(2);
|
||||
mpz ten(10);
|
||||
|
@ -455,17 +456,16 @@ void mpbq_manager::display_decimal(std::ostream & out, mpbq const & a, unsigned
|
|||
m_manager.del(n1);
|
||||
m_manager.del(v1);
|
||||
m_manager.del(two_k);
|
||||
return out;
|
||||
}
|
||||
|
||||
void mpbq_manager::display_decimal(std::ostream & out, mpbq const & a, mpbq const & b, unsigned prec) {
|
||||
std::ostream& mpbq_manager::display_decimal(std::ostream & out, mpbq const & a, mpbq const & b, unsigned prec) {
|
||||
mpz two(2);
|
||||
mpz ten(10);
|
||||
mpz two_k1, two_k2;
|
||||
mpz n1, v1, n2, v2;
|
||||
if (m_manager.is_neg(a.m_num) != m_manager.is_neg(b.m_num)) {
|
||||
out << "?";
|
||||
return;
|
||||
}
|
||||
if (m_manager.is_neg(a.m_num) != m_manager.is_neg(b.m_num))
|
||||
return out << "?";
|
||||
if (m_manager.is_neg(a.m_num))
|
||||
out << "-";
|
||||
m_manager.set(v1, a.m_num);
|
||||
|
@ -512,6 +512,7 @@ void mpbq_manager::display_decimal(std::ostream & out, mpbq const & a, mpbq cons
|
|||
m_manager.del(v2);
|
||||
m_manager.del(two_k1);
|
||||
m_manager.del(two_k2);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool mpbq_manager::to_mpbq(mpq const & q, mpbq & bq) {
|
||||
|
|
|
@ -258,17 +258,17 @@ public:
|
|||
void select_small_core(unsynch_mpq_manager & qm, mpq const & lower, mpq const & upper, mpbq & r);
|
||||
|
||||
|
||||
void display(std::ostream & out, mpbq const & a);
|
||||
void display_pp(std::ostream & out, mpbq const & a);
|
||||
void display_decimal(std::ostream & out, mpbq const & a, unsigned prec = 8);
|
||||
std::ostream& display(std::ostream & out, mpbq const & a);
|
||||
std::ostream& display_pp(std::ostream & out, mpbq const & a);
|
||||
std::ostream& display_decimal(std::ostream & out, mpbq const & a, unsigned prec = 8);
|
||||
/**
|
||||
\brief Display a in decimal while its digits match b digits.
|
||||
This function is useful when a and b are representing an interval [a,b] which
|
||||
contains an algebraic number
|
||||
*/
|
||||
void display_decimal(std::ostream & out, mpbq const & a, mpbq const & b, unsigned prec);
|
||||
std::ostream& display_decimal(std::ostream & out, mpbq const & a, mpbq const & b, unsigned prec);
|
||||
|
||||
void display_smt2(std::ostream & out, mpbq const & a, bool decimal);
|
||||
std::ostream& display_smt2(std::ostream & out, mpbq const & a, bool decimal);
|
||||
|
||||
/**
|
||||
\brief Approximate n as b/2^k' s.t. k' <= k.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue