mirror of
https://github.com/Z3Prover/z3
synced 2025-08-26 13:06:05 +00:00
Centralize and document TRACE tags using X-macros (#7657)
* Introduce X-macro-based trace tag definition - Created trace_tags.def to centralize TRACE tag definitions - Each tag includes a symbolic name and description - Set up enum class TraceTag for type-safe usage in TRACE macros * Add script to generate Markdown documentation from trace_tags.def - Python script parses trace_tags.def and outputs trace_tags.md * Refactor TRACE_NEW to prepend TraceTag and pass enum to is_trace_enabled * trace: improve trace tag handling system with hierarchical tagging - Introduce hierarchical tag-class structure: enabling a tag class activates all child tags - Unify TRACE, STRACE, SCTRACE, and CTRACE under enum TraceTag - Implement initial version of trace_tag.def using X(tag, tag_class, description) (class names and descriptions to be refined in a future update) * trace: replace all string-based TRACE tags with enum TraceTag - Migrated all TRACE, STRACE, SCTRACE, and CTRACE macros to use enum TraceTag values instead of raw string literals * trace : add cstring header * trace : Add Markdown documentation generation from trace_tags.def via mk_api_doc.py * trace : rename macro parameter 'class' to 'tag_class' and remove Unicode comment in trace_tags.h. * trace : Add TODO comment for future implementation of tag_class activation * trace : Disable code related to tag_class until implementation is ready (#7663).
This commit is contained in:
parent
d766292dab
commit
0a93ff515d
583 changed files with 8698 additions and 7299 deletions
|
@ -40,7 +40,7 @@ void bit_vector::resize(unsigned new_size, bool val) {
|
|||
return;
|
||||
}
|
||||
|
||||
TRACE("bit_vector", tout << "expanding: " << new_size << " capacity: " << m_capacity << " num words: "
|
||||
TRACE(bit_vector, tout << "expanding: " << new_size << " capacity: " << m_capacity << " num words: "
|
||||
<< num_words(new_size) << "\n";);
|
||||
|
||||
if (num_words(new_size) > m_capacity) {
|
||||
|
@ -64,7 +64,7 @@ void bit_vector::resize(unsigned new_size, bool val) {
|
|||
cval = 0;
|
||||
}
|
||||
|
||||
TRACE("bit_vector",
|
||||
TRACE(bit_vector,
|
||||
tout << "num_bits: " << m_num_bits << "\n";
|
||||
tout << "bwidx: " << bwidx << "\n";
|
||||
tout << "ewidx: " << ewidx << "\n";
|
||||
|
|
|
@ -89,7 +89,7 @@ protected:
|
|||
cell * copy_table(cell * source, unsigned source_slots, unsigned source_capacity,
|
||||
cell * target, unsigned target_slots, unsigned target_capacity,
|
||||
unsigned & used_slots) {
|
||||
TRACE("chashtable", tout << "copy_table...\n";);
|
||||
TRACE(chashtable, tout << "copy_table...\n";);
|
||||
SASSERT(target_slots >= source_slots);
|
||||
SASSERT(target_capacity >= source_capacity);
|
||||
unsigned target_mask = target_slots - 1;
|
||||
|
@ -129,7 +129,7 @@ protected:
|
|||
}
|
||||
}
|
||||
#if 0
|
||||
TRACE("chashtable",
|
||||
TRACE(chashtable,
|
||||
for (unsigned i = 0; i < source_capacity; i++) {
|
||||
tout << i << ":[";
|
||||
if (source[i].m_next == 0)
|
||||
|
|
|
@ -612,7 +612,7 @@ void gparams::reset() {
|
|||
}
|
||||
|
||||
void gparams::set(char const * name, char const * value) {
|
||||
TRACE("gparams", tout << "setting [" << name << "] <- '" << value << "'\n";);
|
||||
TRACE(gparams, tout << "setting [" << name << "] <- '" << value << "'\n";);
|
||||
SASSERT(g_imp);
|
||||
g_imp->set(name, value);
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ params_ref gparams::get_module(char const * module_name) {
|
|||
|
||||
|
||||
params_ref const& gparams::get_ref() {
|
||||
TRACE("gparams", tout << "gparams::get_ref()\n";);
|
||||
TRACE(gparams, tout << "gparams::get_ref()\n";);
|
||||
SASSERT(g_imp);
|
||||
return g_imp->get_ref();
|
||||
}
|
||||
|
@ -689,13 +689,13 @@ void gparams::display_parameter(std::ostream & out, char const * name) {
|
|||
}
|
||||
|
||||
void gparams::init() {
|
||||
TRACE("gparams", tout << "gparams::init()\n";);
|
||||
TRACE(gparams, tout << "gparams::init()\n";);
|
||||
ALLOC_MUTEX(gparams_mux);
|
||||
g_imp = alloc(imp);
|
||||
}
|
||||
|
||||
void gparams::finalize() {
|
||||
TRACE("gparams", tout << "gparams::finalize()\n";);
|
||||
TRACE(gparams, tout << "gparams::finalize()\n";);
|
||||
dealloc(g_imp);
|
||||
DEALLOC_MUTEX(gparams_mux);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ void hwf_manager::set(hwf & o, mpf_rounding_mode rm, char const * value) {
|
|||
f = (e_pos != std::string::npos) ? v.substr(0, e_pos) : v;
|
||||
e = (e_pos != std::string::npos) ? v.substr(e_pos+1) : "0";
|
||||
|
||||
TRACE("mpf_dbg", tout << " f = " << f << " e = " << e << std::endl;);
|
||||
TRACE(mpf_dbg, tout << " f = " << f << " e = " << e << std::endl;);
|
||||
|
||||
mpq q;
|
||||
m_mpq_manager.set(q, f.c_str());
|
||||
|
@ -136,7 +136,7 @@ void hwf_manager::set(hwf & o, mpf_rounding_mode rm, char const * value) {
|
|||
|
||||
set(o, rm, q, ex);
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void hwf_manager::set(hwf & o, mpf_rounding_mode rm, mpq const & significand, mpz const & exponent) {
|
||||
|
|
|
@ -223,12 +223,12 @@ void memory::display_i_max_usage(std::ostream & os) {
|
|||
#if Z3DEBUG
|
||||
void memory::deallocate(char const * file, int line, void * p) {
|
||||
deallocate(p);
|
||||
TRACE_CODE(if (!g_finalizing) TRACE("memory", tout << "dealloc " << std::hex << p << std::dec << " " << file << ":" << line << "\n";););
|
||||
TRACE_CODE(if (!g_finalizing) TRACE(memory, tout << "dealloc " << std::hex << p << std::dec << " " << file << ":" << line << "\n";););
|
||||
}
|
||||
|
||||
void * memory::allocate(char const* file, int line, char const* obj, size_t s) {
|
||||
void * r = allocate(s);
|
||||
TRACE("memory", tout << "alloc " << std::hex << r << std::dec << " " << file << ":" << line << " " << obj << " " << s << "\n";);
|
||||
TRACE(memory, tout << "alloc " << std::hex << r << std::dec << " " << file << ":" << line << " " << obj << " " << s << "\n";);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,7 +32,7 @@ unsigned min_cut::new_node() {
|
|||
void min_cut::add_edge(unsigned int i, unsigned int j, unsigned capacity) {
|
||||
m_edges.reserve(i + 1);
|
||||
m_edges[i].push_back(edge(j, capacity));
|
||||
TRACE("spacer.mincut", tout << "adding edge (" << i << "," << j << ")\n";);
|
||||
TRACE(spacer_mincut, tout << "adding edge (" << i << "," << j << ")\n";);
|
||||
}
|
||||
|
||||
void min_cut::compute_min_cut(unsigned_vector& cut_nodes) {
|
||||
|
|
|
@ -163,7 +163,7 @@ void mpbq_manager::add(mpbq const & a, mpz const & b, mpbq & r) {
|
|||
normalize(r);
|
||||
#ifdef MPBQ_DEBUG
|
||||
rational _r = to_rational(r);
|
||||
TRACE("mpbq_bug", tout << "add a: " << _a << ", b: " << _b << ", r: " << _r << ", expected: " << (_a + _b) << "\n";);
|
||||
TRACE(mpbq_bug, tout << "add a: " << _a << ", b: " << _b << ", r: " << _r << ", expected: " << (_a + _b) << "\n";);
|
||||
SASSERT(_a + _b == _r);
|
||||
#endif
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ void mpbq_manager::sub(mpbq const & a, mpbq const & b, mpbq & r) {
|
|||
normalize(r);
|
||||
#ifdef MPBQ_DEBUG
|
||||
rational _r = to_rational(r);
|
||||
TRACE("mpbq_bug", tout << "sub a: " << _a << ", b: " << _b << ", r: " << _r << ", expected: " << (_a - _b) << "\n";);
|
||||
TRACE(mpbq_bug, tout << "sub a: " << _a << ", b: " << _b << ", r: " << _r << ", expected: " << (_a - _b) << "\n";);
|
||||
SASSERT(_a - _b == _r);
|
||||
#endif
|
||||
}
|
||||
|
@ -750,7 +750,7 @@ bool mpbq_manager::select_small(mpbq const & lower, mpbq const & upper, mpbq & r
|
|||
|
||||
|
||||
void mpbq_manager::select_small_core(unsynch_mpq_manager & qm, mpq const & lower, mpbq const & upper, mpbq & r) {
|
||||
TRACE("select_small", tout << "lower (q): " << qm.to_string(lower) << ", upper (bq): " << to_string(upper) << "\n";);
|
||||
TRACE(select_small, tout << "lower (q): " << qm.to_string(lower) << ", upper (bq): " << to_string(upper) << "\n";);
|
||||
SASSERT(gt(upper, lower));
|
||||
mpz & aux = m_select_small_tmp;
|
||||
if (select_integer(qm, lower, upper, aux)) {
|
||||
|
|
234
src/util/mpf.cpp
234
src/util/mpf.cpp
|
@ -68,7 +68,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, int value) {
|
|||
o.ebits = ebits;
|
||||
o.sbits = sbits;
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: value = " << value << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: value = " << value << std::endl;);
|
||||
if (value == 0) {
|
||||
mk_pzero(ebits, sbits, o);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, int value) {
|
|||
m_mpz_manager.machine_div2k(o.significand, 32-sbits);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, int n, int d) {
|
||||
|
@ -116,7 +116,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, double value) {
|
|||
int64_t e = ((raw & 0x7FF0000000000000ull) >> 52) - 1023;
|
||||
uint64_t s = raw & 0x000FFFFFFFFFFFFFull;
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: " << value << " is: raw=" << raw << " (double)" <<
|
||||
TRACE(mpf_dbg, tout << "set: " << value << " is: raw=" << raw << " (double)" <<
|
||||
" sign=" << sign << " s=" << s << " e=" << e << std::endl;);
|
||||
|
||||
SASSERT(-1023 <= e && e <= +1024);
|
||||
|
@ -139,7 +139,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, double value) {
|
|||
else if (sbits > 53)
|
||||
m_mpz_manager.mul2k(o.significand, sbits-53);
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, float value) {
|
||||
|
@ -152,7 +152,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, float value) {
|
|||
signed int e = ((raw & 0x7F800000) >> 23) - 127;
|
||||
unsigned int s = raw & 0x007FFFFF;
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: " << value << " is: raw=" << raw << " (float)" <<
|
||||
TRACE(mpf_dbg, tout << "set: " << value << " is: raw=" << raw << " (float)" <<
|
||||
" sign=" << sign << " s=" << s << " e=" << e << std::endl;);
|
||||
|
||||
SASSERT(-127 <= e && e <= +128);
|
||||
|
@ -175,19 +175,19 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, float value) {
|
|||
else if (sbits > 24)
|
||||
m_mpz_manager.mul2k(o.significand, sbits-24);
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string_raw(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: res = " << to_string_raw(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpq const & value) {
|
||||
TRACE("mpf_dbg", tout << "set: " << m_mpq_manager.to_string(value) << " [" << ebits << "/" << sbits << "]"<< std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: " << m_mpq_manager.to_string(value) << " [" << ebits << "/" << sbits << "]"<< std::endl;);
|
||||
scoped_mpz exp(m_mpz_manager);
|
||||
m_mpz_manager.set(exp, 0);
|
||||
set(o, ebits, sbits, rm, exp, value);
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, char const * value) {
|
||||
TRACE("mpf_dbg", tout << "set: " << value << " [" << ebits << "/" << sbits << "]"<< std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: " << value << " [" << ebits << "/" << sbits << "]"<< std::endl;);
|
||||
|
||||
o.ebits = ebits;
|
||||
o.sbits = sbits;
|
||||
|
@ -209,7 +209,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
auto f = (e_pos != std::string_view::npos) ? std::string(v.substr(0, e_pos)) : std::string(v);
|
||||
auto e = (e_pos != std::string_view::npos) ? std::string(v.substr(e_pos+1)) : "0";
|
||||
|
||||
TRACE("mpf_dbg", tout << "sgn = " << sgn << " f = " << f << " e = " << e << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "sgn = " << sgn << " f = " << f << " e = " << e << std::endl;);
|
||||
|
||||
scoped_mpq q(m_mpq_manager);
|
||||
m_mpq_manager.set(q, f.c_str());
|
||||
|
@ -220,12 +220,12 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
set(o, ebits, sbits, rm, ex, q);
|
||||
o.sign = sgn;
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpz const & exponent, mpq const & significand) {
|
||||
// Assumption: this represents significand * 2^exponent.
|
||||
TRACE("mpf_dbg", tout << "set: sig = " << m_mpq_manager.to_string(significand) << " exp = " << m_mpz_manager.to_string(exponent) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: sig = " << m_mpq_manager.to_string(significand) << " exp = " << m_mpz_manager.to_string(exponent) << std::endl;);
|
||||
|
||||
o.ebits = ebits;
|
||||
o.sbits = sbits;
|
||||
|
@ -260,7 +260,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
m_mpz_manager.add(exp, mpz(pp), exp);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "Normalized: sig = " << m_mpq_manager.to_string(sig) <<
|
||||
TRACE(mpf_dbg, tout << "Normalized: sig = " << m_mpq_manager.to_string(sig) <<
|
||||
" exp = " << m_mpz_manager.to_string(exp) << std::endl;);
|
||||
|
||||
// Check that 1.0 <= sig < 2.0
|
||||
|
@ -279,7 +279,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
if (!m_mpq_manager.is_zero(sig) && m_mpz_manager.is_even(o.significand))
|
||||
m_mpz_manager.inc(o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "sig = " << m_mpz_manager.to_string(o.significand) <<
|
||||
TRACE(mpf_dbg, tout << "sig = " << m_mpz_manager.to_string(o.significand) <<
|
||||
" exp = " << o.exponent << std::endl;);
|
||||
|
||||
if (m_mpz_manager.is_small(exp)) {
|
||||
|
@ -290,7 +290,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
mk_inf(ebits, sbits, o.sign, o);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: res = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "set: res = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64_t significand) {
|
||||
|
@ -529,9 +529,9 @@ void mpf_manager::add_sub(mpf_rounding_mode rm, mpf const & x, mpf const & y, mp
|
|||
if (exp_delta > x.sbits+2)
|
||||
exp_delta = x.sbits+2;
|
||||
|
||||
TRACE("mpf_dbg", tout << "A = " << to_string(a) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "B = " << to_string(b) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "d = " << exp_delta << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "A = " << to_string(a) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "B = " << to_string(b) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "d = " << exp_delta << std::endl;);
|
||||
|
||||
// Introduce 3 extra bits into both numbers.
|
||||
m_mpz_manager.mul2k(a.significand(), 3, a.significand());
|
||||
|
@ -542,32 +542,32 @@ void mpf_manager::add_sub(mpf_rounding_mode rm, mpf const & x, mpf const & y, mp
|
|||
scoped_mpz sticky_rem(m_mpz_manager);
|
||||
m_mpz_manager.machine_div_rem(b.significand(), m_powers2((int)exp_delta), b.significand(), sticky_rem);
|
||||
|
||||
TRACE("mpf_dbg", tout << "A' = " << m_mpz_manager.to_string(a.significand()) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "B' = " << m_mpz_manager.to_string(b.significand()) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "A' = " << m_mpz_manager.to_string(a.significand()) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "B' = " << m_mpz_manager.to_string(b.significand()) << std::endl;);
|
||||
|
||||
// Significand addition
|
||||
if (sgn(a) != sgn(b)) {
|
||||
TRACE("mpf_dbg", tout << "SUBTRACTING" << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "SUBTRACTING" << std::endl;);
|
||||
m_mpz_manager.sub(a.significand(), b.significand(), o.significand);
|
||||
if (!sticky_rem.is_zero() && m_mpz_manager.is_even(o.significand))
|
||||
m_mpz_manager.dec(o.significand);
|
||||
}
|
||||
else {
|
||||
TRACE("mpf_dbg", tout << "ADDING" << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "ADDING" << std::endl;);
|
||||
m_mpz_manager.add(a.significand(), b.significand(), o.significand);
|
||||
if (!sticky_rem.is_zero() && m_mpz_manager.is_even(o.significand))
|
||||
m_mpz_manager.inc(o.significand);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "sum[-2:sbits+2] = " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "sum[-2:sbits+2] = " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
|
||||
if (m_mpz_manager.is_zero(o.significand))
|
||||
mk_zero(o.ebits, o.sbits, rm == MPF_ROUND_TOWARD_NEGATIVE, o);
|
||||
else {
|
||||
bool neg = m_mpz_manager.is_neg(o.significand);
|
||||
TRACE("mpf_dbg", tout << "NEG=" << neg << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "NEG=" << neg << std::endl;);
|
||||
m_mpz_manager.abs(o.significand);
|
||||
TRACE("mpf_dbg", tout << "fs[-1:sbits+2] = " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "fs[-1:sbits+2] = " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
o.sign = ((!a.sign() && b.sign() && neg) ||
|
||||
( a.sign() && !b.sign() && !neg) ||
|
||||
( a.sign() && b.sign()));
|
||||
|
@ -578,13 +578,13 @@ void mpf_manager::add_sub(mpf_rounding_mode rm, mpf const & x, mpf const & y, mp
|
|||
}
|
||||
|
||||
void mpf_manager::mul(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf & o) {
|
||||
TRACE("mpf_mul_bug", tout << "rm: " << rm << "\n";
|
||||
TRACE(mpf_mul_bug, tout << "rm: " << rm << "\n";
|
||||
tout << "X: " << to_string(x) << "\n";
|
||||
tout << "Y: " << to_string(y) << "\n";);
|
||||
SASSERT(x.sbits == y.sbits && x.ebits == y.ebits);
|
||||
|
||||
TRACE("mpf_dbg", tout << "X = " << to_string(x) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "Y = " << to_string(y) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "X = " << to_string(x) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Y = " << to_string(y) << std::endl;);
|
||||
|
||||
if (is_nan(x))
|
||||
mk_nan(x.ebits, x.sbits, o);
|
||||
|
@ -628,17 +628,17 @@ void mpf_manager::mul(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf &
|
|||
unpack(a, true);
|
||||
unpack(b, true);
|
||||
|
||||
TRACE("mpf_dbg", tout << "A = " << to_string(a) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "B = " << to_string(b) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "A = " << to_string(a) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "B = " << to_string(b) << std::endl;);
|
||||
|
||||
o.exponent = a.exponent() + b.exponent();
|
||||
|
||||
TRACE("mpf_dbg", tout << "A' = " << m_mpz_manager.to_string(a.significand()) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "B' = " << m_mpz_manager.to_string(b.significand()) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "A' = " << m_mpz_manager.to_string(a.significand()) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "B' = " << m_mpz_manager.to_string(b.significand()) << std::endl;);
|
||||
|
||||
m_mpz_manager.mul(a.significand(), b.significand(), o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "PRODUCT = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "PRODUCT = " << to_string(o) << std::endl;);
|
||||
|
||||
// Remove the extra bits, keeping a sticky bit.
|
||||
scoped_mpz sticky_rem(m_mpz_manager);
|
||||
|
@ -652,14 +652,14 @@ void mpf_manager::mul(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf &
|
|||
|
||||
round(rm, o);
|
||||
}
|
||||
TRACE("mpf_mul_bug", tout << "result: " << to_string(o) << "\n";);
|
||||
TRACE(mpf_mul_bug, tout << "result: " << to_string(o) << "\n";);
|
||||
}
|
||||
|
||||
void mpf_manager::div(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf & o) {
|
||||
SASSERT(x.sbits == y.sbits && x.ebits == y.ebits);
|
||||
|
||||
TRACE("mpf_dbg", tout << "X = " << to_string(x) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "Y = " << to_string(y) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "X = " << to_string(x) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Y = " << to_string(y) << std::endl;);
|
||||
|
||||
if (is_nan(x))
|
||||
mk_nan(x.ebits, x.sbits, o);
|
||||
|
@ -710,19 +710,19 @@ void mpf_manager::div(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf &
|
|||
unpack(a, true);
|
||||
unpack(b, true);
|
||||
|
||||
TRACE("mpf_dbg", tout << "A = " << to_string(a) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "B = " << to_string(b) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "A = " << to_string(a) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "B = " << to_string(b) << std::endl;);
|
||||
|
||||
o.exponent = a.exponent() - b.exponent();
|
||||
|
||||
TRACE("mpf_dbg", tout << "A' = " << m_mpz_manager.to_string(a.significand()) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "B' = " << m_mpz_manager.to_string(b.significand()) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "A' = " << m_mpz_manager.to_string(a.significand()) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "B' = " << m_mpz_manager.to_string(b.significand()) << std::endl;);
|
||||
|
||||
unsigned extra_bits = x.sbits + 2;
|
||||
m_mpz_manager.mul2k(a.significand(), x.sbits + extra_bits);
|
||||
m_mpz_manager.machine_div(a.significand(), b.significand(), o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "QUOTIENT = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "QUOTIENT = " << to_string(o) << std::endl;);
|
||||
|
||||
// Remove the extra bits, keeping a sticky bit.
|
||||
scoped_mpz sticky_rem(m_mpz_manager);
|
||||
|
@ -730,7 +730,7 @@ void mpf_manager::div(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf &
|
|||
if (!m_mpz_manager.is_zero(sticky_rem) && m_mpz_manager.is_even(o.significand))
|
||||
m_mpz_manager.inc(o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "QUOTIENT' = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "QUOTIENT' = " << to_string(o) << std::endl;);
|
||||
|
||||
round(rm, o);
|
||||
}
|
||||
|
@ -740,9 +740,9 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
SASSERT(x.sbits == y.sbits && x.ebits == y.ebits &&
|
||||
x.sbits == z.sbits && x.ebits == z.ebits);
|
||||
|
||||
TRACE("mpf_dbg", tout << "X = " << to_string(x) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "Y = " << to_string(y) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "Z = " << to_string(z) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "X = " << to_string(x) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Y = " << to_string(y) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Z = " << to_string(z) << std::endl;);
|
||||
|
||||
if (is_nan(x) || is_nan(y) || is_nan(z))
|
||||
mk_nan(x.ebits, x.sbits, o);
|
||||
|
@ -801,7 +801,7 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
unpack(b, true);
|
||||
unpack(c, true);
|
||||
|
||||
TRACE("mpf_dbg", tout << "A = " << to_string(a) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "A = " << to_string(a) << std::endl;
|
||||
tout << "B = " << to_string(b) << std::endl;
|
||||
tout << "C = " << to_string(c) << std::endl;
|
||||
tout << "A = " << to_string_binary(a, 1, 0) << std::endl;
|
||||
|
@ -818,7 +818,7 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
mr.set(x.ebits+2, 2*x.sbits-1, a.sign() != b.sign(), a.exponent() + b.exponent());
|
||||
m_mpz_manager.mul(a.significand(), b.significand(), mr.significand());
|
||||
|
||||
TRACE("mpf_dbg", tout << "M = " << to_string(mr) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "M = " << to_string(mr) << std::endl;
|
||||
tout << "M = " << to_string_binary(mr, 1, 0) << std::endl;);
|
||||
|
||||
// mul_res is [-1][0].[2*sbits - 2], i.e., >= 2^(2*sbits-2) and < 2^(2*sbits).
|
||||
|
@ -832,7 +832,7 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
mr.set(x.ebits + 2, 2 * x.sbits - 1 + 3, mr.sign(), mr.exponent(), mr.significand());
|
||||
m_mpz_manager.mul2k(mr.significand(), 3);
|
||||
|
||||
TRACE("mpf_dbg", tout << "C_= " << to_string(c) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "C_= " << to_string(c) << std::endl;
|
||||
tout << "C_= " << to_string_binary(c, 1, 0) << std::endl;);
|
||||
|
||||
SASSERT(m_mpz_manager.lt(c.significand(), m_powers2(2*x.sbits + 3)));
|
||||
|
@ -840,7 +840,7 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
m_mpz_manager.ge(c.significand(), m_powers2(2*x.sbits - 2 + 3)));
|
||||
|
||||
if (exp(c) > exp(mr)) {
|
||||
TRACE("mpf_dbg", tout << "Swap!" << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Swap!" << std::endl;);
|
||||
mr.swap(c);
|
||||
}
|
||||
|
||||
|
@ -855,20 +855,20 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
|
||||
scoped_mpz sticky_rem(m_mpz_manager);
|
||||
m_mpz_manager.machine_div_rem(c.significand(), m_powers2(exp_delta), c.significand(), sticky_rem);
|
||||
TRACE("mpf_dbg", tout << "alignment shift by delta=" << exp_delta << " -> sig = " << m_mpz_manager.to_string(c.significand()) <<
|
||||
TRACE(mpf_dbg, tout << "alignment shift by delta=" << exp_delta << " -> sig = " << m_mpz_manager.to_string(c.significand()) <<
|
||||
" sticky_rem = " << m_mpz_manager.to_string(sticky_rem) << std::endl;);
|
||||
bool alignment_sticky = !m_mpz_manager.is_zero(sticky_rem);
|
||||
|
||||
TRACE("mpf_dbg", tout << "M'= " << m_mpz_manager.to_string(mr.significand()) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "M'= " << m_mpz_manager.to_string(mr.significand()) << std::endl;
|
||||
tout << "M'= " << to_string_binary(mr, 1, 0) << std::endl; );
|
||||
TRACE("mpf_dbg", tout << "C'= " << m_mpz_manager.to_string(c.significand()) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "C'= " << m_mpz_manager.to_string(c.significand()) << std::endl;
|
||||
tout << "C'= " << to_string_binary(c, 1, 0) << std::endl; );
|
||||
|
||||
// Significand addition
|
||||
scoped_mpf res(mr);
|
||||
|
||||
if (sgn(mr) != sgn(c)) {
|
||||
TRACE("mpf_dbg", tout << "SUBTRACTING" << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "SUBTRACTING" << std::endl;);
|
||||
m_mpz_manager.sub(mr.significand(), c.significand(), res.significand());
|
||||
|
||||
if (alignment_sticky && m_mpz_manager.is_even(res.significand()))
|
||||
|
@ -880,14 +880,14 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
}
|
||||
}
|
||||
else {
|
||||
TRACE("mpf_dbg", tout << "ADDING" << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "ADDING" << std::endl;);
|
||||
m_mpz_manager.add(mr.significand(), c.significand(), res.significand());
|
||||
|
||||
if (alignment_sticky && m_mpz_manager.is_even(res.significand()))
|
||||
m_mpz_manager.inc(res.get().significand);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "S'= " << m_mpz_manager.to_string(res.significand()) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "S'= " << m_mpz_manager.to_string(res.significand()) << std::endl;
|
||||
tout << "S'= " << to_string_binary(res, 1, 0) << std::endl; );
|
||||
|
||||
// Renormalize
|
||||
|
@ -899,7 +899,7 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
res.get().exponent++;
|
||||
renorm_sticky = !m_mpz_manager.is_even(res.significand());
|
||||
m_mpz_manager.machine_div2k(res.significand(), 1);
|
||||
TRACE("mpf_dbg", tout << "Add/Sub overflew into 4.xxx!" << std::endl;
|
||||
TRACE(mpf_dbg, tout << "Add/Sub overflew into 4.xxx!" << std::endl;
|
||||
tout << "S*= " << to_string_binary(res, 2, 0) << std::endl;);
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
res.get().exponent -= renorm_delta;
|
||||
m_mpz_manager.mul2k(res.significand(), renorm_delta);
|
||||
|
||||
TRACE("mpf_dbg", tout << "R*= " << to_string_binary(res, 2, 0) << " (renormalized, delta=" << renorm_delta << ")" << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "R*= " << to_string_binary(res, 2, 0) << " (renormalized, delta=" << renorm_delta << ")" << std::endl;);
|
||||
|
||||
set(o, x.ebits, x.sbits, res.sign(), res.exponent(), mpz(0));
|
||||
|
||||
|
@ -927,7 +927,7 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
if (renorm_sticky && m_mpz_manager.is_even(o.significand))
|
||||
m_mpz_manager.inc(o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "sum[-1:sbits+2] = " << m_mpz_manager.to_string(o.significand) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "sum[-1:sbits+2] = " << m_mpz_manager.to_string(o.significand) << std::endl;
|
||||
tout << "R = " << to_string_binary(o, 1, 3) << std::endl;);
|
||||
|
||||
unsigned max_size = o.sbits+4;
|
||||
|
@ -944,7 +944,7 @@ void mpf_manager::fma(mpf_rounding_mode rm, mpf const & x, mpf const & y, mpf co
|
|||
round(rm, o);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "FMA = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "FMA = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void my_mpz_sqrt(unsynch_mpz_manager & m, unsigned sbits, bool odd_exp, mpz & in, mpz & o) {
|
||||
|
@ -965,18 +965,18 @@ void my_mpz_sqrt(unsynch_mpz_manager & m, unsigned sbits, bool odd_exp, mpz & in
|
|||
m.set(o, lower);
|
||||
|
||||
while (m.neq(lower, upper)) {
|
||||
STRACE("mpf_dbg", tout << "SIG = " << m.to_string(in) <<
|
||||
STRACE(mpf_dbg, tout << "SIG = " << m.to_string(in) <<
|
||||
" LOWER = " << m.to_string(lower) <<
|
||||
" UPPER = " << m.to_string(upper) << std::endl;);
|
||||
m.sub(upper, lower, diff);
|
||||
if (m.is_one(diff)) {
|
||||
m.mul(lower, lower, product);
|
||||
if (m.eq(product, in)) {
|
||||
STRACE("mpf_dbg", tout << "choosing lower" << std::endl;);
|
||||
STRACE(mpf_dbg, tout << "choosing lower" << std::endl;);
|
||||
m.set(o, lower);
|
||||
}
|
||||
else {
|
||||
STRACE("mpf_dbg", tout << "choosing upper" << std::endl;);
|
||||
STRACE(mpf_dbg, tout << "choosing upper" << std::endl;);
|
||||
m.set(o, upper); // choosing upper is like a sticky bit here.
|
||||
}
|
||||
break;
|
||||
|
@ -986,7 +986,7 @@ void my_mpz_sqrt(unsynch_mpz_manager & m, unsigned sbits, bool odd_exp, mpz & in
|
|||
m.machine_div2k(mid, 1);
|
||||
m.mul(mid, mid, product);
|
||||
|
||||
STRACE("mpf_dbg", tout << "MID = " << m.to_string(mid) <<
|
||||
STRACE(mpf_dbg, tout << "MID = " << m.to_string(mid) <<
|
||||
" PROD = " << m.to_string(product) << std::endl;);
|
||||
|
||||
if (m.lt(product, in))
|
||||
|
@ -1004,7 +1004,7 @@ void my_mpz_sqrt(unsynch_mpz_manager & m, unsigned sbits, bool odd_exp, mpz & in
|
|||
void mpf_manager::sqrt(mpf_rounding_mode rm, mpf const & x, mpf & o) {
|
||||
SASSERT(x.ebits > 0 && x.sbits > 0);
|
||||
|
||||
TRACE("mpf_dbg", tout << "X = " << to_string(x) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "X = " << to_string(x) << std::endl;);
|
||||
|
||||
if (is_nan(x))
|
||||
mk_nan(x.ebits, x.sbits, o);
|
||||
|
@ -1023,7 +1023,7 @@ void mpf_manager::sqrt(mpf_rounding_mode rm, mpf const & x, mpf & o) {
|
|||
set(a, x);
|
||||
unpack(a, true);
|
||||
|
||||
TRACE("mpf_dbg", tout << "A = " << to_string(a) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "A = " << to_string(a) << std::endl;);
|
||||
|
||||
m_mpz_manager.mul2k(a.significand(), x.sbits + ((a.exponent() % 2)?6:7));
|
||||
if (!m_mpz_manager.root(a.significand(), 2, o.significand))
|
||||
|
@ -1032,7 +1032,7 @@ void mpf_manager::sqrt(mpf_rounding_mode rm, mpf const & x, mpf & o) {
|
|||
// We need a sticky bit in the last position here, so we fix that.
|
||||
if (m_mpz_manager.is_even(o.significand))
|
||||
m_mpz_manager.dec(o.significand);
|
||||
TRACE("mpf_dbg", tout << "dec'ed " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "dec'ed " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
}
|
||||
o.exponent = a.exponent() >> 1;
|
||||
if (a.exponent() % 2 == 0) o.exponent--;
|
||||
|
@ -1040,13 +1040,13 @@ void mpf_manager::sqrt(mpf_rounding_mode rm, mpf const & x, mpf & o) {
|
|||
round(rm, o);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "SQRT = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "SQRT = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::round_to_integral(mpf_rounding_mode rm, mpf const & x, mpf & o) {
|
||||
SASSERT(x.ebits > 0 && x.sbits > 0);
|
||||
|
||||
TRACE("mpf_dbg", tout << "X = " << to_string(x) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "X = " << to_string(x) << std::endl;);
|
||||
|
||||
if (is_nan(x))
|
||||
mk_nan(x.ebits, x.sbits, o);
|
||||
|
@ -1072,7 +1072,7 @@ void mpf_manager::round_to_integral(mpf_rounding_mode rm, mpf const & x, mpf & o
|
|||
else {
|
||||
SASSERT(rm == MPF_ROUND_NEAREST_TEVEN || rm == MPF_ROUND_NEAREST_TAWAY);
|
||||
bool tie = m_mpz_manager.is_zero(x.significand) && x.exponent == -1;
|
||||
TRACE("mpf_dbg", tout << "tie = " << tie << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "tie = " << tie << std::endl;);
|
||||
if (tie && rm == MPF_ROUND_NEAREST_TEVEN)
|
||||
mk_zero(x.ebits, x.sbits, x.sign, o);
|
||||
else if (tie && rm == MPF_ROUND_NEAREST_TAWAY)
|
||||
|
@ -1096,7 +1096,7 @@ void mpf_manager::round_to_integral(mpf_rounding_mode rm, mpf const & x, mpf & o
|
|||
set(a, x);
|
||||
unpack(a, true); // A includes hidden bit
|
||||
|
||||
TRACE("mpf_dbg", tout << "A = " << to_string_raw(a) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "A = " << to_string_raw(a) << std::endl;);
|
||||
|
||||
SASSERT(m_mpz_manager.lt(a.significand(), m_powers2(x.sbits)));
|
||||
SASSERT(m_mpz_manager.ge(a.significand(), m_powers2(x.sbits - 1)));
|
||||
|
@ -1107,12 +1107,12 @@ void mpf_manager::round_to_integral(mpf_rounding_mode rm, mpf const & x, mpf & o
|
|||
unsigned shift = (o.sbits - 1) - ((unsigned)o.exponent);
|
||||
const mpz & shift_p = m_powers2(shift);
|
||||
const mpz & shiftm1_p = m_powers2(shift-1);
|
||||
TRACE("mpf_dbg", tout << "shift=" << shift << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "shiftm1_p=" << m_mpz_manager.to_string(shiftm1_p) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "shift=" << shift << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "shiftm1_p=" << m_mpz_manager.to_string(shiftm1_p) << std::endl;);
|
||||
|
||||
scoped_mpz div(m_mpz_manager), rem(m_mpz_manager);
|
||||
m_mpz_manager.machine_div_rem(o.significand, shift_p, div, rem);
|
||||
TRACE("mpf_dbg", tout << "div=" << m_mpz_manager.to_string(div) << " rem=" << m_mpz_manager.to_string(rem) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "div=" << m_mpz_manager.to_string(div) << " rem=" << m_mpz_manager.to_string(rem) << std::endl;);
|
||||
|
||||
switch (rm) {
|
||||
case MPF_ROUND_NEAREST_TEVEN:
|
||||
|
@ -1121,11 +1121,11 @@ void mpf_manager::round_to_integral(mpf_rounding_mode rm, mpf const & x, mpf & o
|
|||
bool less_than_tie = m_mpz_manager.lt(rem, shiftm1_p);
|
||||
bool more_than_tie = m_mpz_manager.gt(rem, shiftm1_p);
|
||||
(void)less_than_tie;
|
||||
TRACE("mpf_dbg", tout << "tie= " << tie << "; <tie = " << less_than_tie << "; >tie = " << more_than_tie << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "tie= " << tie << "; <tie = " << less_than_tie << "; >tie = " << more_than_tie << std::endl;);
|
||||
if (tie) {
|
||||
if ((rm == MPF_ROUND_NEAREST_TEVEN && m_mpz_manager.is_odd(div)) ||
|
||||
(rm == MPF_ROUND_NEAREST_TAWAY)) {
|
||||
TRACE("mpf_dbg", tout << "div++ (1)" << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "div++ (1)" << std::endl;);
|
||||
m_mpz_manager.inc(div);
|
||||
}
|
||||
}
|
||||
|
@ -1133,7 +1133,7 @@ void mpf_manager::round_to_integral(mpf_rounding_mode rm, mpf const & x, mpf & o
|
|||
SASSERT(less_than_tie || more_than_tie);
|
||||
if (more_than_tie) {
|
||||
m_mpz_manager.inc(div);
|
||||
TRACE("mpf_dbg", tout << "div++ (2)" << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "div++ (2)" << std::endl;);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1163,7 +1163,7 @@ void mpf_manager::round_to_integral(mpf_rounding_mode rm, mpf const & x, mpf & o
|
|||
m_mpz_manager.sub(o.significand, m_powers2(o.sbits - 1), o.significand); // strip hidden bit
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "INTEGRAL = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "INTEGRAL = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::to_mpz(mpf const & x, unsynch_mpz_manager & zm, mpz & o) {
|
||||
|
@ -1213,7 +1213,7 @@ void mpf_manager::to_sbv_mpq(mpf_rounding_mode rm, const mpf & x, scoped_mpq & o
|
|||
default: UNREACHABLE();
|
||||
}
|
||||
if (inc) m_mpz_manager.inc(z);
|
||||
TRACE("mpf_dbg_sbv",
|
||||
TRACE(mpf_dbg_sbv,
|
||||
tout << "SBV: (" << to_string(x) << ") == " << m_mpq_manager.to_string(z) << std::endl;
|
||||
tout << "sign=" << t.sign() << " last=" << last << " round=" << round <<
|
||||
" sticky=" << sticky << " inc=" << inc << std::endl; );
|
||||
|
@ -1224,7 +1224,7 @@ void mpf_manager::to_sbv_mpq(mpf_rounding_mode rm, const mpf & x, scoped_mpq & o
|
|||
m_mpq_manager.set(o, z);
|
||||
if (x.sign) m_mpq_manager.neg(o);
|
||||
|
||||
TRACE("mpf_dbg", tout << "SBV = " << m_mpq_manager.to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "SBV = " << m_mpq_manager.to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::to_ieee_bv_mpz(const mpf & x, scoped_mpz & o) {
|
||||
|
@ -1251,7 +1251,7 @@ void mpf_manager::to_ieee_bv_mpz(const mpf & x, scoped_mpz & o) {
|
|||
m_mpz_manager.add(o, sig(x), o);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "IEEE_BV = " << m_mpz_manager.to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "IEEE_BV = " << m_mpz_manager.to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::renormalize(unsigned ebits, unsigned sbits, mpf_exp_t & exp, mpz & sig) {
|
||||
|
@ -1281,7 +1281,7 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
signed int D = (signed int)(exp_diff);
|
||||
mpf_exp_t N = sbits-1;
|
||||
|
||||
TRACE("mpf_dbg_rem", tout << "x=" << to_string(x) << std::endl;
|
||||
TRACE(mpf_dbg_rem, tout << "x=" << to_string(x) << std::endl;
|
||||
tout << "y=" << to_string(y) << std::endl;
|
||||
tout << "d=" << D << std::endl;
|
||||
tout << "partial=" << partial << std::endl;);
|
||||
|
@ -1300,7 +1300,7 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
m_mpz_manager.machine_div_rem(x_sig_shifted, y.significand, x_div_y_sig_lrg, x_div_y_rem); // rem useful?
|
||||
// x/y is in x_diuv_y_sig_lrg and has sbits+3 extra bits.
|
||||
|
||||
TRACE("mpf_dbg_rem", tout << "X/Y_exp=" << x_div_y_exp << std::endl;
|
||||
TRACE(mpf_dbg_rem, tout << "X/Y_exp=" << x_div_y_exp << std::endl;
|
||||
tout << "X/Y_sig_lrg=" << m_mpz_manager.to_string(x_div_y_sig_lrg) << std::endl;
|
||||
tout << "X/Y_rem=" << m_mpz_manager.to_string(x_div_y_rem) << std::endl;
|
||||
tout << "X/Y~=" << to_string_hexfloat(x_div_y_sgn, x_div_y_exp, x_div_y_sig_lrg, ebits, sbits, sbits+3) << std::endl;);
|
||||
|
@ -1321,7 +1321,7 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
const mpz & shiftm1_p = m_powers2(Q_shft-1);
|
||||
bool tie = m_mpz_manager.eq(Q_rem, shiftm1_p);
|
||||
bool more_than_tie = m_mpz_manager.gt(Q_rem, shiftm1_p);
|
||||
TRACE("mpf_dbg_rem", tout << "tie= " << tie << "; >tie= " << more_than_tie << std::endl;);
|
||||
TRACE(mpf_dbg_rem, tout << "tie= " << tie << "; >tie= " << more_than_tie << std::endl;);
|
||||
if ((tie && m_mpz_manager.is_odd(Q_sig)) || more_than_tie)
|
||||
m_mpz_manager.inc(Q_sig);
|
||||
}
|
||||
|
@ -1330,7 +1330,7 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
renormalize(ebits, sbits, Q_exp, Q_sig);
|
||||
|
||||
(void)Q_sgn;
|
||||
TRACE("mpf_dbg_rem", tout << "Q_exp=" << Q_exp << std::endl;
|
||||
TRACE(mpf_dbg_rem, tout << "Q_exp=" << Q_exp << std::endl;
|
||||
tout << "Q_sig=" << m_mpz_manager.to_string(Q_sig) << std::endl;
|
||||
tout << "Q=" << to_string_hexfloat(Q_sgn, Q_exp, Q_sig, ebits, sbits, 0) << std::endl;);
|
||||
|
||||
|
@ -1351,7 +1351,7 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
renormalize(ebits, 2*sbits-1, YQ_exp, YQ_sig); // YQ_sig has `sbits-1' extra bits.
|
||||
|
||||
(void)YQ_sgn;
|
||||
TRACE("mpf_dbg_rem", tout << "YQ_sgn=" << YQ_sgn << std::endl;
|
||||
TRACE(mpf_dbg_rem, tout << "YQ_sgn=" << YQ_sgn << std::endl;
|
||||
tout << "YQ_exp=" << YQ_exp << std::endl;
|
||||
tout << "YQ_sig=" << m_mpz_manager.to_string(YQ_sig) << std::endl;
|
||||
tout << "YQ=" << to_string_hexfloat(YQ_sgn, YQ_exp, YQ_sig, ebits, sbits, sbits-1) << std::endl;);
|
||||
|
@ -1364,7 +1364,7 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
mpf_exp_t X_YQ_exp = x.exponent;
|
||||
scoped_mpz X_YQ_sig(m_mpz_manager);
|
||||
mpf_exp_t exp_delta = exp(x) - YQ_exp;
|
||||
TRACE("mpf_dbg_rem", tout << "exp_delta=" << exp_delta << std::endl;);
|
||||
TRACE(mpf_dbg_rem, tout << "exp_delta=" << exp_delta << std::endl;);
|
||||
SASSERT(INT_MIN < exp_delta && exp_delta <= INT_MAX);
|
||||
scoped_mpz minuend(m_mpz_manager), subtrahend(m_mpz_manager);
|
||||
|
||||
|
@ -1393,11 +1393,11 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
}
|
||||
if (!m_mpz_manager.is_zero(sticky_rem) && m_mpz_manager.is_even(subtrahend))
|
||||
m_mpz_manager.inc(subtrahend);
|
||||
TRACE("mpf_dbg_rem", tout << "aligned subtrahend=" << m_mpz_manager.to_string(subtrahend) << std::endl;);
|
||||
TRACE(mpf_dbg_rem, tout << "aligned subtrahend=" << m_mpz_manager.to_string(subtrahend) << std::endl;);
|
||||
}
|
||||
|
||||
m_mpz_manager.sub(minuend, subtrahend, X_YQ_sig);
|
||||
TRACE("mpf_dbg_rem", tout << "X_YQ_sig'=" << m_mpz_manager.to_string(X_YQ_sig) << std::endl;);
|
||||
TRACE(mpf_dbg_rem, tout << "X_YQ_sig'=" << m_mpz_manager.to_string(X_YQ_sig) << std::endl;);
|
||||
|
||||
bool neg = m_mpz_manager.is_neg(X_YQ_sig);
|
||||
if (neg) m_mpz_manager.neg(X_YQ_sig);
|
||||
|
@ -1409,7 +1409,7 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
else {
|
||||
renormalize(ebits, 2*sbits-1, X_YQ_exp, X_YQ_sig);
|
||||
|
||||
TRACE("mpf_dbg_rem", tout << "minuend=" << m_mpz_manager.to_string(minuend) << std::endl;
|
||||
TRACE(mpf_dbg_rem, tout << "minuend=" << m_mpz_manager.to_string(minuend) << std::endl;
|
||||
tout << "subtrahend=" << m_mpz_manager.to_string(subtrahend) << std::endl;
|
||||
tout << "X_YQ_sgn=" << X_YQ_sgn << std::endl;
|
||||
tout << "X_YQ_exp=" << X_YQ_exp << std::endl;
|
||||
|
@ -1420,7 +1420,7 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
SASSERT(m_mpz_manager.lt(X_YQ_sig, m_powers2(2*sbits-1)));
|
||||
scoped_mpz rnd_bits(m_mpz_manager);
|
||||
m_mpz_manager.machine_div_rem(X_YQ_sig, m_powers2(sbits-1), X_YQ_sig, rnd_bits);
|
||||
TRACE("mpf_dbg_rem", tout << "final sticky=" << m_mpz_manager.to_string(rnd_bits) << std::endl; );
|
||||
TRACE(mpf_dbg_rem, tout << "final sticky=" << m_mpz_manager.to_string(rnd_bits) << std::endl; );
|
||||
|
||||
// Round to nearest, ties to even.
|
||||
if (m_mpz_manager.eq(rnd_bits, mpz(32))) { // tie.
|
||||
|
@ -1434,13 +1434,13 @@ void mpf_manager::partial_remainder(mpf & x, mpf const & y, mpf_exp_t const & ex
|
|||
set(x, ebits, sbits, X_YQ_sgn, X_YQ_exp, X_YQ_sig);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg_rem", tout << "partial remainder = " << to_string_hexfloat(x) << std::endl;);
|
||||
TRACE(mpf_dbg_rem, tout << "partial remainder = " << to_string_hexfloat(x) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::rem(mpf const & x, mpf const & y, mpf & o) {
|
||||
SASSERT(x.sbits == y.sbits && x.ebits == y.ebits);
|
||||
|
||||
TRACE("mpf_dbg_rem", tout << "X = " << to_string(x) << "=" << to_string_hexfloat(x) << std::endl;
|
||||
TRACE(mpf_dbg_rem, tout << "X = " << to_string(x) << "=" << to_string_hexfloat(x) << std::endl;
|
||||
tout << "Y = " << to_string(y) << "=" << to_string_hexfloat(y) << std::endl;);
|
||||
|
||||
if (is_nan(x) || is_nan(y))
|
||||
|
@ -1482,8 +1482,8 @@ void mpf_manager::rem(mpf const & x, mpf const & y, mpf & o) {
|
|||
round(MPF_ROUND_NEAREST_TEVEN, o);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg_rem", tout << "R = " << to_string(o) << "=" << to_string_hexfloat(o) << std::endl; );
|
||||
TRACE("mpf_dbg", tout << "REMAINDER = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg_rem, tout << "R = " << to_string(o) << "=" << to_string_hexfloat(o) << std::endl; );
|
||||
TRACE(mpf_dbg, tout << "REMAINDER = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::maximum(mpf const & x, mpf const & y, mpf & o) {
|
||||
|
@ -1546,10 +1546,10 @@ std::string mpf_manager::to_string(mpf const & x) {
|
|||
m_mpz_manager.add(num, sig(x), num);
|
||||
m_mpz_manager.mul2k(denom, x.sbits-1, denom);
|
||||
|
||||
//TRACE("mpf_dbg", tout << "SIG=" << m_mpq_manager.to_string(sig(x)) << std::endl; );
|
||||
//TRACE("mpf_dbg", tout << "NUM=" << m_mpq_manager.to_string(num) << std::endl;);
|
||||
//TRACE("mpf_dbg", tout << "DEN=" << m_mpq_manager.to_string(denom) << std::endl;);
|
||||
//TRACE("mpf_dbg", tout << "EXP=" << exponent << std::endl;);
|
||||
//TRACE(mpf_dbg, tout << "SIG=" << m_mpq_manager.to_string(sig(x)) << std::endl; );
|
||||
//TRACE(mpf_dbg, tout << "NUM=" << m_mpq_manager.to_string(num) << std::endl;);
|
||||
//TRACE(mpf_dbg, tout << "DEN=" << m_mpq_manager.to_string(denom) << std::endl;);
|
||||
//TRACE(mpf_dbg, tout << "EXP=" << exponent << std::endl;);
|
||||
|
||||
scoped_mpq r(m_mpq_manager);
|
||||
m_mpq_manager.set(r, num);
|
||||
|
@ -1918,7 +1918,7 @@ void mpf_manager::mk_ninf(unsigned ebits, unsigned sbits, mpf & o) {
|
|||
}
|
||||
|
||||
void mpf_manager::unpack(mpf & o, bool normalize) {
|
||||
TRACE("mpf_dbg", tout << "unpack " << to_string(o) << ": ebits=" <<
|
||||
TRACE(mpf_dbg, tout << "unpack " << to_string(o) << ": ebits=" <<
|
||||
o.ebits << " sbits=" << o.sbits <<
|
||||
" normalize=" << normalize <<
|
||||
" has_top_exp=" << has_top_exp(o) << " (" << mk_top_exp(o.ebits) << ")" <<
|
||||
|
@ -1962,7 +1962,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
// Assumptions: o.significand is of the form f[-1:0] . f[1:sbits-1] [round,extra,sticky],
|
||||
// i.e., it has 2 + (sbits-1) + 3 = sbits + 4 bits.
|
||||
|
||||
TRACE("mpf_dbg", tout << "RND: " << to_string(o) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "RND: " << to_string(o) << std::endl;
|
||||
tout << to_string_binary(o, 1, 3) << std::endl;);
|
||||
|
||||
DEBUG_CODE({
|
||||
|
@ -1995,7 +1995,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
if (m_mpz_manager.lt(sigma, sigma_cap))
|
||||
m_mpz_manager.set(sigma, sigma_cap);
|
||||
|
||||
TRACE("mpf_dbg", tout << "e_min_norm = " << e_min << std::endl;
|
||||
TRACE(mpf_dbg, tout << "e_min_norm = " << e_min << std::endl;
|
||||
tout << "e_max_norm = " << e_max << std::endl;
|
||||
tout << "beta = " << beta << ", (beta < e_min) = " << (beta < e_min) << std::endl;
|
||||
tout << "LZ = " << lz << std::endl;
|
||||
|
@ -2004,7 +2004,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
|
||||
// Normalization shift
|
||||
|
||||
TRACE("mpf_dbg", tout << "Shift distance: " << m_mpz_manager.to_string(sigma) << " " << ((m_mpz_manager.is_nonneg(sigma))?"(LEFT)":"(RIGHT)") << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Shift distance: " << m_mpz_manager.to_string(sigma) << " " << ((m_mpz_manager.is_nonneg(sigma))?"(LEFT)":"(RIGHT)") << std::endl;);
|
||||
|
||||
if (m_mpz_manager.le(sigma, -1)) {
|
||||
// Right shift
|
||||
|
@ -2021,7 +2021,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
m_mpz_manager.mul2k(o.significand, sigma_uint, o.significand);
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "Shifted: " << to_string(o) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "Shifted: " << to_string(o) << std::endl;
|
||||
tout << to_string_binary(o, 1, 3) << std::endl;);
|
||||
|
||||
// Significand rounding (sigrd)
|
||||
|
@ -2035,8 +2035,8 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
|
||||
bool last = !m_mpz_manager.is_even(o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "sign=" << o.sign << " last=" << last << " round=" << round << " sticky=" << sticky << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "before rounding decision: " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "sign=" << o.sign << " last=" << last << " round=" << round << " sticky=" << sticky << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "before rounding decision: " << to_string(o) << std::endl;);
|
||||
|
||||
// The significand has the right size now, but we might have to increment it
|
||||
// depending on the sign, the last/round/sticky bits, and the rounding mode.
|
||||
|
@ -2050,11 +2050,11 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "Rounding increment -> significand +" << (int)inc << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Rounding increment -> significand +" << (int)inc << std::endl;);
|
||||
if (inc)
|
||||
m_mpz_manager.inc(o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "Rounded significand: " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Rounded significand: " << to_string(o) << std::endl;);
|
||||
|
||||
// Post normalization (post)
|
||||
|
||||
|
@ -2065,16 +2065,16 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
}
|
||||
|
||||
bool SIGovf = o.exponent > e_max;
|
||||
TRACE("mpf_dbg", tout << "Post-normalized: " << to_string(o) << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "SIGovf = " << SIGovf << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "Post-normalized: " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "SIGovf = " << SIGovf << std::endl;);
|
||||
|
||||
// Exponent rounding (exprd)
|
||||
|
||||
bool o_has_max_exp = (o.exponent > e_max);
|
||||
bool OVF2 = SIGovf && o_has_max_exp;
|
||||
|
||||
TRACE("mpf_dbg", tout << "OVF2 = " << OVF2 << std::endl;);
|
||||
TRACE("mpf_dbg", tout << "o_has_max_exp = " << o_has_max_exp << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "OVF2 = " << OVF2 << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "o_has_max_exp = " << o_has_max_exp << std::endl;);
|
||||
|
||||
if (OVF2)
|
||||
mk_round_inf(rm, o);
|
||||
|
@ -2082,21 +2082,21 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
const mpz & p = m_powers2(o.sbits-1);
|
||||
|
||||
if (m_mpz_manager.ge(o.significand, p)) {
|
||||
TRACE("mpf_dbg", tout << "NORMAL: " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "NORMAL: " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
m_mpz_manager.sub(o.significand, p, o.significand); // Strips the hidden bit.
|
||||
}
|
||||
else {
|
||||
TRACE("mpf_dbg", tout << "DENORMAL: " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "DENORMAL: " << m_mpz_manager.to_string(o.significand) << std::endl;);
|
||||
o.exponent = mk_bot_exp(o.ebits);
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "ROUNDED = " << to_string(o) << std::endl;
|
||||
TRACE(mpf_dbg, tout << "ROUNDED = " << to_string(o) << std::endl;
|
||||
tout << to_string_binary(o, -1, 0) << " (hidden bit, unbiased exp)." << std::endl;);
|
||||
}
|
||||
|
||||
void mpf_manager::round_sqrt(mpf_rounding_mode rm, mpf & o) {
|
||||
TRACE("mpf_dbg", tout << "RND-SQRT: " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "RND-SQRT: " << to_string(o) << std::endl;);
|
||||
|
||||
bool sticky = !m_mpz_manager.is_even(o.significand);
|
||||
m_mpz_manager.machine_div2k(o.significand, 1);
|
||||
|
@ -2118,14 +2118,14 @@ void mpf_manager::round_sqrt(mpf_rounding_mode rm, mpf & o) {
|
|||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
TRACE("mpf_dbg", tout << "last=" << last << " round=" << round << " sticky=" << sticky << " --> inc=" << inc << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "last=" << last << " round=" << round << " sticky=" << sticky << " --> inc=" << inc << std::endl;);
|
||||
|
||||
if (inc)
|
||||
m_mpz_manager.inc(o.significand);
|
||||
|
||||
m_mpz_manager.sub(o.significand, m_powers2(o.sbits-1), o.significand);
|
||||
|
||||
TRACE("mpf_dbg", tout << "ROUNDED = " << to_string(o) << std::endl;);
|
||||
TRACE(mpf_dbg, tout << "ROUNDED = " << to_string(o) << std::endl;);
|
||||
}
|
||||
|
||||
unsigned mpf_manager::prev_power_of_two(mpf const & a) {
|
||||
|
|
|
@ -326,13 +326,13 @@ void mpff_manager::set(mpff & n, mpff const & v) {
|
|||
|
||||
template<bool SYNCH>
|
||||
void mpff_manager::set_core(mpff & n, mpz_manager<SYNCH> & m, mpz const & v) {
|
||||
TRACE("mpff", tout << "mpz->mpff\n"; m.display(tout, v); tout << "\n";);
|
||||
TRACE(mpff, tout << "mpz->mpff\n"; m.display(tout, v); tout << "\n";);
|
||||
if (m.is_int64(v)) {
|
||||
TRACE("mpff", tout << "is_int64 " << m.get_int64(v) << "\n";);
|
||||
TRACE(mpff, tout << "is_int64 " << m.get_int64(v) << "\n";);
|
||||
set(n, m.get_int64(v));
|
||||
}
|
||||
else if (m.is_uint64(v)) {
|
||||
TRACE("mpff", tout << "is_uint64\n";);
|
||||
TRACE(mpff, tout << "is_uint64\n";);
|
||||
set(n, m.get_uint64(v));
|
||||
}
|
||||
else {
|
||||
|
@ -342,7 +342,7 @@ void mpff_manager::set_core(mpff & n, mpz_manager<SYNCH> & m, mpz const & v) {
|
|||
while (w.size() < m_precision) {
|
||||
w.push_back(0);
|
||||
}
|
||||
TRACE("mpff", tout << "w words: "; for (unsigned i = 0; i < w.size(); i++) tout << w[i] << " "; tout << "\n";);
|
||||
TRACE(mpff, tout << "w words: "; for (unsigned i = 0; i < w.size(); i++) tout << w[i] << " "; tout << "\n";);
|
||||
unsigned w_sz = w.size();
|
||||
SASSERT(w_sz >= m_precision);
|
||||
unsigned num_leading_zeros = nlz(w_sz, w.data());
|
||||
|
@ -368,7 +368,7 @@ void mpff_manager::set_core(mpff & n, mpz_manager<SYNCH> & m, mpz const & v) {
|
|||
// it is precise
|
||||
}
|
||||
}
|
||||
TRACE("mpff", tout << "mpz->mpff result:\n"; display_raw(tout, n); tout << "\n";);
|
||||
TRACE(mpff, tout << "mpz->mpff result:\n"; display_raw(tout, n); tout << "\n";);
|
||||
SASSERT(check(n));
|
||||
}
|
||||
|
||||
|
@ -422,14 +422,14 @@ bool mpff_manager::eq(mpff const & a, mpff const & b) const {
|
|||
}
|
||||
|
||||
bool mpff_manager::lt(mpff const & a, mpff const & b) const {
|
||||
STRACE("mpff_trace", tout << "[mpff] ("; display(tout, a); tout << " < "; display(tout, b); tout << ") == ";);
|
||||
STRACE(mpff_trace, tout << "[mpff] ("; display(tout, a); tout << " < "; display(tout, b); tout << ") == ";);
|
||||
if (is_zero(a)) {
|
||||
if (is_zero(b) || is_neg(b)) {
|
||||
STRACE("mpff_trace", tout << "(1 == 0)\n";);
|
||||
STRACE(mpff_trace, tout << "(1 == 0)\n";);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
STRACE("mpff_trace", tout << "(1 == 1)\n";);
|
||||
STRACE(mpff_trace, tout << "(1 == 1)\n";);
|
||||
SASSERT(is_pos(b));
|
||||
return true;
|
||||
}
|
||||
|
@ -437,12 +437,12 @@ bool mpff_manager::lt(mpff const & a, mpff const & b) const {
|
|||
if (is_zero(b)) {
|
||||
SASSERT(!is_zero(a));
|
||||
if (is_neg(a)) {
|
||||
STRACE("mpff_trace", tout << "(1 == 1)\n";);
|
||||
STRACE(mpff_trace, tout << "(1 == 1)\n";);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
SASSERT(is_pos(a));
|
||||
STRACE("mpff_trace", tout << "(1 == 0)\n";);
|
||||
STRACE(mpff_trace, tout << "(1 == 0)\n";);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -450,26 +450,26 @@ bool mpff_manager::lt(mpff const & a, mpff const & b) const {
|
|||
SASSERT(!is_zero(b));
|
||||
if (a.m_sign == 1) {
|
||||
if (b.m_sign == 0) {
|
||||
STRACE("mpff_trace", tout << "(1 == 1)\n";);
|
||||
STRACE(mpff_trace, tout << "(1 == 1)\n";);
|
||||
return true; // neg < pos
|
||||
}
|
||||
// case: neg neg
|
||||
bool r =
|
||||
b.m_exponent < a.m_exponent ||
|
||||
(a.m_exponent == b.m_exponent && ::lt(m_precision, sig(b), sig(a)));
|
||||
STRACE("mpff_trace", tout << "(" << r << " == 1)\n";);
|
||||
STRACE(mpff_trace, tout << "(" << r << " == 1)\n";);
|
||||
return r;
|
||||
}
|
||||
else {
|
||||
if (b.m_sign == 1) {
|
||||
STRACE("mpff_trace", tout << "(1 == 0)\n";);
|
||||
STRACE(mpff_trace, tout << "(1 == 0)\n";);
|
||||
return false; // pos < neg
|
||||
}
|
||||
// case: pos pos
|
||||
bool r =
|
||||
a.m_exponent < b.m_exponent ||
|
||||
(a.m_exponent == b.m_exponent && ::lt(m_precision, sig(a), sig(b)));
|
||||
STRACE("mpff_trace", tout << "(" << r << " == 1)\n";);
|
||||
STRACE(mpff_trace, tout << "(" << r << " == 1)\n";);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c
|
|||
return;
|
||||
}
|
||||
|
||||
TRACE("mpff", tout << (is_sub ? "sub" : "add") << "("; display(tout, a); tout << ", "; display(tout, b); tout << ")\n";);
|
||||
TRACE(mpff, tout << (is_sub ? "sub" : "add") << "("; display(tout, a); tout << ", "; display(tout, b); tout << ")\n";);
|
||||
|
||||
// Remark: any result returned by sig(...) may be invalid after a call to allocate_if_needed()
|
||||
// So, we must invoke allocate_if_needed(c) before we invoke sig(a) and sig(b).
|
||||
|
@ -766,30 +766,30 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c
|
|||
c.m_exponent = exp_a;
|
||||
}
|
||||
}
|
||||
TRACE("mpff", tout << "result: "; display(tout, c); tout << "\n";);
|
||||
TRACE(mpff, tout << "result: "; display(tout, c); tout << "\n";);
|
||||
SASSERT(check(c));
|
||||
}
|
||||
|
||||
void mpff_manager::add(mpff const & a, mpff const & b, mpff & c) {
|
||||
STRACE("mpff_trace", tout << "[mpff] "; display(tout, a); tout << " + "; display(tout, b); tout << " " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
STRACE(mpff_trace, tout << "[mpff] "; display(tout, a); tout << " + "; display(tout, b); tout << " " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
add_sub(false, a, b, c);
|
||||
STRACE("mpff_trace", display(tout, c); tout << "\n";);
|
||||
STRACE(mpff_trace, display(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpff_manager::sub(mpff const & a, mpff const & b, mpff & c) {
|
||||
STRACE("mpff_trace", tout << "[mpff] "; display(tout, a); tout << " - "; display(tout, b); tout << " " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
STRACE(mpff_trace, tout << "[mpff] "; display(tout, a); tout << " - "; display(tout, b); tout << " " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
add_sub(true, a, b, c);
|
||||
STRACE("mpff_trace", display(tout, c); tout << "\n";);
|
||||
STRACE(mpff_trace, display(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpff_manager::mul(mpff const & a, mpff const & b, mpff & c) {
|
||||
STRACE("mpff_trace", tout << "[mpff] ("; display(tout, a); tout << ") * ("; display(tout, b); tout << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
STRACE(mpff_trace, tout << "[mpff] ("; display(tout, a); tout << ") * ("; display(tout, b); tout << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
if (is_zero(a) || is_zero(b)) {
|
||||
reset(c);
|
||||
}
|
||||
else {
|
||||
allocate_if_needed(c);
|
||||
TRACE("mpff", tout << "mul("; display(tout, a); tout << ", "; display(tout, b); tout << ")\n";);
|
||||
TRACE(mpff, tout << "mul("; display(tout, a); tout << ", "; display(tout, b); tout << ")\n";);
|
||||
c.m_sign = a.m_sign ^ b.m_sign;
|
||||
// use int64_t to make sure we do not have overflows
|
||||
int64_t exp_a = a.m_exponent;
|
||||
|
@ -801,7 +801,7 @@ void mpff_manager::mul(mpff const & a, mpff const & b, mpff & c) {
|
|||
// r has 2*m_precision_bits bits
|
||||
unsigned num_leading_zeros = nlz(m_precision*2, r);
|
||||
SASSERT(num_leading_zeros <= m_precision_bits);
|
||||
TRACE("mpff", tout << "num_leading_zeros: " << num_leading_zeros << "\n";);
|
||||
TRACE(mpff, tout << "num_leading_zeros: " << num_leading_zeros << "\n";);
|
||||
// We must shift right (m_precision_bits - num_leading_zeros)
|
||||
// If r does not have a 1 bit in the first (m_precision_bits - num_leading_zeros), then the result is precise.
|
||||
unsigned shift = m_precision_bits - num_leading_zeros;
|
||||
|
@ -812,7 +812,7 @@ void mpff_manager::mul(mpff const & a, mpff const & b, mpff & c) {
|
|||
// 1) !c.m_sign && m_to_plus_inf
|
||||
// 2) c.m_sign && !m_to_plus_inf
|
||||
bool _inc_significand = ((c.m_sign == 1) != m_to_plus_inf) && has_one_at_first_k_bits(m_precision*2, r, shift);
|
||||
TRACE("mpff",
|
||||
TRACE(mpff,
|
||||
tout << "c.m_sign: " << c.m_sign << ", m_to_plus_inf: " << m_to_plus_inf
|
||||
<< "\nhas_one_at_first_k_bits: " << has_one_at_first_k_bits(m_precision*2, r, shift) << "\n";
|
||||
tout << "_inc_significand: " << _inc_significand << "\n";);
|
||||
|
@ -822,16 +822,16 @@ void mpff_manager::mul(mpff const & a, mpff const & b, mpff & c) {
|
|||
if (_inc_significand)
|
||||
inc_significand(s_c, exp_c);
|
||||
set_exponent(c, exp_c);
|
||||
TRACE("mpff", tout << "result: "; display(tout, c); tout << "\n";);
|
||||
TRACE(mpff, tout << "result: "; display(tout, c); tout << "\n";);
|
||||
SASSERT(check(c));
|
||||
}
|
||||
STRACE("mpff_trace", display(tout, c); tout << "\n";);
|
||||
STRACE(mpff_trace, display(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpff_manager::div(mpff const & a, mpff const & b, mpff & c) {
|
||||
if (is_zero(b))
|
||||
throw div0_exception();
|
||||
STRACE("mpff_trace", tout << "[mpff] ("; display(tout, a); tout << ") / ("; display(tout, b); tout << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
STRACE(mpff_trace, tout << "[mpff] ("; display(tout, a); tout << ") / ("; display(tout, b); tout << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
if (is_zero(a)) {
|
||||
reset(c);
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ void mpff_manager::div(mpff const & a, mpff const & b, mpff & c) {
|
|||
sig(b), m_precision,
|
||||
q,
|
||||
r);
|
||||
TRACE("mpff_div",
|
||||
TRACE(mpff_div,
|
||||
unsigned j = q_sz;
|
||||
while (j > 0) { --j; tout << std::hex << std::setfill('0') << std::setw(2*sizeof(unsigned)) << q[j]; tout << " "; }
|
||||
tout << std::dec << "\n";);
|
||||
|
@ -915,13 +915,13 @@ void mpff_manager::div(mpff const & a, mpff const & b, mpff & c) {
|
|||
set_exponent(c, exp_c);
|
||||
SASSERT(check(c));
|
||||
}
|
||||
STRACE("mpff_trace", display(tout, c); tout << "\n";);
|
||||
STRACE(mpff_trace, display(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpff_manager::floor(mpff & n) {
|
||||
if (n.m_exponent >= 0)
|
||||
return;
|
||||
STRACE("mpff_trace", tout << "[mpff] Floor["; display(tout, n); tout << "] == ";);
|
||||
STRACE(mpff_trace, tout << "[mpff] Floor["; display(tout, n); tout << "] == ";);
|
||||
if (n.m_exponent <= -static_cast<int>(m_precision_bits)) {
|
||||
// number is between (-1, 1)
|
||||
if (n.m_sign == 0)
|
||||
|
@ -951,13 +951,13 @@ void mpff_manager::floor(mpff & n) {
|
|||
}
|
||||
}
|
||||
SASSERT(check(n));
|
||||
STRACE("mpff_trace", display(tout, n); tout << "\n";);
|
||||
STRACE(mpff_trace, display(tout, n); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpff_manager::ceil(mpff & n) {
|
||||
if (n.m_exponent >= 0)
|
||||
return;
|
||||
STRACE("mpff_trace", tout << "[mpff] Ceiling["; display(tout, n); tout << "] == ";);
|
||||
STRACE(mpff_trace, tout << "[mpff] Ceiling["; display(tout, n); tout << "] == ";);
|
||||
if (n.m_exponent <= -static_cast<int>(m_precision_bits)) {
|
||||
// number is between (-1, 1)
|
||||
if (n.m_sign == 0)
|
||||
|
@ -987,7 +987,7 @@ void mpff_manager::ceil(mpff & n) {
|
|||
}
|
||||
}
|
||||
SASSERT(check(n));
|
||||
STRACE("mpff_trace", display(tout, n); tout << "\n";);
|
||||
STRACE(mpff_trace, display(tout, n); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpff_manager::power(mpff const & a, unsigned p, mpff & b) {
|
||||
|
@ -1053,8 +1053,8 @@ void mpff_manager::power(mpff const & a, unsigned p, mpff & b) {
|
|||
}
|
||||
}
|
||||
}
|
||||
STRACE("mpff_trace", tout << "[mpff] ("; display(tout, _a); tout << ") ^ " << _p << (m_to_plus_inf ? "<=" : ">="); display(tout, b); tout << "\n";);
|
||||
TRACE("mpff_power", display_raw(tout, b); tout << "\n";);
|
||||
STRACE(mpff_trace, tout << "[mpff] ("; display(tout, _a); tout << ") ^ " << _p << (m_to_plus_inf ? "<=" : ">="); display(tout, b); tout << "\n";);
|
||||
TRACE(mpff_power, display_raw(tout, b); tout << "\n";);
|
||||
SASSERT(check(b));
|
||||
}
|
||||
|
||||
|
@ -1124,7 +1124,7 @@ void mpff_manager::to_mpz(mpff const & n, synch_mpz_manager & m, mpz & t) {
|
|||
template<bool SYNCH>
|
||||
void mpff_manager::to_mpq_core(mpff const & n, mpq_manager<SYNCH> & m, mpq & t) {
|
||||
int exp = n.m_exponent;
|
||||
TRACE("mpff_to_mpq", tout << "to_mpq: "; display(tout, n); tout << "\nexp: " << exp << "\n";);
|
||||
TRACE(mpff_to_mpq, tout << "to_mpq: "; display(tout, n); tout << "\nexp: " << exp << "\n";);
|
||||
if (exp < 0 && exp > -static_cast<int>(m_precision_bits) && !has_one_at_first_k_bits(m_precision, sig(n), -n.m_exponent)) {
|
||||
to_buffer(0, n);
|
||||
unsigned * b = m_buffers[0].data();
|
||||
|
|
|
@ -334,7 +334,7 @@ bool mpfx_manager::eq(mpfx const & a, mpfx const & b) const {
|
|||
}
|
||||
|
||||
bool mpfx_manager::lt(mpfx const & a, mpfx const & b) const {
|
||||
STRACE("mpfx_trace", tout << "[mpfx] ("; display(tout, a); tout << " < "; display(tout, b); tout << ") == ";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] ("; display(tout, a); tout << " < "; display(tout, b); tout << ") == ";);
|
||||
bool r;
|
||||
if (is_zero(a)) {
|
||||
r = !is_zero(b) && !is_neg(b);
|
||||
|
@ -353,7 +353,7 @@ bool mpfx_manager::lt(mpfx const & a, mpfx const & b) const {
|
|||
r = is_pos(b) && ::lt(m_total_sz, words(a), words(b));
|
||||
}
|
||||
}
|
||||
STRACE("mpfx_trace", tout << "(" << r << " == 1)\n";);
|
||||
STRACE(mpfx_trace, tout << "(" << r << " == 1)\n";);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ void mpfx_manager::add_sub(bool is_sub, mpfx const & a, mpfx const & b, mpfx & c
|
|||
return;
|
||||
}
|
||||
|
||||
TRACE("mpfx", tout << (is_sub ? "sub" : "add") << "("; display(tout, a); tout << ", "; display(tout, b); tout << ")\n";);
|
||||
TRACE(mpfx, tout << (is_sub ? "sub" : "add") << "("; display(tout, a); tout << ", "; display(tout, b); tout << ")\n";);
|
||||
|
||||
allocate_if_needed(c);
|
||||
|
||||
|
@ -405,24 +405,24 @@ void mpfx_manager::add_sub(bool is_sub, mpfx const & a, mpfx const & b, mpfx & c
|
|||
}
|
||||
SASSERT(borrow == 0);
|
||||
}
|
||||
TRACE("mpfx", tout << "result: "; display(tout, c); tout << "\n";);
|
||||
TRACE(mpfx, tout << "result: "; display(tout, c); tout << "\n";);
|
||||
SASSERT(check(c));
|
||||
}
|
||||
|
||||
void mpfx_manager::add(mpfx const & a, mpfx const & b, mpfx & c) {
|
||||
STRACE("mpfx_trace", tout << "[mpfx] "; display(tout, a); tout << " + "; display(tout, b); tout << " == ";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] "; display(tout, a); tout << " + "; display(tout, b); tout << " == ";);
|
||||
add_sub(false, a, b, c);
|
||||
STRACE("mpfx_trace", display(tout, c); tout << "\n";);
|
||||
STRACE(mpfx_trace, display(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpfx_manager::sub(mpfx const & a, mpfx const & b, mpfx & c) {
|
||||
STRACE("mpfx_trace", tout << "[mpfx] "; display(tout, a); tout << " - "; display(tout, b); tout << " == ";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] "; display(tout, a); tout << " - "; display(tout, b); tout << " == ";);
|
||||
add_sub(true, a, b, c);
|
||||
STRACE("mpfx_trace", display(tout, c); tout << "\n";);
|
||||
STRACE(mpfx_trace, display(tout, c); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpfx_manager::mul(mpfx const & a, mpfx const & b, mpfx & c) {
|
||||
STRACE("mpfx_trace", tout << "[mpfx] ("; display(tout, a); tout << ") * ("; display(tout, b); tout << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] ("; display(tout, a); tout << ") * ("; display(tout, b); tout << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
if (is_zero(a) || is_zero(b)) {
|
||||
reset(c);
|
||||
}
|
||||
|
@ -445,14 +445,14 @@ void mpfx_manager::mul(mpfx const & a, mpfx const & b, mpfx & c) {
|
|||
for (unsigned i = 0; i < m_total_sz; i++)
|
||||
w_c[i] = _r[i];
|
||||
}
|
||||
STRACE("mpfx_trace", display(tout, c); tout << "\n";);
|
||||
STRACE(mpfx_trace, display(tout, c); tout << "\n";);
|
||||
SASSERT(check(c));
|
||||
}
|
||||
|
||||
void mpfx_manager::div(mpfx const & a, mpfx const & b, mpfx & c) {
|
||||
if (is_zero(b))
|
||||
throw div0_exception();
|
||||
STRACE("mpfx_trace", tout << "[mpfx] ("; display(tout, a); tout << ") / ("; display(tout, b); tout << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] ("; display(tout, a); tout << ") / ("; display(tout, b); tout << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
if (is_zero(a)) {
|
||||
reset(c);
|
||||
}
|
||||
|
@ -519,12 +519,12 @@ void mpfx_manager::div(mpfx const & a, mpfx const & b, mpfx & c) {
|
|||
}
|
||||
}
|
||||
}
|
||||
STRACE("mpfx_trace", display(tout, c); tout << "\n";);
|
||||
STRACE(mpfx_trace, display(tout, c); tout << "\n";);
|
||||
SASSERT(check(c));
|
||||
}
|
||||
|
||||
void mpfx_manager::div2k(mpfx & a, unsigned k) {
|
||||
STRACE("mpfx_trace", tout << "[mpfx] ("; display(tout, a); tout << ") / (2^" << k << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] ("; display(tout, a); tout << ") / (2^" << k << ") " << (m_to_plus_inf ? "<=" : ">=") << " ";);
|
||||
if (!is_zero(a) && k > 0) {
|
||||
unsigned * w = words(a);
|
||||
bool _inc = ((a.m_sign == 1) != m_to_plus_inf) && has_one_at_first_k_bits(m_total_sz, w, k);
|
||||
|
@ -537,7 +537,7 @@ void mpfx_manager::div2k(mpfx & a, unsigned k) {
|
|||
reset(a);
|
||||
}
|
||||
}
|
||||
STRACE("mpfx_trace", display(tout, a); tout << "\n";);
|
||||
STRACE(mpfx_trace, display(tout, a); tout << "\n";);
|
||||
SASSERT(check(a));
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ void mpfx_manager::set_plus_epsilon(mpfx & n) {
|
|||
}
|
||||
|
||||
void mpfx_manager::floor(mpfx & n) {
|
||||
STRACE("mpfx_trace", tout << "[mpfx] Floor["; display(tout, n); tout << "] == ";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] Floor["; display(tout, n); tout << "] == ";);
|
||||
unsigned * w = words(n);
|
||||
if (is_neg(n)) {
|
||||
bool is_int = true;
|
||||
|
@ -581,11 +581,11 @@ void mpfx_manager::floor(mpfx & n) {
|
|||
if (::is_zero(m_int_part_sz, w + m_frac_part_sz))
|
||||
reset(n);
|
||||
SASSERT(check(n));
|
||||
STRACE("mpfx_trace", display(tout, n); tout << "\n";);
|
||||
STRACE(mpfx_trace, display(tout, n); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpfx_manager::ceil(mpfx & n) {
|
||||
STRACE("mpfx_trace", tout << "[mpfx] Ceiling["; display(tout, n); tout << "] == ";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] Ceiling["; display(tout, n); tout << "] == ";);
|
||||
unsigned * w = words(n);
|
||||
if (is_pos(n)) {
|
||||
bool is_int = true;
|
||||
|
@ -605,7 +605,7 @@ void mpfx_manager::ceil(mpfx & n) {
|
|||
if (::is_zero(m_int_part_sz, w + m_frac_part_sz))
|
||||
reset(n);
|
||||
SASSERT(check(n));
|
||||
STRACE("mpfx_trace", display(tout, n); tout << "\n";);
|
||||
STRACE(mpfx_trace, display(tout, n); tout << "\n";);
|
||||
}
|
||||
|
||||
void mpfx_manager::power(mpfx const & a, unsigned p, mpfx & b) {
|
||||
|
@ -649,8 +649,8 @@ void mpfx_manager::power(mpfx const & a, unsigned p, mpfx & b) {
|
|||
mask = mask << 1;
|
||||
}
|
||||
}
|
||||
STRACE("mpfx_trace", tout << "[mpfx] ("; display(tout, _a); tout << ") ^ " << _p << (m_to_plus_inf ? "<=" : ">="); display(tout, b); tout << "\n";);
|
||||
TRACE("mpfx_power", display_raw(tout, b); tout << "\n";);
|
||||
STRACE(mpfx_trace, tout << "[mpfx] ("; display(tout, _a); tout << ") ^ " << _p << (m_to_plus_inf ? "<=" : ">="); display(tout, b); tout << "\n";);
|
||||
TRACE(mpfx_power, display_raw(tout, b); tout << "\n";);
|
||||
SASSERT(check(b));
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ int mpn_manager::compare(mpn_digit const * a, unsigned lnga,
|
|||
res = -1;
|
||||
}
|
||||
|
||||
TRACE("mpn", tout << ((res == 1) ? " > " : (res == -1) ? " < " : " == "); );
|
||||
TRACE(mpn, tout << ((res == 1) ? " > " : (res == -1) ? " < " : " == "); );
|
||||
|
||||
trace_nl(b, lngb);
|
||||
return res;
|
||||
|
@ -173,7 +173,7 @@ bool mpn_manager::div(mpn_digit const * numer, unsigned lnum,
|
|||
div_unnormalize(u, v, d, rem);
|
||||
}
|
||||
|
||||
// TRACE("mpn_dbg", display_raw(tout, quot, lnum - lden + 1); tout << ", ";
|
||||
// TRACE(mpn_dbg, display_raw(tout, quot, lnum - lden + 1); tout << ", ";
|
||||
// display_raw(tout, rem, lden); tout << std::endl; );
|
||||
trace_nl(quot, lnum-lden+1);
|
||||
|
||||
|
@ -189,7 +189,7 @@ bool mpn_manager::div(mpn_digit const * numer, unsigned lnum,
|
|||
for (unsigned i = 0; i < lnum && ok; i++)
|
||||
if (temp[i] != numer[i]) ok = false;
|
||||
if (temp[lnum] != 0) ok = false;
|
||||
CTRACE("mpn_dbg", !ok, tout << "DIV BUG: quot * denom + rem = "; display_raw(tout, temp.data(), lnum+1); tout << std::endl; );
|
||||
CTRACE(mpn_dbg, !ok, tout << "DIV BUG: quot * denom + rem = "; display_raw(tout, temp.data(), lnum+1); tout << std::endl; );
|
||||
SASSERT(ok);
|
||||
#endif
|
||||
|
||||
|
@ -230,7 +230,7 @@ unsigned mpn_manager::div_normalize(mpn_digit const * numer, unsigned lnum,
|
|||
d = 0;
|
||||
}
|
||||
|
||||
TRACE("mpn_norm", tout << "Normalized: n_numer="; display_raw(tout, n_numer.data(), n_numer.size());
|
||||
TRACE(mpn_norm, tout << "Normalized: n_numer="; display_raw(tout, n_numer.data(), n_numer.size());
|
||||
tout << " n_denom="; display_raw(tout, n_denom.data(), n_denom.size()); tout << std::endl; );
|
||||
return d;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ bool mpn_manager::div_1(mpn_sbuffer & numer, mpn_digit const denom,
|
|||
quot[j-1]--;
|
||||
numer[j] = numer[j-1] + denom;
|
||||
}
|
||||
TRACE("mpn_div1",
|
||||
TRACE(mpn_div1,
|
||||
mpn_double_digit r_hat = temp % (mpn_double_digit) denom;
|
||||
tout << "j=" << j << " q_hat=" << q_hat << " r_hat=" << r_hat;
|
||||
tout << " ms=" << ms;
|
||||
|
@ -323,7 +323,7 @@ bool mpn_manager::div_n(mpn_sbuffer & numer, mpn_sbuffer const & denom,
|
|||
for (unsigned i = 0; i < n+1; i++)
|
||||
numer[j+i] = ab[i];
|
||||
}
|
||||
TRACE("mpn_div", tout << "q_hat=" << q_hat << " r_hat=" << r_hat;
|
||||
TRACE(mpn_div, tout << "q_hat=" << q_hat << " r_hat=" << r_hat;
|
||||
tout << " ms="; display_raw(tout, ms.data(), n);
|
||||
tout << " new numer="; display_raw(tout, numer.data(), m+n+1);
|
||||
tout << " borrow=" << borrow;
|
||||
|
@ -335,7 +335,7 @@ bool mpn_manager::div_n(mpn_sbuffer & numer, mpn_sbuffer const & denom,
|
|||
|
||||
char * mpn_manager::to_string(mpn_digit const * a, unsigned lng, char * buf, unsigned lbuf) const {
|
||||
SASSERT(buf && lbuf > 0);
|
||||
TRACE("mpn_to_string", tout << "[mpn] to_string "; display_raw(tout, a, lng); tout << " == "; );
|
||||
TRACE(mpn_to_string, tout << "[mpn] to_string "; display_raw(tout, a, lng); tout << " == "; );
|
||||
|
||||
if (lng == 1) {
|
||||
#ifdef _WINDOWS
|
||||
|
@ -368,7 +368,7 @@ char * mpn_manager::to_string(mpn_digit const * a, unsigned lng, char * buf, uns
|
|||
std::swap(buf[i], buf[j-i]);
|
||||
}
|
||||
|
||||
TRACE("mpn_to_string", tout << buf << std::endl; );
|
||||
TRACE(mpn_to_string, tout << buf << std::endl; );
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ void mpn_manager::trace(mpn_digit const * a, unsigned lnga,
|
|||
const char * op) const {
|
||||
#ifdef Z3DEBUG
|
||||
char char_buf[4096];
|
||||
TRACE("mpn", tout << "[mpn] " << to_string(a, lnga, char_buf, sizeof(char_buf));
|
||||
TRACE(mpn, tout << "[mpn] " << to_string(a, lnga, char_buf, sizeof(char_buf));
|
||||
tout << " " << op << " " << to_string(b, lngb, char_buf, sizeof(char_buf));
|
||||
tout << " == "; );
|
||||
#endif
|
||||
|
@ -393,13 +393,13 @@ void mpn_manager::trace(mpn_digit const * a, unsigned lnga,
|
|||
void mpn_manager::trace(mpn_digit const * a, unsigned lnga) const {
|
||||
#ifdef Z3DEBUG
|
||||
char char_buf[4096];
|
||||
TRACE("mpn", tout << to_string(a, lnga, char_buf, sizeof(char_buf)); );
|
||||
TRACE(mpn, tout << to_string(a, lnga, char_buf, sizeof(char_buf)); );
|
||||
#endif
|
||||
}
|
||||
|
||||
void mpn_manager::trace_nl(mpn_digit const * a, unsigned lnga) const {
|
||||
#ifdef Z3DEBUG
|
||||
char char_buf[4096];
|
||||
TRACE("mpn", tout << to_string(a, lnga, char_buf, sizeof(char_buf)) << std::endl; );
|
||||
TRACE(mpn, tout << to_string(a, lnga, char_buf, sizeof(char_buf)) << std::endl; );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ void mpq_manager<SYNCH>::set(mpq & a, char const * val) {
|
|||
}
|
||||
++str;
|
||||
}
|
||||
TRACE("mpq_set", tout << "[before] a: " << to_string(a) << "\n";);
|
||||
TRACE(mpq_set, tout << "[before] a: " << to_string(a) << "\n";);
|
||||
if (str[0] == '/' || str[0] == '.' || str[0] == 'e' || str[0] == 'E') {
|
||||
bool is_rat = str[0] == '/';
|
||||
_scoped_numeral<mpz_manager<SYNCH> > tmp2(*this);
|
||||
|
@ -239,7 +239,7 @@ void mpq_manager<SYNCH>::set(mpq & a, char const * val) {
|
|||
else if ('/' == str[0]) {
|
||||
throw default_exception("mixing rational/scientific notation");
|
||||
}
|
||||
TRACE("mpq_set", tout << "[exp]: " << exp << ", str[0]: " << (str[0] - '0') << std::endl;);
|
||||
TRACE(mpq_set, tout << "[exp]: " << exp << ", str[0]: " << (str[0] - '0') << std::endl;);
|
||||
++str;
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ void mpq_manager<SYNCH>::set(mpq & a, char const * val) {
|
|||
_scoped_numeral<mpq_manager<SYNCH>> _qten(*this);
|
||||
_qten = 10;
|
||||
power(_qten, static_cast<unsigned>(exp), _exp);
|
||||
TRACE("mpq_set", tout << "a: " << to_string(a) << ", exp_sign:" << exp_sign << ", exp: " << exp << " " << to_string(_exp) << std::endl;);
|
||||
TRACE(mpq_set, tout << "a: " << to_string(a) << ", exp_sign:" << exp_sign << ", exp: " << exp << " " << to_string(_exp) << std::endl;);
|
||||
if (exp_sign)
|
||||
div(a, _exp, a);
|
||||
else
|
||||
|
@ -371,17 +371,17 @@ void mpq_manager<SYNCH>::rat_mul(mpq const & a, mpq const & b, mpq & c, mpz& g1,
|
|||
|
||||
template<bool SYNCH>
|
||||
void mpq_manager<SYNCH>::rat_mul(mpz const & a, mpq const & b, mpq & c) {
|
||||
STRACE("rat_mpq", tout << "[mpq] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
STRACE(rat_mpq, tout << "[mpq] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
mul(a, b.m_num, c.m_num);
|
||||
set(c.m_den, b.m_den);
|
||||
normalize(c);
|
||||
STRACE("rat_mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(rat_mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpq_manager<SYNCH>::rat_mul(mpq const & a, mpq const & b, mpq & c) {
|
||||
STRACE("rat_mpq", tout << "[mpq] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
STRACE(rat_mpq, tout << "[mpq] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
if (SYNCH) {
|
||||
mpz g1, g2, tmp1, tmp2;
|
||||
rat_mul(a, b, c, g1, g2, tmp1, tmp2);
|
||||
|
@ -393,12 +393,12 @@ void mpq_manager<SYNCH>::rat_mul(mpq const & a, mpq const & b, mpq & c) {
|
|||
else {
|
||||
rat_mul(a, b, c, m_tmp1, m_tmp2, m_tmp3, m_tmp4);
|
||||
}
|
||||
STRACE("rat_mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(rat_mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpq_manager<SYNCH>::rat_add(mpq const & a, mpq const & b, mpq & c) {
|
||||
STRACE("rat_mpq", tout << "[mpq] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
STRACE(rat_mpq, tout << "[mpq] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
if (SYNCH) {
|
||||
mpz_stack tmp1, tmp2, tmp3, g;
|
||||
lin_arith_op<false>(a, b, c, g, tmp1, tmp2, tmp3);
|
||||
|
@ -410,12 +410,12 @@ void mpq_manager<SYNCH>::rat_add(mpq const & a, mpq const & b, mpq & c) {
|
|||
else {
|
||||
lin_arith_op<false>(a, b, c, m_tmp1, m_tmp2, m_tmp3, m_tmp4);
|
||||
}
|
||||
STRACE("rat_mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(rat_mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpq_manager<SYNCH>::rat_sub(mpq const & a, mpq const & b, mpq & c) {
|
||||
STRACE("rat_mpq", tout << "[mpq] " << to_string(a) << " - " << to_string(b) << " == ";);
|
||||
STRACE(rat_mpq, tout << "[mpq] " << to_string(a) << " - " << to_string(b) << " == ";);
|
||||
if (SYNCH) {
|
||||
mpz tmp1, tmp2, tmp3, g;
|
||||
lin_arith_op<true>(a, b, c, g, tmp1, tmp2, tmp3);
|
||||
|
@ -427,7 +427,7 @@ void mpq_manager<SYNCH>::rat_sub(mpq const & a, mpq const & b, mpq & c) {
|
|||
else {
|
||||
lin_arith_op<true>(a, b, c, m_tmp1, m_tmp2, m_tmp3, m_tmp4);
|
||||
}
|
||||
STRACE("rat_mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(rat_mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class mpq_manager : public mpz_manager<SYNCH> {
|
|||
void rat_add(mpq const & a, mpq const & b, mpq & c);
|
||||
|
||||
void rat_add(mpq const & a, mpz const & b, mpq & c) {
|
||||
STRACE("rat_mpq", tout << "[mpq] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
STRACE(rat_mpq, tout << "[mpq] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
if (SYNCH) {
|
||||
mpz tmp1;
|
||||
mul(b, a.m_den, tmp1);
|
||||
|
@ -89,7 +89,7 @@ class mpq_manager : public mpz_manager<SYNCH> {
|
|||
add(a.m_num, m_tmp1, c.m_num);
|
||||
normalize(c);
|
||||
}
|
||||
STRACE("rat_mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(rat_mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
void rat_sub(mpq const & a, mpq const & b, mpq & c);
|
||||
|
@ -228,7 +228,7 @@ public:
|
|||
void add(mpz const & a, mpz const & b, mpz & c) { mpz_manager<SYNCH>::add(a, b, c); }
|
||||
|
||||
void add(mpq const & a, mpq const & b, mpq & c) {
|
||||
STRACE("mpq", tout << "[mpq] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
STRACE(mpq, tout << "[mpq] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
if (is_zero(b)) {
|
||||
set(c, a);
|
||||
}
|
||||
|
@ -242,11 +242,11 @@ public:
|
|||
else {
|
||||
rat_add(a, b, c);
|
||||
}
|
||||
STRACE("mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
void add(mpq const & a, mpz const & b, mpq & c) {
|
||||
STRACE("mpq", tout << "[mpq] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
STRACE(mpq, tout << "[mpq] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
if (is_zero(b)) {
|
||||
set(c, a);
|
||||
}
|
||||
|
@ -260,20 +260,20 @@ public:
|
|||
else {
|
||||
rat_add(a, b, c);
|
||||
}
|
||||
STRACE("mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
void sub(mpz const & a, mpz const & b, mpz & c) { mpz_manager<SYNCH>::sub(a, b, c); }
|
||||
|
||||
void sub(mpq const & a, mpq const & b, mpq & c) {
|
||||
STRACE("mpq", tout << "[mpq] " << to_string(a) << " - " << to_string(b) << " == ";);
|
||||
STRACE(mpq, tout << "[mpq] " << to_string(a) << " - " << to_string(b) << " == ";);
|
||||
if (is_int(a) && is_int(b)) {
|
||||
mpz_manager<SYNCH>::sub(a.m_num, b.m_num, c.m_num);
|
||||
reset_denominator(c);
|
||||
}
|
||||
else
|
||||
rat_sub(a, b, c);
|
||||
STRACE("mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
void inc(mpz & a) { mpz_manager<SYNCH>::inc(a); }
|
||||
|
@ -292,25 +292,25 @@ public:
|
|||
}
|
||||
|
||||
void mul(mpq const & a, mpq const & b, mpq & c) {
|
||||
STRACE("mpq", tout << "[mpq] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
STRACE(mpq, tout << "[mpq] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
if (is_int(a) && is_int(b)) {
|
||||
mpz_manager<SYNCH>::mul(a.m_num, b.m_num, c.m_num);
|
||||
reset_denominator(c);
|
||||
}
|
||||
else
|
||||
rat_mul(a, b, c);
|
||||
STRACE("mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
void mul(mpz const & a, mpq const & b, mpq & c) {
|
||||
STRACE("mpq", tout << "[mpq] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
STRACE(mpq, tout << "[mpq] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
if (is_int(b)) {
|
||||
mpz_manager<SYNCH>::mul(a, b.m_num, c.m_num);
|
||||
reset_denominator(c);
|
||||
}
|
||||
else
|
||||
rat_mul(a, b, c);
|
||||
STRACE("mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
void addmul(mpz const & a, mpz const & b, mpz const & c, mpz & d) {
|
||||
|
@ -431,7 +431,7 @@ public:
|
|||
}
|
||||
|
||||
void div(mpq const & a, mpq const & b, mpq & c) {
|
||||
STRACE("mpq", tout << "[mpq] " << to_string(a) << " / " << to_string(b) << " == ";);
|
||||
STRACE(mpq, tout << "[mpq] " << to_string(a) << " / " << to_string(b) << " == ";);
|
||||
if (is_zero(a) || is_one(b)) {
|
||||
set(c, a);
|
||||
return;
|
||||
|
@ -453,11 +453,11 @@ public:
|
|||
neg(c.m_den);
|
||||
}
|
||||
normalize(c);
|
||||
STRACE("mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
void div(mpq const & a, mpz const & b, mpq & c) {
|
||||
STRACE("mpq", tout << "[mpq] " << to_string(a) << " / " << to_string(b) << " == ";);
|
||||
STRACE(mpq, tout << "[mpq] " << to_string(a) << " / " << to_string(b) << " == ";);
|
||||
if (is_zero(a) || is_one(b)) {
|
||||
set(c, a);
|
||||
return;
|
||||
|
@ -469,18 +469,18 @@ public:
|
|||
neg(c.m_den);
|
||||
}
|
||||
normalize(c);
|
||||
STRACE("mpq", tout << to_string(c) << "\n";);
|
||||
STRACE(mpq, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
void acc_div(mpq & a, mpz const & b) {
|
||||
STRACE("mpq", tout << "[mpq] " << to_string(a) << " / " << to_string(b) << " == ";);
|
||||
STRACE(mpq, tout << "[mpq] " << to_string(a) << " / " << to_string(b) << " == ";);
|
||||
mul(a.m_den, b, a.m_den);
|
||||
if (mpz_manager<SYNCH>::is_neg(b)) {
|
||||
neg(a.m_num);
|
||||
neg(a.m_den);
|
||||
}
|
||||
normalize(a);
|
||||
STRACE("mpq", tout << to_string(a) << "\n";);
|
||||
STRACE(mpq, tout << to_string(a) << "\n";);
|
||||
}
|
||||
|
||||
void machine_div(mpz const & a, mpz const & b, mpz & c) { mpz_manager<SYNCH>::machine_div(a, b, c); }
|
||||
|
|
|
@ -251,26 +251,26 @@ void mpz_manager<SYNCH>::del(mpz_manager<SYNCH>* m, mpz & a) {
|
|||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::add(mpz const & a, mpz const & b, mpz & c) {
|
||||
STRACE("mpz", tout << "[mpz] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
STRACE(mpz, tout << "[mpz] " << to_string(a) << " + " << to_string(b) << " == ";);
|
||||
if (is_small(a) && is_small(b)) {
|
||||
set_i64(c, i64(a) + i64(b));
|
||||
}
|
||||
else {
|
||||
big_add(a, b, c);
|
||||
}
|
||||
STRACE("mpz", tout << to_string(c) << "\n";);
|
||||
STRACE(mpz, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::sub(mpz const & a, mpz const & b, mpz & c) {
|
||||
STRACE("mpz", tout << "[mpz] " << to_string(a) << " - " << to_string(b) << " == ";);
|
||||
STRACE(mpz, tout << "[mpz] " << to_string(a) << " - " << to_string(b) << " == ";);
|
||||
if (is_small(a) && is_small(b)) {
|
||||
set_i64(c, i64(a) - i64(b));
|
||||
}
|
||||
else {
|
||||
big_sub(a, b, c);
|
||||
}
|
||||
STRACE("mpz", tout << to_string(c) << "\n";);
|
||||
STRACE(mpz, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
|
@ -507,14 +507,14 @@ void mpz_manager<SYNCH>::set_digits(mpz & target, unsigned sz, digit_t const * d
|
|||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::mul(mpz const & a, mpz const & b, mpz & c) {
|
||||
STRACE("mpz", tout << "[mpz] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
STRACE(mpz, tout << "[mpz] " << to_string(a) << " * " << to_string(b) << " == ";);
|
||||
if (is_small(a) && is_small(b)) {
|
||||
set_i64(c, i64(a) * i64(b));
|
||||
}
|
||||
else {
|
||||
big_mul(a, b, c);
|
||||
}
|
||||
STRACE("mpz", tout << to_string(c) << "\n";);
|
||||
STRACE(mpz, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
// d <- a + b*c
|
||||
|
@ -555,7 +555,7 @@ void mpz_manager<SYNCH>::submul(mpz const & a, mpz const & b, mpz const & c, mpz
|
|||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::machine_div_rem(mpz const & a, mpz const & b, mpz & q, mpz & r) {
|
||||
STRACE("mpz", tout << "[mpz-ext] divrem(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
STRACE(mpz, tout << "[mpz-ext] divrem(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
if (is_small(a) && is_small(b)) {
|
||||
int64_t _a = i64(a);
|
||||
int64_t _b = i64(b);
|
||||
|
@ -565,12 +565,12 @@ void mpz_manager<SYNCH>::machine_div_rem(mpz const & a, mpz const & b, mpz & q,
|
|||
else {
|
||||
big_div_rem(a, b, q, r);
|
||||
}
|
||||
STRACE("mpz", tout << "(" << to_string(q) << ", " << to_string(r) << ")\n";);
|
||||
STRACE(mpz, tout << "(" << to_string(q) << ", " << to_string(r) << ")\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::machine_div(mpz const & a, mpz const & b, mpz & c) {
|
||||
STRACE("mpz", tout << "[mpz-ext] machine-div(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
STRACE(mpz, tout << "[mpz-ext] machine-div(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
if (is_small(b) && i64(b) == 0)
|
||||
throw default_exception("division by 0");
|
||||
|
||||
|
@ -578,7 +578,7 @@ void mpz_manager<SYNCH>::machine_div(mpz const & a, mpz const & b, mpz & c) {
|
|||
set_i64(c, i64(a) / i64(b));
|
||||
else
|
||||
big_div(a, b, c);
|
||||
STRACE("mpz", tout << to_string(c) << "\n";);
|
||||
STRACE(mpz, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
|
@ -589,32 +589,32 @@ void mpz_manager<SYNCH>::reset(mpz & a) {
|
|||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::rem(mpz const & a, mpz const & b, mpz & c) {
|
||||
STRACE("mpz", tout << "[mpz-ext] rem(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
STRACE(mpz, tout << "[mpz-ext] rem(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
if (is_small(a) && is_small(b)) {
|
||||
set_i64(c, i64(a) % i64(b));
|
||||
}
|
||||
else {
|
||||
big_rem(a, b, c);
|
||||
}
|
||||
STRACE("mpz", tout << to_string(c) << "\n";);
|
||||
STRACE(mpz, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::div_gcd(mpz const& a, mpz const& b, mpz & c) {
|
||||
STRACE("mpz", tout << "[mpz-ext] div(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
STRACE(mpz, tout << "[mpz-ext] div(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
if (is_one(b)) {
|
||||
set(c, a);
|
||||
}
|
||||
else {
|
||||
machine_div(a, b, c);
|
||||
}
|
||||
STRACE("mpz", tout << to_string(c) << "\n";);
|
||||
STRACE(mpz, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::div(mpz const & a, mpz const & b, mpz & c) {
|
||||
STRACE("mpz", tout << "[mpz-ext] div(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
STRACE(mpz, tout << "[mpz-ext] div(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
SASSERT(!is_zero(b));
|
||||
if (is_one(b)) {
|
||||
set(c, a);
|
||||
|
@ -633,12 +633,12 @@ void mpz_manager<SYNCH>::div(mpz const & a, mpz const & b, mpz & c) {
|
|||
else {
|
||||
machine_div(a, b, c);
|
||||
}
|
||||
STRACE("mpz", tout << to_string(c) << "\n";);
|
||||
STRACE(mpz, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::mod(mpz const & a, mpz const & b, mpz & c) {
|
||||
STRACE("mpz", tout << "[mpz-ext] mod(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
STRACE(mpz, tout << "[mpz-ext] mod(" << to_string(a) << ", " << to_string(b) << ") == ";);
|
||||
rem(a, b, c);
|
||||
if (is_neg(c)) {
|
||||
if (is_pos(b))
|
||||
|
@ -646,12 +646,12 @@ void mpz_manager<SYNCH>::mod(mpz const & a, mpz const & b, mpz & c) {
|
|||
else
|
||||
sub(c, b, c);
|
||||
}
|
||||
STRACE("mpz", tout << to_string(c) << "\n";);
|
||||
STRACE(mpz, tout << to_string(c) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::neg(mpz & a) {
|
||||
STRACE("mpz", tout << "[mpz] 0 - " << to_string(a) << " == ";);
|
||||
STRACE(mpz, tout << "[mpz] 0 - " << to_string(a) << " == ";);
|
||||
if (is_small(a) && a.m_val == INT_MIN) {
|
||||
// neg(INT_MIN) is not a small int
|
||||
set_big_i64(a, - static_cast<long long>(INT_MIN));
|
||||
|
@ -667,7 +667,7 @@ void mpz_manager<SYNCH>::neg(mpz & a) {
|
|||
mpz_neg(*a.m_ptr, *a.m_ptr);
|
||||
}
|
||||
#endif
|
||||
STRACE("mpz", tout << to_string(a) << "\n";);
|
||||
STRACE(mpz, tout << to_string(a) << "\n";);
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
|
@ -1198,7 +1198,7 @@ void mpz_manager<SYNCH>::gcd(unsigned sz, mpz const * as, mpz & g) {
|
|||
p.push_back(i);
|
||||
sz_lt lt(*this, as);
|
||||
std::sort(p.begin(), p.end(), lt);
|
||||
TRACE("mpz_gcd", for (unsigned i = 0; i < sz; i++) tout << p[i] << ":" << size_info(as[p[i]]) << " "; tout << "\n";);
|
||||
TRACE(mpz_gcd, for (unsigned i = 0; i < sz; i++) tout << p[i] << ":" << size_info(as[p[i]]) << " "; tout << "\n";);
|
||||
gcd(as[p[0]], as[p[1]], g);
|
||||
for (i = 2; i < sz; i++) {
|
||||
if (is_one(g))
|
||||
|
@ -1311,30 +1311,30 @@ template<bool SYNCH>
|
|||
void mpz_manager<SYNCH>::lcm(mpz const & a, mpz const & b, mpz & c) {
|
||||
if (is_one(b)) {
|
||||
set(c, a);
|
||||
TRACE("lcm_bug", tout << "1. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
TRACE(lcm_bug, tout << "1. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
}
|
||||
else if (is_one(a) || eq(a, b)) {
|
||||
set(c, b);
|
||||
TRACE("lcm_bug", tout << "2. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
TRACE(lcm_bug, tout << "2. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
}
|
||||
else {
|
||||
mpz r;
|
||||
gcd(a, b, r);
|
||||
TRACE("lcm_bug", tout << "gcd(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(r) << "\n";);
|
||||
TRACE(lcm_bug, tout << "gcd(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(r) << "\n";);
|
||||
if (eq(r, a)) {
|
||||
set(c, b);
|
||||
TRACE("lcm_bug", tout << "3. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
TRACE(lcm_bug, tout << "3. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
}
|
||||
else if (eq(r, b)) {
|
||||
set(c, a);
|
||||
TRACE("lcm_bug", tout << "4. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
TRACE(lcm_bug, tout << "4. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
}
|
||||
else {
|
||||
// c contains gcd(a, b)
|
||||
// so c divides a, and machine_div(a, c) is equal to div(a, c)
|
||||
machine_div(a, r, r);
|
||||
mul(r, b, c);
|
||||
TRACE("lcm_bug", tout << "5. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
TRACE(lcm_bug, tout << "5. lcm(" << to_string(a) << ", " << to_string(b) << ") = " << to_string(c) << "\n";);
|
||||
}
|
||||
del(r);
|
||||
}
|
||||
|
@ -1344,7 +1344,7 @@ template<bool SYNCH>
|
|||
void mpz_manager<SYNCH>::bitwise_or(mpz const & a, mpz const & b, mpz & c) {
|
||||
SASSERT(is_nonneg(a));
|
||||
SASSERT(is_nonneg(b));
|
||||
TRACE("mpz", tout << "is_small(a): " << is_small(a) << ", is_small(b): " << is_small(b) << "\n";);
|
||||
TRACE(mpz, tout << "is_small(a): " << is_small(a) << ", is_small(b): " << is_small(b) << "\n";);
|
||||
if (is_small(a) && is_small(b)) {
|
||||
c.m_val = a.m_val | b.m_val;
|
||||
c.m_kind = mpz_small;
|
||||
|
@ -1357,12 +1357,12 @@ void mpz_manager<SYNCH>::bitwise_or(mpz const & a, mpz const & b, mpz & c) {
|
|||
set(m, 1);
|
||||
set(c, 0);
|
||||
while (!is_zero(a1) && !is_zero(b1)) {
|
||||
TRACE("mpz", tout << "a1: " << to_string(a1) << ", b1: " << to_string(b1) << "\n";);
|
||||
TRACE(mpz, tout << "a1: " << to_string(a1) << ", b1: " << to_string(b1) << "\n";);
|
||||
mod(a1, m_two64, a2);
|
||||
mod(b1, m_two64, b2);
|
||||
TRACE("mpz", tout << "a2: " << to_string(a2) << ", b2: " << to_string(b2) << "\n";);
|
||||
TRACE(mpz, tout << "a2: " << to_string(a2) << ", b2: " << to_string(b2) << "\n";);
|
||||
uint64_t v = get_uint64(a2) | get_uint64(b2);
|
||||
TRACE("mpz", tout << "uint(a2): " << get_uint64(a2) << ", uint(b2): " << get_uint64(b2) << "\n";);
|
||||
TRACE(mpz, tout << "uint(a2): " << get_uint64(a2) << ", uint(b2): " << get_uint64(b2) << "\n";);
|
||||
set(tmp, v);
|
||||
mul(tmp, m, tmp);
|
||||
add(c, tmp, c); // c += m * v
|
||||
|
@ -1487,7 +1487,7 @@ void mpz_manager<SYNCH>::bitwise_not(unsigned sz, mpz const & a, mpz & c) {
|
|||
uint64_t mask = (1ull << static_cast<uint64_t>(sz)) - 1ull;
|
||||
v = mask & v;
|
||||
}
|
||||
TRACE("bitwise_not", tout << "sz: " << sz << ", v: " << v << ", n: " << n << "\n";);
|
||||
TRACE(bitwise_not, tout << "sz: " << sz << ", v: " << v << ", n: " << n << "\n";);
|
||||
set(tmp, v);
|
||||
SASSERT(get_uint64(tmp) == v);
|
||||
mul(tmp, m, tmp);
|
||||
|
@ -1497,7 +1497,7 @@ void mpz_manager<SYNCH>::bitwise_not(unsigned sz, mpz const & a, mpz & c) {
|
|||
sz -= (sz<64) ? sz : 64;
|
||||
}
|
||||
del(a1); del(a2); del(m); del(tmp);
|
||||
TRACE("bitwise_not", tout << "sz: " << sz << " a: " << to_string(a) << " c: " << to_string(c) << "\n";);
|
||||
TRACE(bitwise_not, tout << "sz: " << sz << " a: " << to_string(a) << " c: " << to_string(c) << "\n";);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2072,7 +2072,7 @@ void mpz_manager<SYNCH>::machine_div2k(mpz & a, unsigned k) {
|
|||
unsigned new_sz = sz - digit_shift;
|
||||
SASSERT(new_sz >= 1);
|
||||
digit_t * ds = c->m_digits;
|
||||
TRACE("mpz_2k", tout << "bit_shift: " << bit_shift << ", comp_shift: " << comp_shift << ", new_sz: " << new_sz << ", sz: " << sz << "\n";);
|
||||
TRACE(mpz_2k, tout << "bit_shift: " << bit_shift << ", comp_shift: " << comp_shift << ", new_sz: " << new_sz << ", sz: " << sz << "\n";);
|
||||
if (new_sz < sz) {
|
||||
unsigned i = 0;
|
||||
unsigned j = digit_shift;
|
||||
|
@ -2123,13 +2123,13 @@ void mpz_manager<SYNCH>::mul2k(mpz & a, unsigned k) {
|
|||
return;
|
||||
}
|
||||
#ifndef _MP_GMP
|
||||
TRACE("mpz_mul2k", tout << "mul2k\na: " << to_string(a) << "\nk: " << k << "\n";);
|
||||
TRACE(mpz_mul2k, tout << "mul2k\na: " << to_string(a) << "\nk: " << k << "\n";);
|
||||
unsigned word_shift = k / (8 * sizeof(digit_t));
|
||||
unsigned bit_shift = k % (8 * sizeof(digit_t));
|
||||
unsigned old_sz = is_small(a) ? 1 : a.m_ptr->m_size;
|
||||
unsigned new_sz = old_sz + word_shift + 1;
|
||||
ensure_capacity(a, new_sz);
|
||||
TRACE("mpz_mul2k", tout << "word_shift: " << word_shift << "\nbit_shift: " << bit_shift << "\nold_sz: " << old_sz << "\nnew_sz: " << new_sz
|
||||
TRACE(mpz_mul2k, tout << "word_shift: " << word_shift << "\nbit_shift: " << bit_shift << "\nold_sz: " << old_sz << "\nnew_sz: " << new_sz
|
||||
<< "\na after ensure capacity:\n" << to_string(a) << "\n";
|
||||
tout << a.m_kind << "\n";);
|
||||
SASSERT(!is_small(a));
|
||||
|
@ -2168,7 +2168,7 @@ void mpz_manager<SYNCH>::mul2k(mpz & a, unsigned k) {
|
|||
}
|
||||
}
|
||||
normalize(a);
|
||||
TRACE("mpz_mul2k", tout << "mul2k result:\n" << to_string(a) << "\n";);
|
||||
TRACE(mpz_mul2k, tout << "mul2k result:\n" << to_string(a) << "\n";);
|
||||
#else
|
||||
ensure_mpz_t a1(a);
|
||||
mk_big(a);
|
||||
|
@ -2425,7 +2425,7 @@ bool mpz_manager<SYNCH>::root(mpz & a, unsigned n) {
|
|||
while (true) {
|
||||
add(upper, lower, mid);
|
||||
machine_div2k(mid, 1);
|
||||
TRACE("mpz", tout << "upper: "; display(tout, upper); tout << "\nlower: "; display(tout, lower); tout << "\nmid: "; display(tout, mid); tout << "\n";);
|
||||
TRACE(mpz, tout << "upper: "; display(tout, upper); tout << "\nlower: "; display(tout, lower); tout << "\nmid: "; display(tout, mid); tout << "\n";);
|
||||
power(mid, n, mid_n);
|
||||
if (eq(mid_n, a)) {
|
||||
swap(a, mid);
|
||||
|
@ -2534,8 +2534,8 @@ bool mpz_manager<SYNCH>::divides(mpz const & a, mpz const & b) {
|
|||
rem(b, a, tmp);
|
||||
r = is_zero(tmp);
|
||||
}
|
||||
STRACE("divides", tout << "[mpz] Divisible["; display(tout, b); tout << ", "; display(tout, a); tout << "] == " << (r?"True":"False") << "\n";);
|
||||
TRACE("divides_bug", tout << "tmp: "; display(tout, tmp); tout << "\n";);
|
||||
STRACE(divides, tout << "[mpz] Divisible["; display(tout, b); tout << ", "; display(tout, a); tout << "] == " << (r?"True":"False") << "\n";);
|
||||
TRACE(divides_bug, tout << "tmp: "; display(tout, tmp); tout << "\n";);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class mpzzp_manager {
|
|||
if (even) {
|
||||
m().inc(m_lower);
|
||||
}
|
||||
TRACE("mpzzp", tout << "lower: " << m_manager.to_string(m_lower) << ", upper: " << m_manager.to_string(m_upper) << "\n";);
|
||||
TRACE(mpzzp, tout << "lower: " << m_manager.to_string(m_lower) << ", upper: " << m_manager.to_string(m_upper) << "\n";);
|
||||
}
|
||||
|
||||
void p_normalize_core(mpz & x) {
|
||||
|
@ -171,11 +171,11 @@ public:
|
|||
SASSERT(!is_zero(a));
|
||||
// eulers theorem a^(p - 2), but gcd could be more efficient
|
||||
// a*t1 + p*t2 = 1 => a*t1 = 1 (mod p) => t1 is the inverse (t3 == 1)
|
||||
TRACE("mpzp_inv_bug", tout << "a: " << m().to_string(a) << ", p: " << m().to_string(m_p) << "\n";);
|
||||
TRACE(mpzp_inv_bug, tout << "a: " << m().to_string(a) << ", p: " << m().to_string(m_p) << "\n";);
|
||||
p_normalize(a);
|
||||
TRACE("mpzp_inv_bug", tout << "after normalization a: " << m().to_string(a) << "\n";);
|
||||
TRACE(mpzp_inv_bug, tout << "after normalization a: " << m().to_string(a) << "\n";);
|
||||
m().gcd(a, m_p, m_inv_tmp1, m_inv_tmp2, m_inv_tmp3);
|
||||
TRACE("mpzp_inv_bug", tout << "tmp1: " << m().to_string(m_inv_tmp1) << "\ntmp2: " << m().to_string(m_inv_tmp2)
|
||||
TRACE(mpzp_inv_bug, tout << "tmp1: " << m().to_string(m_inv_tmp1) << "\ntmp2: " << m().to_string(m_inv_tmp2)
|
||||
<< "\ntmp3: " << m().to_string(m_inv_tmp3) << "\n";);
|
||||
p_normalize(m_inv_tmp1);
|
||||
m().swap(a, m_inv_tmp1);
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
++mem;
|
||||
value * r = reinterpret_cast<value*>(mem);
|
||||
SASSERT(capacity(r) == c);
|
||||
TRACE("parray_mem", tout << "allocated values[" << c << "]: " << r << "\n";);
|
||||
TRACE(parray_mem, tout << "allocated values[" << c << "]: " << r << "\n";);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ private:
|
|||
if (vs == nullptr)
|
||||
return;
|
||||
size_t c = capacity(vs);
|
||||
TRACE("parray_mem", tout << "deallocated values[" << c << "]: " << vs << "\n";);
|
||||
TRACE(parray_mem, tout << "deallocated values[" << c << "]: " << vs << "\n";);
|
||||
size_t * mem = reinterpret_cast<size_t*>(vs);
|
||||
--mem;
|
||||
m_allocator.deallocate(sizeof(value)*c + sizeof(size_t), mem);
|
||||
|
@ -98,7 +98,7 @@ private:
|
|||
|
||||
cell * mk(ckind k) {
|
||||
cell * r = new (m_allocator.allocate(sizeof(cell))) cell(k);
|
||||
TRACE("parray_mem", tout << "allocated cell: " << r << "\n";);
|
||||
TRACE(parray_mem, tout << "allocated cell: " << r << "\n";);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ private:
|
|||
deallocate_values(c->m_values);
|
||||
break;
|
||||
}
|
||||
TRACE("parray_mem", tout << "deallocated cell: " << c << "\n";);
|
||||
TRACE(parray_mem, tout << "deallocated cell: " << c << "\n";);
|
||||
c->~cell();
|
||||
m_allocator.deallocate(sizeof(cell), c);
|
||||
if (next == nullptr)
|
||||
|
@ -139,7 +139,7 @@ private:
|
|||
|
||||
void dec_ref(cell * c) {
|
||||
if (!c) return;
|
||||
TRACE("parray_mem", tout << "dec_ref(" << c << "), ref_count: " << c->m_ref_count << "\n";);
|
||||
TRACE(parray_mem, tout << "dec_ref(" << c << "), ref_count: " << c->m_ref_count << "\n";);
|
||||
SASSERT(c->m_ref_count > 0);
|
||||
c->m_ref_count--;
|
||||
if (c->m_ref_count == 0)
|
||||
|
|
|
@ -694,7 +694,7 @@ Notes:
|
|||
}
|
||||
|
||||
literal mk_exactly_1(bool full, unsigned n, literal const* xs) {
|
||||
TRACE("pb", tout << "exactly 1 with " << n << " arguments " << (full?"full":"not full") << "\n";);
|
||||
TRACE(pb, tout << "exactly 1 with " << n << " arguments " << (full?"full":"not full") << "\n";);
|
||||
literal_vector ors;
|
||||
literal r1;
|
||||
switch (m_cfg.m_encoding) {
|
||||
|
@ -724,7 +724,7 @@ Notes:
|
|||
}
|
||||
|
||||
literal mk_at_most_1(bool full, unsigned n, literal const* xs, literal_vector& ors, bool use_ors) {
|
||||
TRACE("pb_verbose", tout << (full?"full":"partial") << " ";
|
||||
TRACE(pb_verbose, tout << (full?"full":"partial") << " ";
|
||||
for (unsigned i = 0; i < n; ++i) tout << xs[i] << " ";
|
||||
tout << "\n";);
|
||||
literal_vector in(n, xs);
|
||||
|
@ -948,7 +948,7 @@ Notes:
|
|||
for (unsigned i = 0; i < N; ++i) {
|
||||
in.push_back(mk_not(xs[i]));
|
||||
}
|
||||
TRACE("pb_verbose",
|
||||
TRACE(pb_verbose,
|
||||
//pp(tout << N << ": ", in);
|
||||
tout << " ~ " << k << "\n";);
|
||||
return true;
|
||||
|
@ -1034,23 +1034,23 @@ Notes:
|
|||
}
|
||||
|
||||
void card(unsigned k, unsigned n, literal const* xs, literal_vector& out) {
|
||||
TRACE("pb_verbose", tout << "card k: " << k << " n: " << n << "\n";);
|
||||
TRACE(pb_verbose, tout << "card k: " << k << " n: " << n << "\n";);
|
||||
if (n <= k) {
|
||||
psort_nw<psort_expr>::sorting(n, xs, out);
|
||||
}
|
||||
else if (use_dcard(k, n)) {
|
||||
TRACE("pb_verbose", tout << "use dcard\n";);
|
||||
TRACE(pb_verbose, tout << "use dcard\n";);
|
||||
dsorting(k, n, xs, out);
|
||||
}
|
||||
else {
|
||||
TRACE("pb_verbose", tout << "use merge\n";);
|
||||
TRACE(pb_verbose, tout << "use merge\n";);
|
||||
literal_vector out1, out2;
|
||||
unsigned half = n/2; // TBD
|
||||
card(k, half, xs, out1);
|
||||
card(k, n-half, xs + half, out2);
|
||||
smerge(k, out1.size(), out1.data(), out2.size(), out2.data(), out);
|
||||
}
|
||||
TRACE("pb_verbose", tout << "card k: " << k << " n: " << n << "\n";
|
||||
TRACE(pb_verbose, tout << "card k: " << k << " n: " << n << "\n";
|
||||
//pp(tout << "in:", n, xs) << "\n";
|
||||
//pp(tout << "out:", out) << "\n";
|
||||
);
|
||||
|
@ -1115,7 +1115,7 @@ Notes:
|
|||
odd_b.size(), odd_b.data(), out2);
|
||||
interleave(out1, out2, out);
|
||||
}
|
||||
TRACE("pb_verbose", tout << "merge a: " << a << " b: " << b << " ";
|
||||
TRACE(pb_verbose, tout << "merge a: " << a << " b: " << b << " ";
|
||||
tout << "num clauses " << m_stats.m_num_compiled_clauses - nc << "\n";
|
||||
vc_dsmerge(a, b, a + b).pp(tout << "vc_dsmerge ") << "\n";
|
||||
vc_smerge_rec(a, b, a + b).pp(tout << "vc_smerge_rec ") << "\n";
|
||||
|
@ -1178,7 +1178,7 @@ Notes:
|
|||
out.push_back(as[sz+1]);
|
||||
}
|
||||
SASSERT(out.size() == as.size() + bs.size());
|
||||
TRACE("pb_verbose", tout << "interleave: " << as.size() << " " << bs.size() << " ";
|
||||
TRACE(pb_verbose, tout << "interleave: " << as.size() << " " << bs.size() << " ";
|
||||
tout << "num clauses " << m_stats.m_num_compiled_clauses - nc << "\n";
|
||||
//pp(tout << "a: ", as) << "\n";
|
||||
//pp(tout << "b: ", bs) << "\n";
|
||||
|
@ -1192,7 +1192,7 @@ Notes:
|
|||
|
||||
public:
|
||||
void sorting(unsigned n, literal const* xs, literal_vector& out) {
|
||||
TRACE("pb_verbose", tout << "sorting: " << n << "\n";);
|
||||
TRACE(pb_verbose, tout << "sorting: " << n << "\n";);
|
||||
switch(n) {
|
||||
case 0:
|
||||
break;
|
||||
|
@ -1204,11 +1204,11 @@ Notes:
|
|||
break;
|
||||
default:
|
||||
if (use_dsorting(n)) {
|
||||
TRACE("pb_verbose", tout << "use dsorting: " << n << "\n";);
|
||||
TRACE(pb_verbose, tout << "use dsorting: " << n << "\n";);
|
||||
dsorting(n, n, xs, out);
|
||||
}
|
||||
else {
|
||||
TRACE("pb_verbose", tout << "use merge: " << n << "\n";);
|
||||
TRACE(pb_verbose, tout << "use merge: " << n << "\n";);
|
||||
literal_vector out1, out2;
|
||||
unsigned half = n/2; // TBD
|
||||
sorting(half, xs, out1);
|
||||
|
@ -1219,7 +1219,7 @@ Notes:
|
|||
}
|
||||
break;
|
||||
}
|
||||
TRACE("pb_verbose", tout << "sorting: " << n << "\n";
|
||||
TRACE(pb_verbose, tout << "sorting: " << n << "\n";
|
||||
//pp(tout << "in:", n, xs) << "\n";
|
||||
//pp(tout << "out:", out) << "\n";
|
||||
);
|
||||
|
@ -1331,7 +1331,7 @@ Notes:
|
|||
out.push_back(y);
|
||||
}
|
||||
}
|
||||
TRACE("pb_verbose", tout << "smerge: c:" << c << " a:" << a << " b:" << b << " ";
|
||||
TRACE(pb_verbose, tout << "smerge: c:" << c << " a:" << a << " b:" << b << " ";
|
||||
tout << "num clauses " << m_stats.m_num_compiled_clauses - nc << "\n";
|
||||
//pp(tout << "a:", a, as) << "\n";
|
||||
//pp(tout << "b:", b, bs) << "\n";
|
||||
|
@ -1421,7 +1421,7 @@ Notes:
|
|||
}
|
||||
}
|
||||
}
|
||||
TRACE("pb_verbose", tout << "dsmerge: c:" << c << " a:" << a << " b:" << b << " ";
|
||||
TRACE(pb_verbose, tout << "dsmerge: c:" << c << " a:" << a << " b:" << b << " ";
|
||||
tout << "num clauses: " << m_stats.m_num_compiled_clauses - nc << "\n";
|
||||
vc_dsmerge(a, b, c).pp(tout << "vc_dsmerge ") << "\n";
|
||||
vc_smerge_rec(a, b, c).pp(tout << "vc_smerge_rec ") << "\n";
|
||||
|
@ -1463,7 +1463,7 @@ Notes:
|
|||
lits.pop_back();
|
||||
}
|
||||
}
|
||||
TRACE("pb_verbose",
|
||||
TRACE(pb_verbose,
|
||||
tout << "dsorting m: " << m << " n: " << n << " ";
|
||||
tout << "num clauses: " << m_stats.m_num_compiled_clauses - nc << "\n";);
|
||||
}
|
||||
|
@ -1482,7 +1482,7 @@ Notes:
|
|||
|
||||
void add_subset(bool polarity, unsigned k, unsigned offset, literal_vector& lits,
|
||||
unsigned n, literal const* xs) {
|
||||
TRACE("pb_verbose", tout << "k:" << k << " offset: " << offset << " n: " << n << " ";
|
||||
TRACE(pb_verbose, tout << "k:" << k << " offset: " << offset << " n: " << n << " ";
|
||||
//pp(tout, lits) << "\n";
|
||||
);
|
||||
SASSERT(k + offset <= n);
|
||||
|
|
|
@ -20,7 +20,7 @@ Author:
|
|||
#include <sstream>
|
||||
|
||||
void state_graph::add_state_core(state s) {
|
||||
STRACE("state_graph", tout << "add(" << s << ") ";);
|
||||
STRACE(state_graph, tout << "add(" << s << ") ";);
|
||||
SASSERT(!m_seen.contains(s));
|
||||
// Ensure corresponding var in union find structure
|
||||
while (s >= m_state_ufind.get_num_vars()) {
|
||||
|
@ -38,7 +38,7 @@ void state_graph::remove_state_core(state s) {
|
|||
// added again later.
|
||||
// The state should be unknown, and all edges to or from the state
|
||||
// should already have been renamed.
|
||||
STRACE("state_graph", tout << "del(" << s << ") ";);
|
||||
STRACE(state_graph, tout << "del(" << s << ") ";);
|
||||
SASSERT(m_seen.contains(s));
|
||||
SASSERT(!m_state_ufind.is_root(s));
|
||||
SASSERT(m_unknown.contains(s));
|
||||
|
@ -49,21 +49,21 @@ void state_graph::remove_state_core(state s) {
|
|||
}
|
||||
|
||||
void state_graph::mark_unknown_core(state s) {
|
||||
STRACE("state_graph", tout << "unk(" << s << ") ";);
|
||||
STRACE(state_graph, tout << "unk(" << s << ") ";);
|
||||
SASSERT(m_state_ufind.is_root(s));
|
||||
SASSERT(m_unexplored.contains(s));
|
||||
m_unexplored.remove(s);
|
||||
m_unknown.insert(s);
|
||||
}
|
||||
void state_graph::mark_live_core(state s) {
|
||||
STRACE("state_graph", tout << "live(" << s << ") ";);
|
||||
STRACE(state_graph, tout << "live(" << s << ") ";);
|
||||
SASSERT(m_state_ufind.is_root(s));
|
||||
SASSERT(m_unknown.contains(s));
|
||||
m_unknown.remove(s);
|
||||
m_live.insert(s);
|
||||
}
|
||||
void state_graph::mark_dead_core(state s) {
|
||||
STRACE("state_graph", tout << "dead(" << s << ") ";);
|
||||
STRACE(state_graph, tout << "dead(" << s << ") ";);
|
||||
SASSERT(m_state_ufind.is_root(s));
|
||||
SASSERT(m_unknown.contains(s));
|
||||
m_unknown.remove(s);
|
||||
|
@ -78,7 +78,7 @@ void state_graph::mark_dead_core(state s) {
|
|||
maybecycle = true.
|
||||
*/
|
||||
void state_graph::add_edge_core(state s1, state s2, bool maybecycle) {
|
||||
STRACE("state_graph", tout << "add(" << s1 << "," << s2 << ","
|
||||
STRACE(state_graph, tout << "add(" << s1 << "," << s2 << ","
|
||||
<< (maybecycle ? "y" : "n") << ") ";);
|
||||
SASSERT(m_state_ufind.is_root(s1));
|
||||
SASSERT(m_state_ufind.is_root(s2));
|
||||
|
@ -95,7 +95,7 @@ void state_graph::add_edge_core(state s1, state s2, bool maybecycle) {
|
|||
}
|
||||
}
|
||||
void state_graph::remove_edge_core(state s1, state s2) {
|
||||
STRACE("state_graph", tout << "del(" << s1 << "," << s2 << ") ";);
|
||||
STRACE(state_graph, tout << "del(" << s1 << "," << s2 << ") ";);
|
||||
SASSERT(m_targets[s1].contains(s2));
|
||||
SASSERT(m_sources[s2].contains(s1));
|
||||
m_targets[s1].remove(s2);
|
||||
|
@ -127,7 +127,7 @@ auto state_graph::merge_states(state s1, state s2) -> state {
|
|||
SASSERT(m_state_ufind.is_root(s2));
|
||||
SASSERT(m_unknown.contains(s1));
|
||||
SASSERT(m_unknown.contains(s2));
|
||||
STRACE("state_graph", tout << "merge(" << s1 << "," << s2 << ") ";);
|
||||
STRACE(state_graph, tout << "merge(" << s1 << "," << s2 << ") ";);
|
||||
m_state_ufind.merge(s1, s2);
|
||||
if (m_state_ufind.is_root(s2)) std::swap(s1, s2);
|
||||
// rename s2 to s1 in edges
|
||||
|
@ -262,15 +262,15 @@ auto state_graph::merge_all_cycles(state s) -> state {
|
|||
|
||||
void state_graph::add_state(state s) {
|
||||
if (m_seen.contains(s)) return;
|
||||
STRACE("state_graph", tout << "[state_graph] adding state " << s << ": ";);
|
||||
STRACE(state_graph, tout << "[state_graph] adding state " << s << ": ";);
|
||||
add_state_core(s);
|
||||
CASSERT("state_graph", write_dgml());
|
||||
CASSERT("state_graph", write_dot());
|
||||
CASSERT("state_graph", check_invariant());
|
||||
STRACE("state_graph", tout << std::endl;);
|
||||
STRACE(state_graph, tout << std::endl;);
|
||||
}
|
||||
void state_graph::mark_live(state s) {
|
||||
STRACE("state_graph", tout << "[state_graph] marking live " << s << ": ";);
|
||||
STRACE(state_graph, tout << "[state_graph] marking live " << s << ": ";);
|
||||
SASSERT(m_unexplored.contains(s) || m_live.contains(s));
|
||||
SASSERT(m_state_ufind.is_root(s));
|
||||
if (m_unexplored.contains(s)) mark_unknown_core(s);
|
||||
|
@ -278,10 +278,10 @@ void state_graph::mark_live(state s) {
|
|||
CASSERT("state_graph", write_dgml());
|
||||
CASSERT("state_graph", write_dot());
|
||||
CASSERT("state_graph", check_invariant());
|
||||
STRACE("state_graph", tout << std::endl;);
|
||||
STRACE(state_graph, tout << std::endl;);
|
||||
}
|
||||
void state_graph::add_edge(state s1, state s2, bool maybecycle) {
|
||||
STRACE("state_graph", tout << "[state_graph] adding edge "
|
||||
STRACE(state_graph, tout << "[state_graph] adding edge "
|
||||
<< s1 << "->" << s2 << ": ";);
|
||||
SASSERT(m_unexplored.contains(s1) || m_live.contains(s1));
|
||||
SASSERT(m_state_ufind.is_root(s1));
|
||||
|
@ -292,20 +292,20 @@ void state_graph::add_edge(state s1, state s2, bool maybecycle) {
|
|||
CASSERT("state_graph", write_dgml());
|
||||
CASSERT("state_graph", write_dot());
|
||||
CASSERT("state_graph", check_invariant());
|
||||
STRACE("state_graph", tout << std::endl;);
|
||||
STRACE(state_graph, tout << std::endl;);
|
||||
}
|
||||
void state_graph::mark_done(state s) {
|
||||
SASSERT(m_unexplored.contains(s) || m_live.contains(s));
|
||||
SASSERT(m_state_ufind.is_root(s));
|
||||
if (m_live.contains(s)) return;
|
||||
STRACE("state_graph", tout << "[state_graph] marking done " << s << ": ";);
|
||||
STRACE(state_graph, tout << "[state_graph] marking done " << s << ": ";);
|
||||
if (m_unexplored.contains(s)) mark_unknown_core(s);
|
||||
s = merge_all_cycles(s);
|
||||
mark_dead_recursive(s); // check if dead
|
||||
CASSERT("state_graph", write_dgml());
|
||||
CASSERT("state_graph", write_dot());
|
||||
CASSERT("state_graph", check_invariant());
|
||||
STRACE("state_graph", tout << std::endl;);
|
||||
STRACE(state_graph, tout << std::endl;);
|
||||
}
|
||||
|
||||
unsigned state_graph::get_size() const {
|
||||
|
@ -413,7 +413,7 @@ bool state_graph::check_invariant() const {
|
|||
!(m_unknown.contains(s1) && m_unknown.contains(s2) &&
|
||||
m_sources_maybecycle[s2].contains(s1)));
|
||||
|
||||
STRACE("state_graph", tout << "(invariant passed) ";);
|
||||
STRACE(state_graph, tout << "(invariant passed) ";);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ void tbv_manager::debug_alloc() {
|
|||
tbv_manager::~tbv_manager() {
|
||||
DEBUG_CODE(
|
||||
for (auto t : allocated_tbvs)
|
||||
TRACE("doc", tout << "dangling: " << t << "\n";););
|
||||
TRACE(doc, tout << "dangling: " << t << "\n";););
|
||||
}
|
||||
|
||||
void tbv_manager::reset() {
|
||||
|
@ -42,7 +42,7 @@ tbv* tbv_manager::allocate() {
|
|||
m.reset(*r);
|
||||
DEBUG_CODE(
|
||||
if (s_debug_alloc) {
|
||||
TRACE("doc", tout << allocated_tbvs.size() << " " << r << "\n";);
|
||||
TRACE(doc, tout << allocated_tbvs.size() << " " << r << "\n";);
|
||||
}
|
||||
allocated_tbvs.insert(r);
|
||||
);
|
||||
|
@ -174,7 +174,7 @@ void tbv_manager::deallocate(tbv* bv) {
|
|||
UNREACHABLE();
|
||||
}
|
||||
if (s_debug_alloc) {
|
||||
TRACE("doc", tout << "deallocate: " << bv << "\n";);
|
||||
TRACE(doc, tout << "deallocate: " << bv << "\n";);
|
||||
}
|
||||
allocated_tbvs.erase(bv););
|
||||
#endif
|
||||
|
|
|
@ -87,7 +87,7 @@ class total_order {
|
|||
uint64_t vbn_a = vbn(a);
|
||||
SASSERT(vb_a < vbn_a);
|
||||
if (vbn_a < 2 || (vb_a > vbn_a - 2)) {
|
||||
TRACE("total_order", tout << "relabeling...\n"; tout << "\n";);
|
||||
TRACE(total_order, tout << "relabeling...\n"; tout << "\n";);
|
||||
uint64_t v0 = v(a);
|
||||
unsigned sz = size();
|
||||
uint64_t ideal_gap = UINT64_MAX / sz;
|
||||
|
@ -100,7 +100,7 @@ class total_order {
|
|||
c = c->m_next;
|
||||
curr_gap = (v(c) - v0) / j;
|
||||
}
|
||||
TRACE("total_order", tout << "j: " << j << " curr_gap: " << curr_gap << " sz: " << sz << "\n";);
|
||||
TRACE(total_order, tout << "j: " << j << " curr_gap: " << curr_gap << " sz: " << sz << "\n";);
|
||||
if (j == sz)
|
||||
curr_gap = ideal_gap;
|
||||
c = a->m_next;
|
||||
|
|
|
@ -59,6 +59,20 @@ void finalize_trace() {
|
|||
|
||||
void enable_trace(const char * tag) {
|
||||
get_enabled_trace_tags().insert(tag);
|
||||
|
||||
// TODO(#7663): Implement tag_class activation of all associated tags
|
||||
// int count = 0;
|
||||
// TraceTag tag_str = find_trace_tag_by_string(tag);
|
||||
// if(tag_str == TraceTag::Count) {
|
||||
// return;
|
||||
// }
|
||||
// const TraceTag* tags = get_tags_by_class(tag_str, count);
|
||||
// for (int i = 0; i < count; ++i) {
|
||||
// const char* tag_str = tracetag_to_string(tags[i]);
|
||||
// if (!get_enabled_trace_tags().contains(tag_str)) {
|
||||
// get_enabled_trace_tags().insert(tag_str);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void enable_all_trace(bool flag) {
|
||||
|
@ -69,9 +83,9 @@ void disable_trace(const char * tag) {
|
|||
get_enabled_trace_tags().erase(tag);
|
||||
}
|
||||
|
||||
bool is_trace_enabled(const char * tag) {
|
||||
bool is_trace_enabled(TraceTag tag) {
|
||||
return g_enable_all_trace_tags ||
|
||||
(g_enabled_trace_tags && get_enabled_trace_tags().contains(tag));
|
||||
(g_enabled_trace_tags && get_enabled_trace_tags().contains(tracetag_to_string(tag)));
|
||||
}
|
||||
|
||||
void close_trace() {
|
||||
|
|
|
@ -20,6 +20,7 @@ Revision History:
|
|||
#pragma once
|
||||
|
||||
#include<fstream>
|
||||
#include "trace_tags.h"
|
||||
|
||||
#ifdef SINGLE_THREAD
|
||||
# define is_threaded() false
|
||||
|
@ -55,7 +56,7 @@ extern std::ofstream tout;
|
|||
void enable_trace(const char * tag);
|
||||
void enable_all_trace(bool flag);
|
||||
void disable_trace(const char * tag);
|
||||
bool is_trace_enabled(const char * tag);
|
||||
bool is_trace_enabled(TraceTag tag);
|
||||
void close_trace();
|
||||
void open_trace();
|
||||
void finalize_trace();
|
||||
|
@ -69,21 +70,18 @@ void finalize_trace();
|
|||
static inline void enable_trace(const char * tag) {}
|
||||
static inline void enable_all_trace(bool flag) {}
|
||||
static inline void disable_trace(const char * tag) {}
|
||||
static inline bool is_trace_enabled(const char * tag) { return false; }
|
||||
static inline bool is_trace_enabled(TraceTag tag) { return false; }
|
||||
static inline void close_trace() {}
|
||||
static inline void open_trace() {}
|
||||
static inline void finalize_trace() {}
|
||||
#endif
|
||||
|
||||
#define TRACEH(TAG) tout << "-------- [" << TAG << "] " << __FUNCTION__ << " " << __FILE__ << ":" << __LINE__ << " ---------\n"
|
||||
#define TRACEH(TAG) tout << "-------- [" << tracetag_to_string(TraceTag::TAG) << "] " << __FUNCTION__ << " " << __FILE__ << ":" << __LINE__ << " ---------\n"
|
||||
#define TRACEEND tout << "------------------------------------------------\n"
|
||||
#define TRACEBODY(TAG, CODE) TRACEH(TAG); CODE; TRACEEND; tout.flush()
|
||||
#define STRACEBODY(CODE) CODE; tout.flush()
|
||||
|
||||
#define TRACE(TAG, CODE) TRACE_CODE(if (is_trace_enabled(TAG)) { THREAD_LOCK(TRACEBODY(TAG, CODE)); })
|
||||
|
||||
#define STRACE(TAG, CODE) TRACE_CODE(if (is_trace_enabled(TAG)) { THREAD_LOCK(STRACEBODY(CODE)); })
|
||||
|
||||
#define SCTRACE(TAG, COND, CODE) TRACE_CODE(if (is_trace_enabled(TAG) && (COND)) { THREAD_LOCK(STRACEBODY(CODE)); })
|
||||
|
||||
#define CTRACE(TAG, COND, CODE) TRACE_CODE(if (is_trace_enabled(TAG) && (COND)) { THREAD_LOCK(TRACEBODY(TAG, CODE)); })
|
||||
#define TRACE(TAG, CODE) TRACE_CODE(if (is_trace_enabled(TraceTag::TAG)) { THREAD_LOCK(TRACEBODY(TAG, CODE)); })
|
||||
#define STRACE(TAG, CODE) TRACE_CODE(if (is_trace_enabled(TraceTag::TAG)) { THREAD_LOCK(STRACEBODY(CODE)); })
|
||||
#define SCTRACE(TAG, COND, CODE) TRACE_CODE(if (is_trace_enabled(TraceTag::TAG) && (COND)) { THREAD_LOCK(STRACEBODY(CODE)); })
|
||||
#define CTRACE(TAG, COND, CODE) TRACE_CODE(if (is_trace_enabled(TraceTag::TAG) && (COND)) { THREAD_LOCK(TRACEBODY(TAG, CODE)); })
|
||||
|
|
1248
src/util/trace_tags.def
Normal file
1248
src/util/trace_tags.def
Normal file
File diff suppressed because it is too large
Load diff
83
src/util/trace_tags.h
Normal file
83
src/util/trace_tags.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
|
||||
enum class TraceTag {
|
||||
#define X(tag, tag_class, desc) tag,
|
||||
#include "trace_tags.def"
|
||||
#undef X
|
||||
Count
|
||||
};
|
||||
|
||||
// Convert TraceTag to string
|
||||
inline const char* tracetag_to_string(TraceTag tag) {
|
||||
switch (tag) {
|
||||
#define X(tag, tag_class, desc) case TraceTag::tag: return #tag;
|
||||
#include "trace_tags.def"
|
||||
#undef X
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
// Return description of TraceTag
|
||||
inline const char* get_trace_tag_doc(TraceTag tag) {
|
||||
switch (tag) {
|
||||
#define X(tag, tag_class, desc) case TraceTag::tag: return desc;
|
||||
#include "trace_tags.def"
|
||||
#undef X
|
||||
default: return "Unknown tag";
|
||||
}
|
||||
}
|
||||
|
||||
// Return the number of TraceTags
|
||||
inline constexpr int trace_tag_count() {
|
||||
return static_cast<int>(TraceTag::Count);
|
||||
}
|
||||
|
||||
// Return all TraceTags as an array
|
||||
inline const TraceTag* all_trace_tags() {
|
||||
static TraceTag tags[] = {
|
||||
#define X(tag, tag_class, desc) TraceTag::tag,
|
||||
#include "trace_tags.def"
|
||||
#undef X
|
||||
};
|
||||
return tags;
|
||||
}
|
||||
|
||||
// Helper function to count tags in a class
|
||||
inline constexpr int count_tags_in_class(TraceTag cls) {
|
||||
int count = 0;
|
||||
#define X(tag, tag_class, desc) if (TraceTag::tag_class == cls) count++;
|
||||
#include "trace_tags.def"
|
||||
#undef X
|
||||
return count;
|
||||
}
|
||||
|
||||
// TODO(#7663): Implement tag_class activation of all associated tags
|
||||
// TODO: Need to consider implementation approach and memory management
|
||||
// Return all tags that belong to the given class
|
||||
// inline const TraceTag* get_tags_by_class(TraceTag cls, int& count) {
|
||||
// count = count_tags_in_class(cls);
|
||||
// static TraceTag* class_tags = nullptr;
|
||||
// if (class_tags) delete[] class_tags;
|
||||
|
||||
// class_tags = new TraceTag[count];
|
||||
// int idx = 0;
|
||||
|
||||
// #define X(tag, tag_class, desc) \
|
||||
// if (TraceTag::tag_class == cls) { \
|
||||
// class_tags[idx++] = TraceTag::tag; \
|
||||
// }
|
||||
// #include "trace_tags.def"
|
||||
// #undef X
|
||||
|
||||
// return class_tags;
|
||||
// }
|
||||
|
||||
// Find TraceTag by string
|
||||
// inline TraceTag find_trace_tag_by_string(const char* tag_str) {
|
||||
// #define X(tag, tag_class, desc) if (strncmp(#tag, tag_str, strlen(#tag)) == 0) return TraceTag::tag;
|
||||
// #include "trace_tags.def"
|
||||
// #undef X
|
||||
// return TraceTag::Count;
|
||||
// }
|
|
@ -72,7 +72,7 @@ class union_find {
|
|||
|
||||
void unmerge(unsigned r1) {
|
||||
unsigned r2 = m_find[r1];
|
||||
TRACE("union_find", tout << "unmerging " << r1 << " " << r2 << "\n";);
|
||||
TRACE(union_find, tout << "unmerging " << r1 << " " << r2 << "\n";);
|
||||
SASSERT(find(r2) == r2);
|
||||
m_size[r2] -= m_size[r1];
|
||||
m_find[r1] = r1;
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
void merge(unsigned v1, unsigned v2) {
|
||||
unsigned r1 = find(v1);
|
||||
unsigned r2 = find(v2);
|
||||
TRACE("union_find", tout << "merging " << r1 << " " << r2 << "\n";);
|
||||
TRACE(union_find, tout << "merging " << r1 << " " << r2 << "\n";);
|
||||
if (r1 == r2)
|
||||
return;
|
||||
if (m_size[r1] > m_size[r2]) {
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
}
|
||||
|
||||
void set_root(unsigned v, unsigned root) {
|
||||
TRACE("union_find", tout << "merging " << v << " " << root << "\n";);
|
||||
TRACE(union_find, tout << "merging " << v << " " << root << "\n";);
|
||||
SASSERT(v != root);
|
||||
m_find[v] = root;
|
||||
m_size[root] += m_size[v];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue