mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
merge with Z3Prover/master
This commit is contained in:
parent
57845d4809
commit
aacb7289be
1147 changed files with 59004 additions and 63575 deletions
|
@ -74,7 +74,7 @@ public:
|
|||
typedef T * iterator;
|
||||
typedef const T * const_iterator;
|
||||
|
||||
array():m_data(0) {}
|
||||
array():m_data(nullptr) {}
|
||||
|
||||
/**
|
||||
\brief Store the array in the given chunk of memory (mem).
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
if (CallDestructors)
|
||||
destroy_elements();
|
||||
a.deallocate(space(size()), raw_ptr());
|
||||
m_data = 0;
|
||||
m_data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
}
|
||||
|
||||
unsigned size() const {
|
||||
if (m_data == 0) {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return static_cast<unsigned>(reinterpret_cast<size_t *>(m_data)[SIZE_IDX]);
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
bit_vector():
|
||||
m_num_bits(0),
|
||||
m_capacity(0),
|
||||
m_data(0) {
|
||||
m_data(nullptr) {
|
||||
}
|
||||
|
||||
bit_vector(unsigned reserve_num_bits) :
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
bit_vector(bit_vector const & source):
|
||||
m_num_bits(source.m_num_bits),
|
||||
m_capacity(source.m_capacity),
|
||||
m_data(0) {
|
||||
m_data(nullptr) {
|
||||
if (source.m_data) {
|
||||
m_data = alloc_svect(unsigned, m_capacity);
|
||||
memcpy(m_data, source.m_data, m_capacity * sizeof(unsigned));
|
||||
|
|
|
@ -30,8 +30,8 @@ class cancel_eh : public event_handler {
|
|||
T & m_obj;
|
||||
public:
|
||||
cancel_eh(T & o): m_canceled(false), m_obj(o) {}
|
||||
~cancel_eh() { if (m_canceled) m_obj.dec_cancel(); }
|
||||
virtual void operator()(event_handler_caller_t caller_id) {
|
||||
~cancel_eh() override { if (m_canceled) m_obj.dec_cancel(); }
|
||||
void operator()(event_handler_caller_t caller_id) override {
|
||||
if (!m_canceled) {
|
||||
m_caller_id = caller_id;
|
||||
m_canceled = true;
|
||||
|
|
|
@ -106,13 +106,13 @@ protected:
|
|||
SASSERT(target_it < target + target_slots);
|
||||
if (target_it->is_free()) {
|
||||
target_it->m_data = list_it->m_data;
|
||||
target_it->m_next = 0;
|
||||
target_it->m_next = nullptr;
|
||||
used_slots++;
|
||||
}
|
||||
else {
|
||||
SASSERT((get_hash(target_it->m_data) & target_mask) == idx);
|
||||
if (target_cellar == target_end)
|
||||
return 0; // the cellar is too small...
|
||||
return nullptr; // the cellar is too small...
|
||||
SASSERT(target_cellar >= target + target_slots);
|
||||
SASSERT(target_cellar < target_end);
|
||||
*target_cellar = *target_it;
|
||||
|
@ -123,7 +123,7 @@ protected:
|
|||
SASSERT(!target_it->is_free());
|
||||
list_it = list_it->m_next;
|
||||
}
|
||||
while (list_it != 0);
|
||||
while (list_it != nullptr);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
@ -164,13 +164,13 @@ protected:
|
|||
cell * next_cell = copy_table(m_table, m_slots, m_capacity,
|
||||
new_table, new_slots, new_capacity,
|
||||
m_used_slots);
|
||||
if (next_cell != 0) {
|
||||
if (next_cell != nullptr) {
|
||||
delete_table();
|
||||
m_table = new_table;
|
||||
m_capacity = new_capacity;
|
||||
m_slots = new_slots;
|
||||
m_next_cell = next_cell;
|
||||
m_free_cell = 0;
|
||||
m_free_cell = nullptr;
|
||||
CASSERT("chashtable", check_invariant());
|
||||
return;
|
||||
}
|
||||
|
@ -180,11 +180,11 @@ protected:
|
|||
}
|
||||
|
||||
bool has_free_cells() const {
|
||||
return m_free_cell != 0 || m_next_cell < m_table + m_capacity;
|
||||
return m_free_cell != nullptr || m_next_cell < m_table + m_capacity;
|
||||
}
|
||||
|
||||
cell * get_free_cell() {
|
||||
if (m_free_cell != 0) {
|
||||
if (m_free_cell != nullptr) {
|
||||
cell * c = m_free_cell;
|
||||
m_free_cell = c->m_next;
|
||||
return c;
|
||||
|
@ -211,7 +211,7 @@ protected:
|
|||
m_used_slots = 0;
|
||||
m_size = 0;
|
||||
m_next_cell = m_table + slots;
|
||||
m_free_cell = 0;
|
||||
m_free_cell = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -281,7 +281,7 @@ public:
|
|||
m_size++;
|
||||
m_used_slots++;
|
||||
c->m_data = d;
|
||||
c->m_next = 0;
|
||||
c->m_next = nullptr;
|
||||
CASSERT("chashtable_bug", check_invariant());
|
||||
return;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ public:
|
|||
CHS_CODE(m_collisions++;);
|
||||
it = it->m_next;
|
||||
}
|
||||
while (it != 0);
|
||||
while (it != nullptr);
|
||||
// d is not in the table.
|
||||
m_size++;
|
||||
cell * new_c = get_free_cell();
|
||||
|
@ -320,7 +320,7 @@ public:
|
|||
m_size++;
|
||||
m_used_slots++;
|
||||
c->m_data = d;
|
||||
c->m_next = 0;
|
||||
c->m_next = nullptr;
|
||||
CASSERT("chashtable_bug", check_invariant());
|
||||
return c->m_data;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ public:
|
|||
CHS_CODE(m_collisions++;);
|
||||
it = it->m_next;
|
||||
}
|
||||
while (it != 0);
|
||||
while (it != nullptr);
|
||||
// d is not in the table.
|
||||
m_size++;
|
||||
cell * new_c = get_free_cell();
|
||||
|
@ -358,7 +358,7 @@ public:
|
|||
m_size++;
|
||||
m_used_slots++;
|
||||
c->m_data = d;
|
||||
c->m_next = 0;
|
||||
c->m_next = nullptr;
|
||||
CASSERT("chashtable_bug", check_invariant());
|
||||
return true;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ public:
|
|||
CHS_CODE(m_collisions++;);
|
||||
it = it->m_next;
|
||||
}
|
||||
while (it != 0);
|
||||
while (it != nullptr);
|
||||
// d is not in the table.
|
||||
m_size++;
|
||||
cell * new_c = get_free_cell();
|
||||
|
@ -399,7 +399,7 @@ public:
|
|||
CHS_CODE(const_cast<chashtable*>(this)->m_collisions++;);
|
||||
c = c->m_next;
|
||||
}
|
||||
while (c != 0);
|
||||
while (c != nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ public:
|
|||
unsigned idx = h & mask;
|
||||
cell * c = m_table + idx;
|
||||
if (c->is_free())
|
||||
return 0;
|
||||
return nullptr;
|
||||
do {
|
||||
if (equals(c->m_data, d)) {
|
||||
return &(c->m_data);
|
||||
|
@ -417,8 +417,8 @@ public:
|
|||
CHS_CODE(const_cast<chashtable*>(this)->m_collisions++;);
|
||||
c = c->m_next;
|
||||
}
|
||||
while (c != 0);
|
||||
return 0;
|
||||
while (c != nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool find(T const & d, T & r) {
|
||||
|
@ -436,7 +436,7 @@ public:
|
|||
CHS_CODE(const_cast<chashtable*>(this)->m_collisions++;);
|
||||
c = c->m_next;
|
||||
}
|
||||
while (c != 0);
|
||||
while (c != nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -447,13 +447,13 @@ public:
|
|||
cell * c = m_table + idx;
|
||||
if (c->is_free())
|
||||
return;
|
||||
cell * prev = 0;
|
||||
cell * prev = nullptr;
|
||||
do {
|
||||
if (equals(c->m_data, d)) {
|
||||
m_size--;
|
||||
if (prev == 0) {
|
||||
if (prev == nullptr) {
|
||||
cell * next = c->m_next;
|
||||
if (next == 0) {
|
||||
if (next == nullptr) {
|
||||
m_used_slots--;
|
||||
c->mark_free();
|
||||
SASSERT(c->is_free());
|
||||
|
@ -474,7 +474,7 @@ public:
|
|||
prev = c;
|
||||
c = c->m_next;
|
||||
}
|
||||
while (c != 0);
|
||||
while (c != nullptr);
|
||||
}
|
||||
|
||||
class iterator {
|
||||
|
@ -490,12 +490,12 @@ public:
|
|||
}
|
||||
m_it++;
|
||||
}
|
||||
m_list_it = 0;
|
||||
m_list_it = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
iterator(cell * start, cell * end): m_it(start), m_end(end) { move_to_used(); }
|
||||
iterator():m_it(0), m_end(0), m_list_it(0) {}
|
||||
iterator():m_it(nullptr), m_end(nullptr), m_list_it(nullptr) {}
|
||||
T & operator*() {
|
||||
return m_list_it->m_data;
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ public:
|
|||
T * operator->() { return &(operator*()); }
|
||||
iterator & operator++() {
|
||||
m_list_it = m_list_it->m_next;
|
||||
if (m_list_it == 0) {
|
||||
if (m_list_it == nullptr) {
|
||||
m_it++;
|
||||
move_to_used();
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ public:
|
|||
|
||||
bool find(Key const & k, Value & v) const {
|
||||
key_value * e = m_table.find_core(key_value(k));
|
||||
if (e == 0)
|
||||
if (e == nullptr)
|
||||
return false;
|
||||
v = e->m_value;
|
||||
return true;
|
||||
|
|
|
@ -7,7 +7,7 @@ Module Name:
|
|||
|
||||
Abstract:
|
||||
|
||||
A class for wrapping checked (and unchecked) int64 operations.
|
||||
A class for wrapping checked (and unchecked) int64_t operations.
|
||||
Note: the mpfx class defines a more general class of fixed-point operations.
|
||||
A tradeoff is that it relies on a manager.
|
||||
This class several of the most common operations from rational, so
|
||||
|
@ -29,19 +29,19 @@ Revision History:
|
|||
|
||||
template<bool CHECK>
|
||||
class checked_int64 {
|
||||
int64 m_value;
|
||||
int64_t m_value;
|
||||
typedef checked_int64 ci;
|
||||
|
||||
rational r64(int64 i) { return rational(i, rational::i64()); }
|
||||
rational r64(int64_t i) { return rational(i, rational::i64()); }
|
||||
|
||||
public:
|
||||
|
||||
checked_int64(): m_value(0) {}
|
||||
checked_int64(int64 v): m_value(v) {}
|
||||
checked_int64(int64_t v): m_value(v) {}
|
||||
checked_int64(checked_int64 const& other) { m_value = other.m_value; }
|
||||
|
||||
class overflow_exception : public z3_exception {
|
||||
virtual char const * msg() const { return "checked_int64 overflow/underflow";}
|
||||
char const * msg() const override { return "checked_int64 overflow/underflow";}
|
||||
};
|
||||
|
||||
bool is_zero() const { return m_value == 0; }
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
static checked_int64 one() { return ci(1); }
|
||||
static checked_int64 minus_one() { return ci(-1);}
|
||||
|
||||
int64 get_int64() const { return m_value; }
|
||||
int64_t get_int64() const { return m_value; }
|
||||
|
||||
checked_int64 abs() const {
|
||||
if (m_value >= 0) {
|
||||
|
@ -117,9 +117,9 @@ public:
|
|||
|
||||
checked_int64& operator+=(checked_int64 const& other) {
|
||||
if (CHECK) {
|
||||
uint64 x = static_cast<uint64>(m_value);
|
||||
uint64 y = static_cast<uint64>(other.m_value);
|
||||
int64 r = static_cast<int64>(x + y);
|
||||
uint64_t x = static_cast<uint64_t>(m_value);
|
||||
uint64_t y = static_cast<uint64_t>(other.m_value);
|
||||
int64_t r = static_cast<int64_t>(x + y);
|
||||
if (m_value > 0 && other.m_value > 0 && r <= 0) throw overflow_exception();
|
||||
if (m_value < 0 && other.m_value < 0 && r >= 0) throw overflow_exception();
|
||||
m_value = r;
|
||||
|
@ -132,9 +132,9 @@ public:
|
|||
|
||||
checked_int64& operator-=(checked_int64 const& other) {
|
||||
if (CHECK) {
|
||||
uint64 x = static_cast<uint64>(m_value);
|
||||
uint64 y = static_cast<uint64>(other.m_value);
|
||||
int64 r = static_cast<int64>(x - y);
|
||||
uint64_t x = static_cast<uint64_t>(m_value);
|
||||
uint64_t y = static_cast<uint64_t>(other.m_value);
|
||||
int64_t r = static_cast<int64_t>(x - y);
|
||||
if (m_value > 0 && other.m_value < 0 && r <= 0) throw overflow_exception();
|
||||
if (m_value < 0 && other.m_value > 0 && r >= 0) throw overflow_exception();
|
||||
m_value = r;
|
||||
|
|
|
@ -91,8 +91,8 @@ public:
|
|||
virtual void reset(cmd_context & ctx) {}
|
||||
virtual void finalize(cmd_context & ctx) {}
|
||||
virtual symbol get_name() const { return m_name; }
|
||||
virtual char const * get_usage() const { return 0; }
|
||||
virtual char const * get_descr(cmd_context & ctx) const { return 0; }
|
||||
virtual char const * get_usage() const { return nullptr; }
|
||||
virtual char const * get_descr(cmd_context & ctx) const { return nullptr; }
|
||||
virtual unsigned get_arity() const { return 0; }
|
||||
|
||||
// command invocation
|
||||
|
|
|
@ -29,7 +29,7 @@ Revision History:
|
|||
// -----------------------------------
|
||||
|
||||
template<class Set1, class Set2>
|
||||
void set_intersection(Set1 & tgt, const Set2 & src) {
|
||||
void set_intersection(Set1 & tgt, const Set2 & src) {
|
||||
svector<typename Set1::data> to_remove;
|
||||
for (auto const& itm : tgt)
|
||||
if (!src.contains(itm))
|
||||
|
|
|
@ -28,7 +28,7 @@ struct cooperation_lock {
|
|||
cooperation_lock() {
|
||||
omp_set_nested(1);
|
||||
omp_init_nest_lock(&m_lock);
|
||||
m_task = 0;
|
||||
m_task = nullptr;
|
||||
m_owner_thread = -1;
|
||||
}
|
||||
~cooperation_lock() {
|
||||
|
|
|
@ -41,7 +41,7 @@ void notify_assertion_violation(const char * fileName, int line, const char * co
|
|||
std::cerr << condition << "\n";
|
||||
}
|
||||
|
||||
static str_hashtable* g_enabled_debug_tags = 0;
|
||||
static str_hashtable* g_enabled_debug_tags = nullptr;
|
||||
|
||||
static void init_debug_table() {
|
||||
if (!g_enabled_debug_tags) {
|
||||
|
@ -51,7 +51,7 @@ static void init_debug_table() {
|
|||
|
||||
void finalize_debug() {
|
||||
dealloc(g_enabled_debug_tags);
|
||||
g_enabled_debug_tags = 0;
|
||||
g_enabled_debug_tags = nullptr;
|
||||
}
|
||||
|
||||
void enable_debug(const char * tag) {
|
||||
|
@ -72,7 +72,7 @@ bool is_debug_enabled(const char * tag) {
|
|||
#ifndef _WINDOWS
|
||||
void invoke_gdb() {
|
||||
char buffer[1024];
|
||||
int * x = 0;
|
||||
int * x = nullptr;
|
||||
for (;;) {
|
||||
std::cerr << "(C)ontinue, (A)bort, (S)top, (T)hrow exception, Invoke (G)DB\n";
|
||||
char result;
|
||||
|
@ -103,7 +103,7 @@ void invoke_gdb() {
|
|||
else {
|
||||
std::cerr << "error starting GDB...\n";
|
||||
// forcing seg fault.
|
||||
int * x = 0;
|
||||
int * x = nullptr;
|
||||
*x = 0;
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
}
|
||||
|
||||
dependency * mk_empty() {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dependency * mk_leaf(value const & v) {
|
||||
|
@ -148,10 +148,10 @@ public:
|
|||
}
|
||||
|
||||
dependency * mk_join(dependency * d1, dependency * d2) {
|
||||
if (d1 == 0) {
|
||||
if (d1 == nullptr) {
|
||||
return d2;
|
||||
}
|
||||
else if (d2 == 0) {
|
||||
else if (d2 == nullptr) {
|
||||
return d1;
|
||||
}
|
||||
else if (d1 == d2) {
|
||||
|
|
|
@ -75,8 +75,8 @@ public:
|
|||
static void set(double & a, char const * val) { a = atof(val); }
|
||||
static void set(double & a, int val) { a = static_cast<double>(val); }
|
||||
static void set(double & a, unsigned val) { a = static_cast<double>(val); }
|
||||
static void set(double & a, int64 val) { a = static_cast<double>(val); }
|
||||
static void set(double & a, uint64 val) { a = static_cast<double>(val); }
|
||||
static void set(double & a, int64_t val) { a = static_cast<double>(val); }
|
||||
static void set(double & a, uint64_t val) { a = static_cast<double>(val); }
|
||||
static void swap(double & a, double & b) { std::swap(a, b); }
|
||||
bool is_pos(double a) const { return a > m_zero_tolerance; }
|
||||
bool is_neg(double a) const { return a < m_zero_tolerance; }
|
||||
|
@ -93,11 +93,11 @@ public:
|
|||
}
|
||||
|
||||
static unsigned hash(double a) {
|
||||
return hash_ull(static_cast<uint64>(a));
|
||||
return hash_ull(static_cast<uint64_t>(a));
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(uint64) == sizeof(double), "");
|
||||
static_assert(sizeof(uint64_t) == sizeof(double), "");
|
||||
|
||||
#endif /* DOUBLE_MANAGER_H_ */
|
||||
|
||||
|
|
56
src/util/ema.h
Normal file
56
src/util/ema.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*++
|
||||
Copyright (c) 2018 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ema.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Exponential moving average based on CaDiCal.
|
||||
The exponential scheme used to adjust beta to alpha is
|
||||
described in Biere & Froelich, POS (Pragmatics of SAT) 2016.
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2018-05-03
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef EMA_H_
|
||||
#define EMA_H_
|
||||
|
||||
class ema {
|
||||
double m_alpha, m_beta, m_value;
|
||||
unsigned m_period, m_wait;
|
||||
bool invariant() const { return 0 <= m_alpha && m_alpha <= m_beta && m_beta <= 1; }
|
||||
public:
|
||||
ema(): m_alpha(0), m_beta(1), m_value(0), m_period(0), m_wait(0) {
|
||||
SASSERT(invariant());
|
||||
}
|
||||
|
||||
ema(double alpha):
|
||||
m_alpha(alpha), m_beta(1), m_value(0),
|
||||
m_period(0), m_wait(0) {
|
||||
SASSERT(invariant());
|
||||
}
|
||||
|
||||
void set_alpha(double alpha) {
|
||||
m_alpha = alpha;
|
||||
SASSERT(invariant());
|
||||
}
|
||||
|
||||
operator double () const { return m_value; }
|
||||
|
||||
void update(double x) {
|
||||
SASSERT(invariant());
|
||||
m_value += m_beta * (x - m_value);
|
||||
if (m_beta <= m_alpha || m_wait--) return;
|
||||
m_wait = m_period = 2*(m_period + 1) - 1;
|
||||
m_beta *= 0.5;
|
||||
if (m_beta < m_alpha) m_beta = m_alpha;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -23,7 +23,7 @@ Notes:
|
|||
#include "util/memory_manager.h"
|
||||
|
||||
void env_params::updt_params() {
|
||||
params_ref p = gparams::get();
|
||||
params_ref const& p = gparams::get_ref();
|
||||
set_verbosity_level(p.get_uint("verbose", get_verbosity_level()));
|
||||
enable_warning_messages(p.get_bool("warning", true));
|
||||
memory::set_max_size(megabytes_to_bytes(p.get_uint("memory_max_size", 0)));
|
||||
|
|
|
@ -21,12 +21,12 @@ Revision History:
|
|||
#include <cstring>
|
||||
|
||||
inline char const * get_extension(char const * file_name) {
|
||||
if (file_name == 0)
|
||||
return 0;
|
||||
char const * last_dot = 0;
|
||||
if (file_name == nullptr)
|
||||
return nullptr;
|
||||
char const * last_dot = nullptr;
|
||||
for (;;) {
|
||||
char const * tmp = strchr(file_name, '.');
|
||||
if (tmp == 0) {
|
||||
if (tmp == nullptr) {
|
||||
return last_dot;
|
||||
}
|
||||
last_dot = tmp + 1;
|
||||
|
|
|
@ -23,7 +23,7 @@ Notes:
|
|||
extern void gparams_register_modules();
|
||||
|
||||
static char const * g_old_params_names[] = {
|
||||
"arith_adaptive","arith_adaptive_assertion_threshold","arith_adaptive_gcd","arith_adaptive_propagation_threshold","arith_add_binary_bounds","arith_blands_rule_threshold","arith_branch_cut_ratio","arith_dump_lemmas","arith_eager_eq_axioms","arith_eager_gcd","arith_eq_bounds","arith_euclidean_solver","arith_expand_eqs","arith_force_simplex","arith_gcd_test","arith_ignore_int","arith_lazy_adapter","arith_lazy_pivoting","arith_max_lemma_size","arith_process_all_eqs","arith_propagate_eqs","arith_propagation_mode","arith_propagation_threshold","arith_prop_strategy","arith_random_initial_value","arith_random_lower","arith_random_seed","arith_random_upper","arith_reflect","arith_skip_big_coeffs","arith_small_lemma_size","arith_solver","arith_stronger_lemmas","array_always_prop_upward","array_canonize","array_cg","array_delay_exp_axiom","array_extensional","array_laziness","array_lazy_ieq","array_lazy_ieq_delay","array_solver","array_weak","async_commands","at_labels_cex","auto_config","bb_eager","bb_ext_gates","bb_quantifiers","bin_clauses","bit2int","bv2int_distribute","bv_blast_max_size","bv_cc","bv_enable_int2bv_propagation","bv_lazy_le","bv_max_sharing","bv_reflect","bv_solver","case_split","check_at_labels","check_proof","cnf_factor","cnf_mode","context_simplifier","dack","dack_eq","dack_factor","dack_gc","dack_gc_inv_decay","dack_threshold","default_qid","default_table","default_table_checked","delay_units","delay_units_threshold","der","display_config","display_dot_proof","display_error_for_visual_studio","display_features","display_proof","display_unsat_core","distribute_forall","dt_lazy_splits","dump_goal_as_smt","elim_and","elim_bounds","elim_nlarith_quantifiers","elim_quantifiers","elim_term_ite","ematching","engine","eq_propagation","hi_div0","ignore_bad_patterns","ignore_setparameter","instruction_max","inst_gen","interactive","internalizer_nnf","lemma_gc_factor","lemma_gc_half","lemma_gc_initial","lemma_gc_new_clause_activity","lemma_gc_new_clause_relevancy","lemma_gc_new_old_ratio","lemma_gc_old_clause_activity","lemma_gc_old_clause_relevancy","lemma_gc_strategy","lift_ite","lookahead_diseq","macro_finder","max_conflicts","max_counterexamples","mbqi","mbqi_force_template","mbqi_max_cexs","mbqi_max_cexs_incr","mbqi_max_iterations","mbqi_trace","minimize_lemmas","model","model_compact","model_completion","model_display_arg_sort","model_hide_unused_partitions","model_on_final_check","model_on_timeout","model_partial","model_v1","model_v2","model_validate","new_core2th_eq","ng_lift_ite","nl_arith","nl_arith_branching","nl_arith_gb","nl_arith_gb_eqs","nl_arith_gb_perturbate","nl_arith_gb_threshold","nl_arith_max_degree","nl_arith_rounds","nnf_factor","nnf_ignore_labels","nnf_mode","nnf_sk_hack","order","order_var_weight","order_weights","phase_selection","pi_arith","pi_arith_weight","pi_avoid_skolems","pi_block_looop_patterns","pi_max_multi_patterns","pi_non_nested_arith_weight","pi_nopat_weight","pi_pull_quantifiers","pi_use_database","pi_warnings","pp_bounded","pp_bv_literals","pp_bv_neg","pp_decimal","pp_decimal_precision","pp_fixed_indent","pp_flat_assoc","pp_max_depth","pp_max_indent","pp_max_num_lines","pp_max_ribbon","pp_max_width","pp_min_alias_size","pp_simplify_implies","pp_single_line","precedence","precedence_gen","pre_demodulator","pre_simplifier","pre_simplify_expr","profile_res_sub","progress_sampling_freq","proof_mode","propagate_booleans","propagate_values","pull_cheap_ite_trees","pull_nested_quantifiers","qi_conservative_final_check","qi_cost","qi_eager_threshold","qi_lazy_instantiation","qi_lazy_quick_checker","qi_lazy_threshold","qi_max_eager_multi_patterns","qi_max_instances","qi_max_lazy_multi_pattern_matching","qi_new_gen","qi_profile","qi_profile_freq","qi_promote_unsat","qi_quick_checker","quasi_macros","random_case_split_freq","random_initial_activity","random_seed","recent_lemma_threshold","reduce_args","refine_inj_axiom","relevancy","relevancy_lemma","rel_case_split_order","restart_adaptive","restart_agility_threshold","restart_factor","restart_initial","restart_strategy","restricted_quasi_macros","simplify_clauses","smtlib2_compliant","smtlib_category","smtlib_dump_lemmas","smtlib_logic","smtlib_source_info","smtlib_trace_path","soft_timeout","solver","spc_bs","spc_es","spc_factor_subsumption_index_opt","spc_initial_subsumption_index_opt","spc_max_subsumption_index_features","spc_min_func_freq_subsumption_index","spc_num_iterations","spc_trace","statistics","strong_context_simplifier","tick","trace","trace_file_name","type_check","user_theory_persist_axioms","user_theory_preprocess_axioms","verbose","warning","well_sorted_check","z3_solver_ll_pp","z3_solver_smt_pp", 0 };
|
||||
"arith_adaptive","arith_adaptive_assertion_threshold","arith_adaptive_gcd","arith_adaptive_propagation_threshold","arith_add_binary_bounds","arith_blands_rule_threshold","arith_branch_cut_ratio","arith_dump_lemmas","arith_eager_eq_axioms","arith_eager_gcd","arith_eq_bounds","arith_euclidean_solver","arith_expand_eqs","arith_force_simplex","arith_gcd_test","arith_ignore_int","arith_lazy_adapter","arith_lazy_pivoting","arith_max_lemma_size","arith_process_all_eqs","arith_propagate_eqs","arith_propagation_mode","arith_propagation_threshold","arith_prop_strategy","arith_random_initial_value","arith_random_lower","arith_random_seed","arith_random_upper","arith_reflect","arith_skip_big_coeffs","arith_small_lemma_size","arith_solver","arith_stronger_lemmas","array_always_prop_upward","array_canonize","array_cg","array_delay_exp_axiom","array_extensional","array_laziness","array_lazy_ieq","array_lazy_ieq_delay","array_solver","array_weak","async_commands","at_labels_cex","auto_config","bb_eager","bb_ext_gates","bb_quantifiers","bin_clauses","bit2int","bv2int_distribute","bv_blast_max_size","bv_cc","bv_enable_int2bv_propagation","bv_lazy_le","bv_max_sharing","bv_reflect","bv_solver","case_split","check_at_labels","check_proof","cnf_factor","cnf_mode","context_simplifier","dack","dack_eq","dack_factor","dack_gc","dack_gc_inv_decay","dack_threshold","default_qid","default_table","default_table_checked","delay_units","delay_units_threshold","der","display_config","display_dot_proof","display_error_for_visual_studio","display_features","display_proof","display_unsat_core","distribute_forall","dt_lazy_splits","dump_goal_as_smt","elim_and","elim_bounds","elim_nlarith_quantifiers","elim_quantifiers","elim_term_ite","ematching","engine","eq_propagation","hi_div0","ignore_bad_patterns","ignore_setparameter","instruction_max","inst_gen","interactive","internalizer_nnf","lemma_gc_factor","lemma_gc_half","lemma_gc_initial","lemma_gc_new_clause_activity","lemma_gc_new_clause_relevancy","lemma_gc_new_old_ratio","lemma_gc_old_clause_activity","lemma_gc_old_clause_relevancy","lemma_gc_strategy","lift_ite","lookahead_diseq","macro_finder","max_conflicts","max_counterexamples","mbqi","mbqi_force_template","mbqi_max_cexs","mbqi_max_cexs_incr","mbqi_max_iterations","mbqi_trace","minimize_lemmas","model","model_compact","model_completion","model_display_arg_sort","model_hide_unused_partitions","model_on_final_check","model_on_timeout","model_partial","model_v1","model_v2","model_validate","new_core2th_eq","ng_lift_ite","nl_arith","nl_arith_branching","nl_arith_gb","nl_arith_gb_eqs","nl_arith_gb_perturbate","nl_arith_gb_threshold","nl_arith_max_degree","nl_arith_rounds","nnf_factor","nnf_ignore_labels","nnf_mode","nnf_sk_hack","order","order_var_weight","order_weights","phase_selection","pi_arith","pi_arith_weight","pi_avoid_skolems","pi_block_looop_patterns","pi_max_multi_patterns","pi_non_nested_arith_weight","pi_nopat_weight","pi_pull_quantifiers","pi_use_database","pi_warnings","pp_bounded","pp_bv_literals","pp_bv_neg","pp_decimal","pp_decimal_precision","pp_fixed_indent","pp_flat_assoc","pp_max_depth","pp_max_indent","pp_max_num_lines","pp_max_ribbon","pp_max_width","pp_min_alias_size","pp_simplify_implies","pp_single_line","precedence","precedence_gen","pre_demodulator","pre_simplifier","pre_simplify_expr","profile_res_sub","progress_sampling_freq","proof_mode","propagate_booleans","propagate_values","pull_cheap_ite_trees","pull_nested_quantifiers","qi_conservative_final_check","qi_cost","qi_eager_threshold","qi_lazy_instantiation","qi_lazy_quick_checker","qi_lazy_threshold","qi_max_eager_multi_patterns","qi_max_instances","qi_max_lazy_multi_pattern_matching","qi_new_gen","qi_profile","qi_profile_freq","qi_promote_unsat","qi_quick_checker","quasi_macros","random_case_split_freq","random_initial_activity","random_seed","recent_lemma_threshold","reduce_args","refine_inj_axiom","relevancy","relevancy_lemma","rel_case_split_order","restart_adaptive","restart_agility_threshold","restart_factor","restart_initial","restart_strategy","restricted_quasi_macros","simplify_clauses","smtlib2_compliant","smtlib_category","smtlib_dump_lemmas","smtlib_logic","smtlib_source_info","smtlib_trace_path","soft_timeout","solver","spc_bs","spc_es","spc_factor_subsumption_index_opt","spc_initial_subsumption_index_opt","spc_max_subsumption_index_features","spc_min_func_freq_subsumption_index","spc_num_iterations","spc_trace","statistics","strong_context_simplifier","tick","trace","trace_file_name","type_check","user_theory_persist_axioms","user_theory_preprocess_axioms","verbose","warning","well_sorted_check","z3_solver_ll_pp","z3_solver_smt_pp", nullptr };
|
||||
|
||||
bool is_old_param_name(symbol const & name) {
|
||||
char const * const * it = g_old_params_names;
|
||||
|
@ -64,7 +64,7 @@ static char const * g_params_renames[] = {
|
|||
"pp_bv_neg", "pp.bv_neg",
|
||||
"pp_max_depth", "pp.max_depth",
|
||||
"pp_min_alias_size", "pp.min_alias_size",
|
||||
0 };
|
||||
nullptr };
|
||||
|
||||
char const * get_new_param_name(symbol const & p) {
|
||||
char const * const * it = g_params_renames;
|
||||
|
@ -75,7 +75,7 @@ char const * get_new_param_name(symbol const & p) {
|
|||
}
|
||||
it += 2;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct gparams::imp {
|
||||
|
@ -104,10 +104,8 @@ public:
|
|||
|
||||
~imp() {
|
||||
reset();
|
||||
dictionary<param_descrs*>::iterator it = m_module_param_descrs.begin();
|
||||
dictionary<param_descrs*>::iterator end = m_module_param_descrs.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->m_value);
|
||||
for (auto & kv : m_module_param_descrs) {
|
||||
dealloc(kv.m_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,10 +113,8 @@ public:
|
|||
#pragma omp critical (gparams)
|
||||
{
|
||||
m_params.reset();
|
||||
dictionary<params_ref*>::iterator it = m_module_params.begin();
|
||||
dictionary<params_ref*>::iterator end = m_module_params.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->m_value);
|
||||
for (auto & kv : m_module_params) {
|
||||
dealloc(kv.m_value);
|
||||
}
|
||||
m_module_params.reset();
|
||||
}
|
||||
|
@ -191,7 +187,7 @@ public:
|
|||
return m_params;
|
||||
}
|
||||
else {
|
||||
params_ref * p = 0;
|
||||
params_ref * p = nullptr;
|
||||
if (!m_module_params.find(mod_name, p)) {
|
||||
p = alloc(params_ref);
|
||||
m_module_params.insert(mod_name, p);
|
||||
|
@ -279,7 +275,7 @@ public:
|
|||
throw_unknown_parameter(param_name, d, mod_name);
|
||||
}
|
||||
else if (k == CPK_UINT) {
|
||||
long val = strtol(value, 0, 10);
|
||||
long val = strtol(value, nullptr, 10);
|
||||
ps.set_uint(param_name, static_cast<unsigned>(val));
|
||||
}
|
||||
else if (k == CPK_DOUBLE) {
|
||||
|
@ -374,7 +370,7 @@ public:
|
|||
throw_unknown_parameter(p, d, m);
|
||||
}
|
||||
char const * r = d.get_default(p);
|
||||
if (r == 0)
|
||||
if (r == nullptr)
|
||||
return "default";
|
||||
return r;
|
||||
}
|
||||
|
@ -397,7 +393,7 @@ public:
|
|||
}
|
||||
}
|
||||
else {
|
||||
params_ref * ps = 0;
|
||||
params_ref * ps = nullptr;
|
||||
if (m_module_params.find(m, ps) && ps->contains(p)) {
|
||||
r = get_value(*ps, p);
|
||||
}
|
||||
|
@ -425,26 +421,22 @@ public:
|
|||
return r;
|
||||
}
|
||||
|
||||
// unfortunately, params_ref is not thread safe
|
||||
// so better create a local copy of the parameters.
|
||||
params_ref get_module(symbol const & module_name) {
|
||||
params_ref result;
|
||||
params_ref * ps = 0;
|
||||
params_ref * ps = nullptr;
|
||||
#pragma omp critical (gparams)
|
||||
{
|
||||
if (m_module_params.find(module_name, ps)) {
|
||||
result = *ps;
|
||||
result.copy(*ps);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
params_ref get() {
|
||||
params_ref result;
|
||||
TRACE("gparams", tout << "get() m_params: " << m_params << "\n";);
|
||||
#pragma omp critical (gparams)
|
||||
{
|
||||
result = m_params;
|
||||
}
|
||||
return result;
|
||||
params_ref const& get_ref() {
|
||||
return m_params;
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
|
@ -464,16 +456,14 @@ public:
|
|||
out << "Example: pp.decimal=true\n";
|
||||
out << "\n";
|
||||
}
|
||||
dictionary<param_descrs*>::iterator it = get_module_param_descrs().begin();
|
||||
dictionary<param_descrs*>::iterator end = get_module_param_descrs().end();
|
||||
for (; it != end; ++it) {
|
||||
out << "[module] " << it->m_key;
|
||||
char const * descr = 0;
|
||||
if (get_module_descrs().find(it->m_key, descr)) {
|
||||
for (auto & kv : get_module_param_descrs()) {
|
||||
out << "[module] " << kv.m_key;
|
||||
char const * descr = nullptr;
|
||||
if (get_module_descrs().find(kv.m_key, descr)) {
|
||||
out << ", description: " << descr;
|
||||
}
|
||||
out << "\n";
|
||||
it->m_value->display(out, indent + 4, smt2_style, include_descr);
|
||||
kv.m_value->display(out, indent + 4, smt2_style, include_descr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -481,12 +471,10 @@ public:
|
|||
void display_modules(std::ostream & out) {
|
||||
#pragma omp critical (gparams)
|
||||
{
|
||||
dictionary<param_descrs*>::iterator it = get_module_param_descrs().begin();
|
||||
dictionary<param_descrs*>::iterator end = get_module_param_descrs().end();
|
||||
for (; it != end; ++it) {
|
||||
out << "[module] " << it->m_key;
|
||||
char const * descr = 0;
|
||||
if (get_module_descrs().find(it->m_key, descr)) {
|
||||
for (auto & kv : get_module_param_descrs()) {
|
||||
out << "[module] " << kv.m_key;
|
||||
char const * descr = nullptr;
|
||||
if (get_module_descrs().find(kv.m_key, descr)) {
|
||||
out << ", description: " << descr;
|
||||
}
|
||||
out << "\n";
|
||||
|
@ -500,14 +488,14 @@ public:
|
|||
#pragma omp critical (gparams)
|
||||
{
|
||||
try {
|
||||
param_descrs * d = 0;
|
||||
param_descrs * d = nullptr;
|
||||
if (!get_module_param_descrs().find(module_name, d)) {
|
||||
std::stringstream strm;
|
||||
strm << "unknown module '" << module_name << "'";
|
||||
throw exception(strm.str());
|
||||
}
|
||||
out << "[module] " << module_name;
|
||||
char const * descr = 0;
|
||||
char const * descr = nullptr;
|
||||
if (get_module_descrs().find(module_name, descr)) {
|
||||
out << ", description: " << descr;
|
||||
}
|
||||
|
@ -566,7 +554,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
gparams::imp * gparams::g_imp = 0;
|
||||
gparams::imp * gparams::g_imp = nullptr;
|
||||
|
||||
void gparams::reset() {
|
||||
SASSERT(g_imp != 0);
|
||||
|
@ -618,10 +606,10 @@ params_ref gparams::get_module(symbol const & module_name) {
|
|||
return g_imp->get_module(module_name);
|
||||
}
|
||||
|
||||
params_ref gparams::get() {
|
||||
TRACE("gparams", tout << "gparams::get()\n";);
|
||||
params_ref const& gparams::get_ref() {
|
||||
TRACE("gparams", tout << "gparams::get_ref()\n";);
|
||||
SASSERT(g_imp != 0);
|
||||
return g_imp->get();
|
||||
return g_imp->get_ref();
|
||||
}
|
||||
|
||||
void gparams::display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) {
|
||||
|
@ -651,9 +639,9 @@ void gparams::init() {
|
|||
|
||||
void gparams::finalize() {
|
||||
TRACE("gparams", tout << "gparams::finalize()\n";);
|
||||
if (g_imp != 0) {
|
||||
if (g_imp != nullptr) {
|
||||
dealloc(g_imp);
|
||||
g_imp = 0;
|
||||
g_imp = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
set_global_param('pp.decimal', 'true')
|
||||
will set the parameter "decimal" in the module "pp" to true.
|
||||
|
||||
An exception is thrown if the the parameter name is unknown, or if the value is incorrect.
|
||||
An exception is thrown if the parameter name is unknown, or if the value is incorrect.
|
||||
*/
|
||||
static void set(char const * name, char const * value);
|
||||
static void set(symbol const & name, char const * value);
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
If the parameter is not set, then it just returns 'default'.
|
||||
|
||||
An exception is thrown if the the parameter name is unknown.
|
||||
An exception is thrown if the parameter name is unknown.
|
||||
*/
|
||||
static std::string get_value(char const * name);
|
||||
static std::string get_value(symbol const & name);
|
||||
|
@ -106,7 +106,8 @@ public:
|
|||
/**
|
||||
\brief Return the global parameter set (i.e., parameters that are not associated with any particular module).
|
||||
*/
|
||||
static params_ref get();
|
||||
|
||||
static params_ref const& get_ref();
|
||||
|
||||
/**
|
||||
\brief Dump information about available parameters in the given output stream.
|
||||
|
|
|
@ -140,8 +140,8 @@ struct size_t_hash {
|
|||
};
|
||||
|
||||
struct uint64_hash {
|
||||
typedef uint64 data;
|
||||
unsigned operator()(uint64 x) const { return static_cast<unsigned>(x); }
|
||||
typedef uint64_t data;
|
||||
unsigned operator()(uint64_t x) const { return static_cast<unsigned>(x); }
|
||||
};
|
||||
|
||||
struct bool_hash {
|
||||
|
|
|
@ -24,11 +24,12 @@ Revision History:
|
|||
#include<limits.h>
|
||||
#include "util/memory_manager.h"
|
||||
#include "util/hash.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
#define DEFAULT_HASHTABLE_INITIAL_CAPACITY 8
|
||||
#define SMALL_TABLE_CAPACITY 64
|
||||
|
||||
// #define HASHTABLE_STATISTICS
|
||||
// #define HASHTABLE_STATISTICS
|
||||
|
||||
#ifdef HASHTABLE_STATISTICS
|
||||
#define HS_CODE(CODE) { CODE }
|
||||
|
@ -91,9 +92,9 @@ class ptr_hash_entry {
|
|||
T * m_ptr;
|
||||
public:
|
||||
typedef T * data;
|
||||
ptr_hash_entry():m_ptr(0) {}
|
||||
ptr_hash_entry():m_ptr(nullptr) {}
|
||||
unsigned get_hash() const { return m_hash; }
|
||||
bool is_free() const { return m_ptr == 0; }
|
||||
bool is_free() const { return m_ptr == nullptr; }
|
||||
bool is_deleted() const { return m_ptr == reinterpret_cast<T *>(1); }
|
||||
bool is_used() const { return m_ptr != reinterpret_cast<T *>(0) && m_ptr != reinterpret_cast<T *>(1); }
|
||||
T * get_data() const { return m_ptr; }
|
||||
|
@ -101,7 +102,7 @@ public:
|
|||
void set_data(T * d) { m_ptr = d; }
|
||||
void set_hash(unsigned h) { m_hash = h; }
|
||||
void mark_as_deleted() { m_ptr = reinterpret_cast<T *>(1); }
|
||||
void mark_as_free() { m_ptr = 0; }
|
||||
void mark_as_free() { m_ptr = nullptr; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -114,9 +115,9 @@ class ptr_addr_hash_entry : public ptr_hash_entry<T> {
|
|||
T * m_ptr;
|
||||
public:
|
||||
typedef T * data;
|
||||
ptr_addr_hash_entry():m_ptr(0) {}
|
||||
ptr_addr_hash_entry():m_ptr(nullptr) {}
|
||||
unsigned get_hash() const { return get_ptr_hash(m_ptr); }
|
||||
bool is_free() const { return m_ptr == 0; }
|
||||
bool is_free() const { return m_ptr == nullptr; }
|
||||
bool is_deleted() const { return m_ptr == reinterpret_cast<T *>(1); }
|
||||
bool is_used() const { return m_ptr != reinterpret_cast<T *>(0) && m_ptr != reinterpret_cast<T *>(1); }
|
||||
T * get_data() const { return m_ptr; }
|
||||
|
@ -145,7 +146,7 @@ protected:
|
|||
|
||||
void delete_table() {
|
||||
dealloc_vect(m_table, m_capacity);
|
||||
m_table = 0;
|
||||
m_table = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -375,8 +376,7 @@ public:
|
|||
} ((void) 0)
|
||||
|
||||
void insert(data && e) {
|
||||
if ((m_size + m_num_deleted) << 2 > (m_capacity * 3)) {
|
||||
// if ((m_size + m_num_deleted) * 2 > (m_capacity)) {
|
||||
if (((m_size + m_num_deleted) << 2) > (m_capacity * 3)) {
|
||||
expand_table();
|
||||
}
|
||||
unsigned hash = get_hash(e);
|
||||
|
@ -385,7 +385,7 @@ public:
|
|||
entry * begin = m_table + idx;
|
||||
entry * end = m_table + m_capacity;
|
||||
entry * curr = begin;
|
||||
entry * del_entry = 0;
|
||||
entry * del_entry = nullptr;
|
||||
for (; curr != end; ++curr) {
|
||||
INSERT_LOOP_BODY();
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ public:
|
|||
entry * begin = m_table + idx;
|
||||
entry * end = m_table + m_capacity;
|
||||
entry * curr = begin;
|
||||
entry * del_entry = 0;
|
||||
entry * del_entry = nullptr;
|
||||
for (; curr != end; ++curr) {
|
||||
INSERT_LOOP_CORE_BODY();
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ public:
|
|||
INSERT_LOOP_CORE_BODY();
|
||||
}
|
||||
UNREACHABLE();
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool insert_if_not_there_core(const data & e, entry * & et) {
|
||||
|
@ -488,7 +488,9 @@ public:
|
|||
else if (curr->is_free()) { \
|
||||
return 0; \
|
||||
} \
|
||||
HS_CODE(const_cast<core_hashtable*>(this)->m_st_collision++;); \
|
||||
else { \
|
||||
HS_CODE(const_cast<core_hashtable*>(this)->m_st_collision++;); \
|
||||
} \
|
||||
} ((void) 0)
|
||||
|
||||
entry * find_core(data const & e) const {
|
||||
|
@ -504,12 +506,12 @@ public:
|
|||
for (curr = m_table; curr != begin; ++curr) {
|
||||
FIND_LOOP_BODY();
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool find(data const & k, data & r) const {
|
||||
entry * e = find_core(k);
|
||||
if (e != 0) {
|
||||
if (e != nullptr) {
|
||||
r = e->get_data();
|
||||
return true;
|
||||
}
|
||||
|
@ -517,7 +519,7 @@ public:
|
|||
}
|
||||
|
||||
bool contains(data const & e) const {
|
||||
return find_core(e) != 0;
|
||||
return find_core(e) != nullptr;
|
||||
}
|
||||
|
||||
iterator find(data const & e) const {
|
||||
|
@ -600,9 +602,8 @@ public:
|
|||
|
||||
core_hashtable& operator|=(core_hashtable const& other) {
|
||||
if (this == &other) return *this;
|
||||
iterator i = other.begin(), e = other.end();
|
||||
for (; i != e; ++i) {
|
||||
insert(*i);
|
||||
for (const data& d : other) {
|
||||
insert(d);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -610,10 +611,9 @@ public:
|
|||
core_hashtable& operator&=(core_hashtable const& other) {
|
||||
if (this == &other) return *this;
|
||||
core_hashtable copy(*this);
|
||||
iterator i = copy.begin(), e = copy.end();
|
||||
for (; i != e; ++i) {
|
||||
if (!other.contains(*i)) {
|
||||
remove(*i);
|
||||
for (const data& d : copy) {
|
||||
if (!other.contains(d)) {
|
||||
remove(d);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
|
@ -622,9 +622,8 @@ public:
|
|||
core_hashtable& operator=(core_hashtable const& other) {
|
||||
if (this == &other) return *this;
|
||||
reset();
|
||||
iterator i = other.begin(), e = other.end();
|
||||
for (; i != e; ++i) {
|
||||
insert(*i);
|
||||
for (const data& d : other) {
|
||||
insert(d);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -655,7 +654,33 @@ public:
|
|||
unsigned long long get_num_collision() const { return 0; }
|
||||
#endif
|
||||
|
||||
|
||||
#define COLL_LOOP_BODY() { \
|
||||
if (curr->is_used()) { \
|
||||
if (curr->get_hash() == hash && equals(curr->get_data(), e)) return; \
|
||||
collisions.push_back(curr->get_data()); \
|
||||
continue; \
|
||||
} \
|
||||
else if (curr->is_free()) { \
|
||||
continue; \
|
||||
} \
|
||||
collisions.push_back(curr->get_data()); \
|
||||
} ((void) 0);
|
||||
|
||||
void get_collisions(data const& e, vector<data>& collisions) {
|
||||
unsigned hash = get_hash(e);
|
||||
unsigned mask = m_capacity - 1;
|
||||
unsigned idx = hash & mask;
|
||||
entry * begin = m_table + idx;
|
||||
entry * end = m_table + m_capacity;
|
||||
entry * curr = begin;
|
||||
for (; curr != end; ++curr) {
|
||||
COLL_LOOP_BODY();
|
||||
}
|
||||
for (curr = m_table; curr != begin; ++curr) {
|
||||
COLL_LOOP_BODY();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename HashProc, typename EqProc>
|
||||
|
|
|
@ -27,10 +27,6 @@ class heap : private LT {
|
|||
int_vector m_values;
|
||||
int_vector m_value2indices;
|
||||
|
||||
bool less_than(int v1, int v2) const {
|
||||
return LT::operator()(v1, v2);
|
||||
}
|
||||
|
||||
static int left(int i) {
|
||||
return i << 1;
|
||||
}
|
||||
|
@ -126,6 +122,10 @@ public:
|
|||
CASSERT("heap", check_invariant());
|
||||
}
|
||||
|
||||
bool less_than(int v1, int v2) const {
|
||||
return LT::operator()(v1, v2);
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return m_values.size() == 1;
|
||||
}
|
||||
|
|
|
@ -91,8 +91,8 @@ hwf_manager::~hwf_manager()
|
|||
{
|
||||
}
|
||||
|
||||
uint64 RAW(double X) { uint64 tmp; memcpy(&tmp, &(X), sizeof(uint64)); return tmp; }
|
||||
double DBL(uint64 X) { double tmp; memcpy(&tmp, &(X), sizeof(double)); return tmp; }
|
||||
uint64_t RAW(double X) { uint64_t tmp; memcpy(&tmp, &(X), sizeof(uint64_t)); return tmp; }
|
||||
double DBL(uint64_t X) { double tmp; memcpy(&tmp, &(X), sizeof(double)); return tmp; }
|
||||
|
||||
void hwf_manager::set(hwf & o, int value) {
|
||||
o.value = (double) value;
|
||||
|
@ -147,7 +147,7 @@ void hwf_manager::set(hwf & o, mpf_rounding_mode rm, mpq const & significand, mp
|
|||
|
||||
mpq sig;
|
||||
m_mpq_manager.set(sig, significand);
|
||||
int64 exp = m_mpz_manager.get_int64(exponent);
|
||||
int64_t exp = m_mpz_manager.get_int64(exponent);
|
||||
|
||||
if (m_mpq_manager.is_zero(significand))
|
||||
o.value = 0.0;
|
||||
|
@ -160,17 +160,17 @@ void hwf_manager::set(hwf & o, mpf_rounding_mode rm, mpq const & significand, mp
|
|||
}
|
||||
|
||||
hwf s; s.value = m_mpq_manager.get_double(sig);
|
||||
uint64 r = (RAW(s.value) & 0x800FFFFFFFFFFFFFull) | ((exp + 1023) << 52);
|
||||
uint64_t r = (RAW(s.value) & 0x800FFFFFFFFFFFFFull) | ((exp + 1023) << 52);
|
||||
o.value = DBL(r);
|
||||
}
|
||||
}
|
||||
|
||||
void hwf_manager::set(hwf & o, bool sign, uint64 significand, int exponent) {
|
||||
void hwf_manager::set(hwf & o, bool sign, uint64_t significand, int exponent) {
|
||||
// Assumption: this represents (sign * -1) * (significand/2^sbits) * 2^exponent.
|
||||
SASSERT(significand <= 0x000FFFFFFFFFFFFFull);
|
||||
SASSERT(-1022 <= exponent && exponent <= 1023);
|
||||
uint64 raw = (sign?0x8000000000000000ull:0);
|
||||
raw |= (((uint64)exponent) + 1023) << 52;
|
||||
uint64_t raw = (sign?0x8000000000000000ull:0);
|
||||
raw |= (((uint64_t)exponent) + 1023) << 52;
|
||||
raw |= significand;
|
||||
memcpy(&o.value, &raw, sizeof(double));
|
||||
}
|
||||
|
@ -413,12 +413,12 @@ void hwf_manager::to_rational(hwf const & x, unsynch_mpq_manager & qm, mpq & o)
|
|||
scoped_mpz n(qm), d(qm);
|
||||
|
||||
if (is_normal(x))
|
||||
qm.set(n, sig(x) | 0x0010000000000000ull);
|
||||
qm.set(n, (uint64_t)(sig(x) | 0x0010000000000000ull));
|
||||
else
|
||||
qm.set(n, sig(x));
|
||||
if (sgn(x))
|
||||
qm.neg(n);
|
||||
qm.set(d, 0x0010000000000000ull);
|
||||
qm.set(d, (uint64_t)0x0010000000000000ull);
|
||||
int e = exp(x);
|
||||
if (e >= 0)
|
||||
qm.mul2k(n, (unsigned)e);
|
||||
|
@ -428,7 +428,7 @@ void hwf_manager::to_rational(hwf const & x, unsynch_mpq_manager & qm, mpq & o)
|
|||
}
|
||||
|
||||
bool hwf_manager::is_zero(hwf const & x) {
|
||||
uint64 t = RAW(x.value) & 0x7FFFFFFFFFFFFFFFull;
|
||||
uint64_t t = RAW(x.value) & 0x7FFFFFFFFFFFFFFFull;
|
||||
return (t == 0x0ull);
|
||||
// CMW: I tried, and these are slower:
|
||||
// return (t != 0x0ull) ? false : true;
|
||||
|
@ -483,12 +483,12 @@ bool hwf_manager::is_ninf(hwf const & x) {
|
|||
}
|
||||
|
||||
bool hwf_manager::is_normal(hwf const & x) {
|
||||
uint64 t = RAW(x.value) & 0x7FF0000000000000ull;
|
||||
uint64_t t = RAW(x.value) & 0x7FF0000000000000ull;
|
||||
return (t != 0x0ull && t != 0x7FF0000000000000ull);
|
||||
}
|
||||
|
||||
bool hwf_manager::is_denormal(hwf const & x) {
|
||||
uint64 t = RAW(x.value);
|
||||
uint64_t t = RAW(x.value);
|
||||
return ((t & 0x7FF0000000000000ull) == 0x0 &&
|
||||
(t & 0x000FFFFFFFFFFFFFull) != 0x0);
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ bool hwf_manager::is_regular(hwf const & x) {
|
|||
// Note that +-0.0 and denormal numbers have exponent==0; these are regular.
|
||||
// All normal numbers are also regular. What remains is +-Inf and NaN, they are
|
||||
// not regular and they are the only numbers that have exponent 7FF.
|
||||
uint64 e = RAW(x.value) & 0x7FF0000000000000ull; // the exponent
|
||||
uint64_t e = RAW(x.value) & 0x7FF0000000000000ull; // the exponent
|
||||
return (e != 0x7FF0000000000000ull);
|
||||
}
|
||||
|
||||
|
@ -513,15 +513,15 @@ bool hwf_manager::is_int(hwf const & x) {
|
|||
return false;
|
||||
else
|
||||
{
|
||||
uint64 t = sig(x);
|
||||
uint64_t t = sig(x);
|
||||
unsigned shift = 52 - ((unsigned)e);
|
||||
uint64 mask = (0x1ull << shift) - 1;
|
||||
uint64_t mask = (0x1ull << shift) - 1;
|
||||
return (t & mask) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
void hwf_manager::mk_nzero(hwf & o) {
|
||||
uint64 raw = 0x8000000000000000ull;
|
||||
uint64_t raw = 0x8000000000000000ull;
|
||||
o.value = DBL(raw);
|
||||
}
|
||||
|
||||
|
@ -537,22 +537,22 @@ void hwf_manager::mk_zero(bool sign, hwf & o) {
|
|||
}
|
||||
|
||||
void hwf_manager::mk_nan(hwf & o) {
|
||||
uint64 raw = 0x7FF0000000000001ull;
|
||||
uint64_t raw = 0x7FF0000000000001ull;
|
||||
o.value = DBL(raw);
|
||||
}
|
||||
|
||||
void hwf_manager::mk_inf(bool sign, hwf & o) {
|
||||
uint64 raw = (sign) ? 0xFFF0000000000000ull : 0x7FF0000000000000ull;
|
||||
uint64_t raw = (sign) ? 0xFFF0000000000000ull : 0x7FF0000000000000ull;
|
||||
o.value = DBL(raw);
|
||||
}
|
||||
|
||||
void hwf_manager::mk_pinf(hwf & o) {
|
||||
uint64 raw = 0x7FF0000000000000ull;
|
||||
uint64_t raw = 0x7FF0000000000000ull;
|
||||
o.value = DBL(raw);
|
||||
}
|
||||
|
||||
void hwf_manager::mk_ninf(hwf & o) {
|
||||
uint64 raw = 0xFFF0000000000000ull;
|
||||
uint64_t raw = 0xFFF0000000000000ull;
|
||||
o.value = DBL(raw);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ class hwf {
|
|||
friend class hwf_manager;
|
||||
double value;
|
||||
hwf & operator=(hwf const & other) { UNREACHABLE(); return *this; }
|
||||
uint64 get_raw() const {
|
||||
uint64 n;
|
||||
uint64_t get_raw() const {
|
||||
uint64_t n;
|
||||
SASSERT(sizeof(n) == sizeof(value));
|
||||
memcpy(&n, &value, sizeof(value));
|
||||
return n;
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
void set(hwf & o, mpf_rounding_mode rm, mpq const & value);
|
||||
void set(hwf & o, mpf_rounding_mode rm, char const * value);
|
||||
void set(hwf & o, mpf_rounding_mode rm, mpq const & significand, mpz const & exponent);
|
||||
void set(hwf & o, bool sign, uint64 significand, int exponent);
|
||||
void set(hwf & o, bool sign, uint64_t significand, int exponent);
|
||||
void set(hwf & o, hwf const & x);
|
||||
|
||||
// auxiliary methods to make the interface compatible with mpf
|
||||
|
@ -128,7 +128,7 @@ public:
|
|||
return (x.get_raw() & 0x8000000000000000ull) != 0;
|
||||
}
|
||||
|
||||
uint64 sig(hwf const & x) const {
|
||||
uint64_t sig(hwf const & x) const {
|
||||
return x.get_raw() & 0x000FFFFFFFFFFFFFull;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,12 +118,12 @@ class inf_eps_rational {
|
|||
|
||||
bool is_rational() const { return m_infty.is_zero() && m_r.is_rational(); }
|
||||
|
||||
int64 get_int64() const {
|
||||
int64_t get_int64() const {
|
||||
SASSERT(is_int64());
|
||||
return m_r.get_int64();
|
||||
}
|
||||
|
||||
uint64 get_uint64() const {
|
||||
uint64_t get_uint64() const {
|
||||
SASSERT(is_uint64());
|
||||
return m_r.get_uint64();
|
||||
}
|
||||
|
|
|
@ -109,12 +109,12 @@ class inf_int_rational {
|
|||
|
||||
bool is_rational() const { return m_second == 0; }
|
||||
|
||||
int64 get_int64() const {
|
||||
int64_t get_int64() const {
|
||||
SASSERT(is_int64());
|
||||
return m_first.get_int64();
|
||||
}
|
||||
|
||||
uint64 get_uint64() const {
|
||||
uint64_t get_uint64() const {
|
||||
SASSERT(is_uint64());
|
||||
return m_first.get_uint64();
|
||||
}
|
||||
|
|
|
@ -122,12 +122,12 @@ class inf_rational {
|
|||
|
||||
bool is_rational() const { return m_second.is_zero(); }
|
||||
|
||||
int64 get_int64() const {
|
||||
int64_t get_int64() const {
|
||||
SASSERT(is_int64());
|
||||
return m_first.get_int64();
|
||||
}
|
||||
|
||||
uint64 get_uint64() const {
|
||||
uint64_t get_uint64() const {
|
||||
SASSERT(is_uint64());
|
||||
return m_first.get_uint64();
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ class inf_s_integer {
|
|||
bool is_int64() const { return m_second == 0; }
|
||||
bool is_uint64() const { return m_second == 0; }
|
||||
bool is_rational() const { return m_second == 0; }
|
||||
int64 get_int64() const { return m_first; }
|
||||
uint64 get_uint64() const { return m_first; }
|
||||
int64_t get_int64() const { return m_first; }
|
||||
uint64_t get_uint64() const { return m_first; }
|
||||
s_integer get_rational() const { return s_integer(m_first); }
|
||||
s_integer get_infinitesimal() const { return s_integer(m_second); }
|
||||
inf_s_integer & operator=(const inf_s_integer & r) {
|
||||
|
|
|
@ -28,7 +28,7 @@ class list {
|
|||
list * m_tail;
|
||||
|
||||
public:
|
||||
list(T const & h, list * t = 0):
|
||||
list(T const & h, list * t = nullptr):
|
||||
m_head(h),
|
||||
m_tail(t) {
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ unsigned length(list<T> * l) {
|
|||
*/
|
||||
template<typename T>
|
||||
list<T> * append(region & r, list<T> * l1, list<T> * l2) {
|
||||
if (l2 == 0) {
|
||||
if (l2 == nullptr) {
|
||||
return l1;
|
||||
}
|
||||
ptr_buffer<list<T> > buffer;
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
|
||||
unsigned get_column_width(unsigned column);
|
||||
|
||||
unsigned regular_cell_width(unsigned row, unsigned column, std::string name) {
|
||||
unsigned regular_cell_width(unsigned row, unsigned column, const std::string & name) {
|
||||
return regular_cell_string(row, column, name).size();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,13 +79,14 @@ public:
|
|||
|
||||
void apply_from_left_to_X(vector<X> & w, lp_settings & );
|
||||
|
||||
virtual void set_number_of_rows(unsigned /*m*/) {}
|
||||
virtual void set_number_of_columns(unsigned /*n*/) { }
|
||||
void set_number_of_rows(unsigned /*m*/) override {}
|
||||
void set_number_of_columns(unsigned /*n*/) override {}
|
||||
#ifdef Z3DEBUG
|
||||
T get_elem(unsigned i, unsigned j) const override { return m_values[i * m_n + j]; }
|
||||
#endif
|
||||
|
||||
T get_elem(unsigned i, unsigned j) const { return m_values[i * m_n + j]; }
|
||||
|
||||
unsigned row_count() const { return m_m; }
|
||||
unsigned column_count() const { return m_n; }
|
||||
unsigned row_count() const override { return m_m; }
|
||||
unsigned column_count() const override { return m_n; }
|
||||
|
||||
void set_elem(unsigned i, unsigned j, const T& val) { m_values[i * m_n + j] = val; }
|
||||
|
||||
|
|
334
src/util/lp/disjoint_intervals.h
Normal file
334
src/util/lp/disjoint_intervals.h
Normal file
|
@ -0,0 +1,334 @@
|
|||
/*
|
||||
Copyright (c) 2017 Microsoft Corporation
|
||||
Author: Lev Nachmanson
|
||||
*/
|
||||
#pragma once
|
||||
#include <map>
|
||||
namespace lp {
|
||||
// represents the set of disjoint intervals of integer number
|
||||
struct disjoint_intervals {
|
||||
std::map<int, short> m_endpoints; // 0 means start, 1 means end, 2 means both - for a point interval
|
||||
bool m_empty;
|
||||
// constructors create an interval containing all integer numbers or an empty interval
|
||||
disjoint_intervals() : m_empty(false) {}
|
||||
disjoint_intervals(bool is_empty) : m_empty(is_empty) {}
|
||||
|
||||
bool is_start(short x) const { return x == 0 || x == 2; }
|
||||
bool is_start(const std::map<int, short>::iterator & it) const {
|
||||
return is_start(it->second);
|
||||
}
|
||||
bool is_start(const std::map<int, short>::reverse_iterator & it) const {
|
||||
return is_start(it->second);
|
||||
}
|
||||
bool is_end(short x) const { return x == 1 || x == 2; }
|
||||
bool is_end(const std::map<int, short>::iterator & it) const {
|
||||
return is_end(it->second);
|
||||
}
|
||||
bool is_end(const std::map<int, short>::reverse_iterator & it) const {
|
||||
return is_end(it->second);
|
||||
}
|
||||
|
||||
int pos(const std::map<int, short>::iterator & it) const {
|
||||
return it->first;
|
||||
}
|
||||
int pos(const std::map<int, short>::reverse_iterator & it) const {
|
||||
return it->first;
|
||||
}
|
||||
|
||||
int bound_kind(const std::map<int, short>::iterator & it) const {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
int bound_kind(const std::map<int, short>::reverse_iterator & it) const {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool is_proper_start(short x) const { return x == 0; }
|
||||
bool is_proper_end(short x) const { return x == 1; }
|
||||
bool is_proper_end(const std::map<int, short>::iterator & it) const {
|
||||
return is_proper_end(it->second);
|
||||
}
|
||||
bool is_proper_end(const std::map<int, short>::reverse_iterator & it) const {
|
||||
return is_proper_end(it->second);
|
||||
}
|
||||
|
||||
bool is_one_point_interval(short x) const { return x == 2; }
|
||||
bool is_one_point_interval(const std::map<int, short>::iterator & it) const {
|
||||
return is_one_point_interval(it->second);
|
||||
}
|
||||
bool is_one_point_interval(const std::map<int, short>::reverse_iterator & it) const {
|
||||
return is_one_point_interval(it->second);
|
||||
}
|
||||
|
||||
|
||||
void erase(int x) {
|
||||
m_endpoints.erase(x);
|
||||
}
|
||||
|
||||
void set_one_point_segment(int x) {
|
||||
m_endpoints[x] = 2;
|
||||
}
|
||||
|
||||
void set_start(int x) {
|
||||
m_endpoints[x] = 0;
|
||||
}
|
||||
|
||||
void set_end(int x) {
|
||||
m_endpoints[x] = 1;
|
||||
}
|
||||
|
||||
void remove_all_endpoints_below(int x) {
|
||||
while (m_endpoints.begin() != m_endpoints.end() && m_endpoints.begin()->first < x)
|
||||
m_endpoints.erase(m_endpoints.begin());
|
||||
}
|
||||
// we intersect the existing set with the half open to the right interval
|
||||
void intersect_with_lower_bound(int x) {
|
||||
if (m_empty)
|
||||
return;
|
||||
if (m_endpoints.empty()) {
|
||||
set_start(x);
|
||||
return;
|
||||
}
|
||||
bool pos_inf = has_pos_inf();
|
||||
auto it = m_endpoints.begin();
|
||||
while (it != m_endpoints.end() && pos(it) < x) {
|
||||
m_endpoints.erase(it);
|
||||
it = m_endpoints.begin();
|
||||
}
|
||||
if (m_endpoints.empty()) {
|
||||
if (!pos_inf) {
|
||||
m_empty = true;
|
||||
return;
|
||||
}
|
||||
set_start(x);
|
||||
return;
|
||||
}
|
||||
lp_assert(pos(it) >= x);
|
||||
if (pos(it) == x) {
|
||||
if (is_proper_end(it))
|
||||
set_one_point_segment(x);
|
||||
}
|
||||
else { // x(it) > x
|
||||
if (is_proper_end(it)) {
|
||||
set_start(x);
|
||||
}
|
||||
}
|
||||
|
||||
lp_assert(is_correct());
|
||||
}
|
||||
|
||||
// we intersect the existing set with the half open interval
|
||||
void intersect_with_upper_bound(int x) {
|
||||
if (m_empty)
|
||||
return;
|
||||
if (m_endpoints.empty()) {
|
||||
set_end(x);
|
||||
return;
|
||||
}
|
||||
bool neg_inf = has_neg_inf();
|
||||
auto it = m_endpoints.rbegin();
|
||||
|
||||
while (!m_endpoints.empty() && pos(it) > x) {
|
||||
m_endpoints.erase(std::prev(m_endpoints.end()));
|
||||
it = m_endpoints.rbegin();
|
||||
}
|
||||
if (m_endpoints.empty()) {
|
||||
if (!neg_inf) {
|
||||
m_empty = true;
|
||||
return;
|
||||
}
|
||||
set_end(x);
|
||||
}
|
||||
lp_assert(pos(it) <= x);
|
||||
if (pos(it) == x) {
|
||||
if (is_one_point_interval(it)) {}
|
||||
else if (is_proper_end(it)) {}
|
||||
else {// is_proper_start(it->second)
|
||||
set_one_point_segment(x);
|
||||
}
|
||||
}
|
||||
else { // pos(it) < x}
|
||||
if (is_start(it))
|
||||
set_end(x);
|
||||
}
|
||||
lp_assert(is_correct());
|
||||
}
|
||||
|
||||
bool has_pos_inf() const {
|
||||
if (m_empty)
|
||||
return false;
|
||||
|
||||
if (m_endpoints.empty())
|
||||
return true;
|
||||
|
||||
lp_assert(m_endpoints.rbegin() != m_endpoints.rend());
|
||||
return m_endpoints.rbegin()->second == 0;
|
||||
}
|
||||
|
||||
bool has_neg_inf() const {
|
||||
if (m_empty)
|
||||
return false;
|
||||
|
||||
if (m_endpoints.empty())
|
||||
return true;
|
||||
auto it = m_endpoints.begin();
|
||||
return is_proper_end(it->second);//m_endpoints.begin());
|
||||
}
|
||||
|
||||
// we are intersecting
|
||||
void intersect_with_interval(int x, int y) {
|
||||
if (m_empty)
|
||||
return;
|
||||
lp_assert(x <= y);
|
||||
intersect_with_lower_bound(x);
|
||||
intersect_with_upper_bound(y);
|
||||
}
|
||||
|
||||
// add an intervar [x, inf]
|
||||
void unite_with_interval_x_pos_inf(int x) {
|
||||
if (m_empty) {
|
||||
set_start(x);
|
||||
m_empty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
while (!m_endpoints.empty() && pos(m_endpoints.rbegin()) > x) {
|
||||
m_endpoints.erase(std::prev(m_endpoints.end()));
|
||||
}
|
||||
|
||||
if (m_endpoints.empty()) {
|
||||
set_start(x);
|
||||
return;
|
||||
}
|
||||
auto it = m_endpoints.rbegin();
|
||||
lp_assert(pos(it) <= x);
|
||||
if (pos(it) == x) {
|
||||
if (is_end(it)) {
|
||||
m_endpoints.erase(x);
|
||||
} else {
|
||||
set_start(x);
|
||||
}
|
||||
} else if (pos(it) == x - 1 && is_end(it)) {
|
||||
m_endpoints.erase(x - 1); // closing the gap
|
||||
} else {
|
||||
if (!has_pos_inf())
|
||||
set_start(x);
|
||||
}
|
||||
}
|
||||
|
||||
// add an interval [-inf, x]
|
||||
void unite_with_interval_neg_inf_x(int x) {
|
||||
if (m_empty) {
|
||||
set_end(x);
|
||||
m_empty = false;
|
||||
return;
|
||||
}
|
||||
auto it = m_endpoints.upper_bound(x);
|
||||
|
||||
if (it == m_endpoints.end()) {
|
||||
bool pos_inf = has_pos_inf();
|
||||
m_endpoints.clear();
|
||||
// it could be the case where x is inside of the last infinite interval with pos inf
|
||||
if (!pos_inf)
|
||||
set_end(x);
|
||||
return;
|
||||
}
|
||||
lp_assert(pos(it) > x);
|
||||
if (is_one_point_interval(pos(it))) {
|
||||
set_end(it->second);
|
||||
} else {
|
||||
if (is_start(it->second)) {
|
||||
set_end(x);
|
||||
}
|
||||
}
|
||||
|
||||
while (!m_endpoints.empty() && m_endpoints.begin()->first < x) {
|
||||
m_endpoints.erase(m_endpoints.begin());
|
||||
}
|
||||
lp_assert(is_correct());
|
||||
}
|
||||
|
||||
void unite_with_interval(int x, int y) {
|
||||
lp_assert(false); // not implemented
|
||||
}
|
||||
|
||||
bool is_correct() const {
|
||||
if (m_empty) {
|
||||
if (m_endpoints.size() > 0) {
|
||||
std::cout << "is empty is true but m_endpoints.size() = " << m_endpoints.size() << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool expect_end;
|
||||
bool prev = false;
|
||||
int prev_x;
|
||||
for (auto t : m_endpoints) {
|
||||
if (prev && (expect_end != t.second > 0)) {
|
||||
std::cout << "x = " << t.first << "\n";
|
||||
if (expect_end) {
|
||||
std::cout << "expecting an interval end\n";
|
||||
} else {
|
||||
std::cout << "expecting an interval start\n";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (t.second == 2) {
|
||||
expect_end = false; // swallow a point interval
|
||||
} else {
|
||||
if (prev)
|
||||
expect_end = !expect_end;
|
||||
else
|
||||
expect_end = is_start(t.second);
|
||||
}
|
||||
if (prev) {
|
||||
if (t.first - prev_x <= 1) {
|
||||
std::cout << "the sequence is not increasing or the gap is too small: " << prev_x << ", " << t.first << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
prev = true;
|
||||
prev_x = t.first;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void print(std::ostream & out) const {
|
||||
if (m_empty) {
|
||||
out << "empty\n";
|
||||
return;
|
||||
}
|
||||
if (m_endpoints.empty()){
|
||||
out << "[-oo,oo]\n";
|
||||
return;
|
||||
}
|
||||
bool first = true;
|
||||
for (auto t : m_endpoints) {
|
||||
if (first) {
|
||||
if (t.second == 1) {
|
||||
out << "[-oo," << t.first << "]";
|
||||
}
|
||||
else if (t.second == 0)
|
||||
out << "[" << t.first << ",";
|
||||
else if (t.second == 2)
|
||||
out << "[" << t.first << "]";
|
||||
first = false;
|
||||
} else {
|
||||
if (t.second==0)
|
||||
out << "[" << t.first << ",";
|
||||
else if (t.second == 1)
|
||||
out << t.first << "]";
|
||||
else if (t.second == 2)
|
||||
out << "[" << t.first << "]";
|
||||
}
|
||||
}
|
||||
if (has_pos_inf())
|
||||
out << "oo]";
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
|
@ -46,7 +46,7 @@ public:
|
|||
#endif
|
||||
m_column_index(column_index) {}
|
||||
|
||||
bool is_dense() const { return false; }
|
||||
bool is_dense() const override { return false; }
|
||||
|
||||
void print(std::ostream & out) {
|
||||
print_matrix(*this, out);
|
||||
|
@ -65,12 +65,12 @@ public:
|
|||
return m_diagonal_element;
|
||||
}
|
||||
|
||||
void apply_from_left(vector<X> & w, lp_settings & );
|
||||
void apply_from_left(vector<X> & w, lp_settings & ) override;
|
||||
|
||||
template <typename L>
|
||||
void apply_from_left_local(indexed_vector<L> & w, lp_settings & settings);
|
||||
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) {
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override {
|
||||
apply_from_left_local(w, settings);
|
||||
}
|
||||
|
||||
|
@ -80,15 +80,15 @@ public:
|
|||
m_column_vector.push_back(row_index, val);
|
||||
}
|
||||
|
||||
void apply_from_right(vector<T> & w);
|
||||
void apply_from_right(indexed_vector<T> & w);
|
||||
void apply_from_right(vector<T> & w) override;
|
||||
void apply_from_right(indexed_vector<T> & w) override;
|
||||
|
||||
T get_elem(unsigned i, unsigned j) const;
|
||||
#ifdef Z3DEBUG
|
||||
unsigned row_count() const { return m_length; }
|
||||
unsigned column_count() const { return m_length; }
|
||||
void set_number_of_rows(unsigned m) { m_length = m; }
|
||||
void set_number_of_columns(unsigned n) { m_length = n; }
|
||||
T get_elem(unsigned i, unsigned j) const override;
|
||||
unsigned row_count() const override { return m_length; }
|
||||
unsigned column_count() const override { return m_length; }
|
||||
void set_number_of_rows(unsigned m) override { m_length = m; }
|
||||
void set_number_of_columns(unsigned n) override { m_length = n; }
|
||||
#endif
|
||||
void divide_by_diagonal_element() {
|
||||
m_column_vector.divide(m_diagonal_element);
|
||||
|
|
|
@ -27,14 +27,14 @@ struct iterator_on_column:linear_combination_iterator<T> {
|
|||
const vector<column_cell>& m_column; // the offset in term coeffs
|
||||
const static_matrix<T, X> & m_A;
|
||||
int m_i; // the initial offset in the column
|
||||
unsigned size() const { return m_column.size(); }
|
||||
unsigned size() const override { return m_column.size(); }
|
||||
iterator_on_column(const vector<column_cell>& column, const static_matrix<T,X> & A) // the offset in term coeffs
|
||||
:
|
||||
m_column(column),
|
||||
m_A(A),
|
||||
m_i(-1) {}
|
||||
|
||||
bool next(mpq & a, unsigned & i) {
|
||||
bool next(mpq & a, unsigned & i) override {
|
||||
if (++m_i >= static_cast<int>(m_column.size()))
|
||||
return false;
|
||||
|
||||
|
@ -44,7 +44,7 @@ struct iterator_on_column:linear_combination_iterator<T> {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool next(unsigned & i) {
|
||||
bool next(unsigned & i) override {
|
||||
if (++m_i >= static_cast<int>(m_column.size()))
|
||||
return false;
|
||||
|
||||
|
@ -53,11 +53,11 @@ struct iterator_on_column:linear_combination_iterator<T> {
|
|||
return true;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
void reset() override {
|
||||
m_i = -1;
|
||||
}
|
||||
|
||||
linear_combination_iterator<mpq> * clone() {
|
||||
linear_combination_iterator<mpq> * clone() override {
|
||||
iterator_on_column * r = new iterator_on_column(m_column, m_A);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ struct iterator_on_indexed_vector:linear_combination_iterator<T> {
|
|||
m_v(v),
|
||||
m_offset(0)
|
||||
{}
|
||||
unsigned size() const { return m_v.m_index.size(); }
|
||||
bool next(T & a, unsigned & i) {
|
||||
unsigned size() const override { return m_v.m_index.size(); }
|
||||
bool next(T & a, unsigned & i) override {
|
||||
if (m_offset >= m_v.m_index.size())
|
||||
return false;
|
||||
i = m_v.m_index[m_offset++];
|
||||
|
@ -37,16 +37,16 @@ struct iterator_on_indexed_vector:linear_combination_iterator<T> {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool next(unsigned & i) {
|
||||
bool next(unsigned & i) override {
|
||||
if (m_offset >= m_v.m_index.size())
|
||||
return false;
|
||||
i = m_v.m_index[m_offset++];
|
||||
return true;
|
||||
}
|
||||
void reset() {
|
||||
void reset() override {
|
||||
m_offset = 0;
|
||||
}
|
||||
linear_combination_iterator<T>* clone() {
|
||||
linear_combination_iterator<T>* clone() override {
|
||||
return new iterator_on_indexed_vector(m_v);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -26,11 +26,11 @@ struct iterator_on_pivot_row:linear_combination_iterator<T> {
|
|||
const indexed_vector<T> & m_v;
|
||||
unsigned m_basis_j;
|
||||
iterator_on_indexed_vector<T> m_it;
|
||||
unsigned size() const { return m_it.size(); }
|
||||
unsigned size() const override { return m_it.size(); }
|
||||
iterator_on_pivot_row(const indexed_vector<T> & v, unsigned basis_j) :
|
||||
m_basis_returned(false),
|
||||
m_v(v), m_basis_j(basis_j), m_it(v) {}
|
||||
bool next(T & a, unsigned & i) {
|
||||
bool next(T & a, unsigned & i) override {
|
||||
if (m_basis_returned == false) {
|
||||
m_basis_returned = true;
|
||||
a = one_of_type<T>();
|
||||
|
@ -39,7 +39,7 @@ struct iterator_on_pivot_row:linear_combination_iterator<T> {
|
|||
}
|
||||
return m_it.next(a, i);
|
||||
}
|
||||
bool next(unsigned & i) {
|
||||
bool next(unsigned & i) override {
|
||||
if (m_basis_returned == false) {
|
||||
m_basis_returned = true;
|
||||
i = m_basis_j;
|
||||
|
@ -47,11 +47,11 @@ struct iterator_on_pivot_row:linear_combination_iterator<T> {
|
|||
}
|
||||
return m_it.next(i);
|
||||
}
|
||||
void reset() {
|
||||
void reset() override {
|
||||
m_basis_returned = false;
|
||||
m_it.reset();
|
||||
}
|
||||
linear_combination_iterator<T> * clone() {
|
||||
linear_combination_iterator<T> * clone() override {
|
||||
iterator_on_pivot_row * r = new iterator_on_pivot_row(m_v, m_basis_j);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ struct iterator_on_row:linear_combination_iterator<T> {
|
|||
unsigned m_i; // offset
|
||||
iterator_on_row(const vector<row_cell<T>> & row) : m_row(row), m_i(0)
|
||||
{}
|
||||
unsigned size() const { return m_row.size(); }
|
||||
bool next(T & a, unsigned & i) {
|
||||
unsigned size() const override { return m_row.size(); }
|
||||
bool next(T & a, unsigned & i) override {
|
||||
if (m_i == m_row.size())
|
||||
return false;
|
||||
auto &c = m_row[m_i++];
|
||||
|
@ -35,17 +35,17 @@ struct iterator_on_row:linear_combination_iterator<T> {
|
|||
a = c.get_val();
|
||||
return true;
|
||||
}
|
||||
bool next(unsigned & i) {
|
||||
bool next(unsigned & i) override {
|
||||
if (m_i == m_row.size())
|
||||
return false;
|
||||
auto &c = m_row[m_i++];
|
||||
i = c.m_j;
|
||||
return true;
|
||||
}
|
||||
void reset() {
|
||||
void reset() override {
|
||||
m_i = 0;
|
||||
}
|
||||
linear_combination_iterator<T>* clone() {
|
||||
linear_combination_iterator<T>* clone() override {
|
||||
return new iterator_on_row(m_row);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -27,14 +27,14 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator<mpq> {
|
|||
std::unordered_map<unsigned, mpq>::const_iterator m_i; // the offset in term coeffs
|
||||
bool m_term_j_returned;
|
||||
unsigned m_term_j;
|
||||
unsigned size() const {return static_cast<unsigned>(m_term.m_coeffs.size() + 1);}
|
||||
unsigned size() const override {return static_cast<unsigned>(m_term.m_coeffs.size() + 1);}
|
||||
iterator_on_term_with_basis_var(const lar_term & t, unsigned term_j) :
|
||||
m_term(t),
|
||||
m_i(t.m_coeffs.begin()),
|
||||
m_term_j_returned(false),
|
||||
m_term_j(term_j) {}
|
||||
|
||||
bool next(mpq & a, unsigned & i) {
|
||||
bool next(mpq & a, unsigned & i) override {
|
||||
if (m_term_j_returned == false) {
|
||||
m_term_j_returned = true;
|
||||
a = - one_of_type<mpq>();
|
||||
|
@ -48,7 +48,7 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator<mpq> {
|
|||
m_i++;
|
||||
return true;
|
||||
}
|
||||
bool next(unsigned & i) {
|
||||
bool next(unsigned & i) override {
|
||||
if (m_term_j_returned == false) {
|
||||
m_term_j_returned = true;
|
||||
i = m_term_j;
|
||||
|
@ -60,11 +60,11 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator<mpq> {
|
|||
m_i++;
|
||||
return true;
|
||||
}
|
||||
void reset() {
|
||||
void reset() override {
|
||||
m_term_j_returned = false;
|
||||
m_i = m_term.m_coeffs.begin();
|
||||
}
|
||||
linear_combination_iterator<mpq> * clone() {
|
||||
linear_combination_iterator<mpq> * clone() override {
|
||||
iterator_on_term_with_basis_var * r = new iterator_on_term_with_basis_var(m_term, m_term_j);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -59,24 +59,24 @@ public:
|
|||
|
||||
struct lar_var_constraint: public lar_base_constraint {
|
||||
unsigned m_j;
|
||||
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const {
|
||||
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const override {
|
||||
vector<std::pair<mpq, var_index>> ret;
|
||||
ret.push_back(std::make_pair(one_of_type<mpq>(), m_j));
|
||||
return ret;
|
||||
}
|
||||
unsigned size() const { return 1;}
|
||||
unsigned size() const override { return 1;}
|
||||
lar_var_constraint(unsigned j, lconstraint_kind kind, const mpq& right_side) : lar_base_constraint(kind, right_side), m_j(j) { }
|
||||
};
|
||||
|
||||
|
||||
struct lar_term_constraint: public lar_base_constraint {
|
||||
const lar_term * m_term;
|
||||
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const {
|
||||
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const override {
|
||||
return m_term->coeffs_as_vector();
|
||||
}
|
||||
unsigned size() const { return m_term->size();}
|
||||
unsigned size() const override { return m_term->size();}
|
||||
lar_term_constraint(const lar_term *t, lconstraint_kind kind, const mpq& right_side) : lar_base_constraint(kind, right_side), m_term(t) { }
|
||||
virtual mpq get_free_coeff_of_left_side() const { return m_term->m_v;}
|
||||
mpq get_free_coeff_of_left_side() const override { return m_term->m_v;}
|
||||
|
||||
};
|
||||
|
||||
|
@ -84,7 +84,6 @@ struct lar_term_constraint: public lar_base_constraint {
|
|||
class lar_constraint : public lar_base_constraint {
|
||||
public:
|
||||
vector<std::pair<mpq, var_index>> m_coeffs;
|
||||
lar_constraint() {}
|
||||
lar_constraint(const vector<std::pair<mpq, var_index>> & left_side, lconstraint_kind kind, const mpq & right_side)
|
||||
: lar_base_constraint(kind, right_side), m_coeffs(left_side) {}
|
||||
|
||||
|
@ -92,10 +91,10 @@ public:
|
|||
SASSERT(false); // should not be called : todo!
|
||||
}
|
||||
|
||||
unsigned size() const {
|
||||
unsigned size() const override {
|
||||
return static_cast<unsigned>(m_coeffs.size());
|
||||
}
|
||||
|
||||
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const { return m_coeffs; }
|
||||
vector<std::pair<mpq, var_index>> get_left_side_coefficients() const override { return m_coeffs; }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -481,7 +481,7 @@ public:
|
|||
}
|
||||
|
||||
bool no_r_lu() const {
|
||||
return m_r_solver.m_factorization == nullptr || m_r_solver.m_factorization->get_status() == LU_status::Degenerated;
|
||||
return m_r_solver.m_factorization == nullptr || m_r_solver.m_factorization->get_status() == LU_status::Degenerated;
|
||||
}
|
||||
|
||||
void solve_on_signature_tableau(const lar_solution_signature & signature, const vector<unsigned> & changes_of_basis) {
|
||||
|
|
|
@ -1011,7 +1011,7 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
std::string get_column_name(unsigned j) const {
|
||||
std::string get_column_name(unsigned j) const override {
|
||||
if (j >= m_terms_start_index)
|
||||
return std::string("_t") + T_to_string(j);
|
||||
if (j >= m_columns_to_ext_vars_or_term_indices.size())
|
||||
|
|
2089
src/util/lp/lar_solver.hpp
Normal file
2089
src/util/lp/lar_solver.hpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -207,6 +207,6 @@ public:
|
|||
|
||||
void solve();
|
||||
|
||||
bool low_bounds_are_set() const { return true; }
|
||||
bool low_bounds_are_set() const override { return true; }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class lp_dual_simplex: public lp_solver<T, X> {
|
|||
vector<column_type> m_column_types_of_logicals;
|
||||
vector<bool> m_can_enter_basis;
|
||||
public:
|
||||
~lp_dual_simplex() {
|
||||
~lp_dual_simplex() override {
|
||||
if (m_core_solver != nullptr) {
|
||||
delete m_core_solver;
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ public:
|
|||
|
||||
void copy_m_b_aside_and_set_it_to_zeros();
|
||||
|
||||
void find_maximal_solution();
|
||||
void find_maximal_solution() override;
|
||||
|
||||
virtual T get_column_value(unsigned column) const {
|
||||
T get_column_value(unsigned column) const override {
|
||||
return this->get_column_value_with_core_solver(column, m_core_solver);
|
||||
}
|
||||
|
||||
T get_current_cost() const;
|
||||
T get_current_cost() const override;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -770,7 +770,7 @@ public:
|
|||
|
||||
void init_reduced_costs();
|
||||
|
||||
bool low_bounds_are_set() const { return true; }
|
||||
bool low_bounds_are_set() const override { return true; }
|
||||
|
||||
int advance_on_sorted_breakpoints(unsigned entering, X & t);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
void set_core_solver_bounds();
|
||||
|
||||
void find_maximal_solution();
|
||||
void find_maximal_solution() override;
|
||||
|
||||
void fill_A_x_and_basis_for_stage_one_total_inf();
|
||||
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
void solve_with_total_inf();
|
||||
|
||||
|
||||
~lp_primal_simplex();
|
||||
~lp_primal_simplex() override;
|
||||
|
||||
bool bounds_hold(std::unordered_map<std::string, T> const & solution);
|
||||
|
||||
|
@ -96,11 +96,11 @@ public:
|
|||
return bounds_hold(solution) && row_constraints_hold(solution);
|
||||
}
|
||||
|
||||
virtual T get_column_value(unsigned column) const {
|
||||
T get_column_value(unsigned column) const override {
|
||||
return this->get_column_value_with_core_solver(column, m_core_solver);
|
||||
}
|
||||
|
||||
T get_current_cost() const;
|
||||
T get_current_cost() const override;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -109,7 +109,7 @@ private:
|
|||
default_lp_resource_limit(lp_settings& s): m_settings(s) {
|
||||
m_sw.start();
|
||||
}
|
||||
virtual bool get_cancel_flag() {
|
||||
bool get_cancel_flag() override {
|
||||
return (m_sw.get_current_seconds() > m_settings.time_limit);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,6 +34,7 @@ template void lp::lp_solver<double, double>::print_statistics_on_A(std::ostream
|
|||
template bool lp::lp_solver<double, double>::problem_is_empty();
|
||||
template void lp::lp_solver<double, double>::scale();
|
||||
template void lp::lp_solver<double, double>::set_scaled_cost(unsigned int);
|
||||
template std::string lp::lp_solver<double, double>::get_column_name(unsigned int) const;
|
||||
template lp::lp_solver<double, double>::~lp_solver();
|
||||
template void lp::lp_solver<lp::mpq, lp::mpq>::add_constraint(lp::lp_relation, lp::mpq, unsigned int);
|
||||
template void lp::lp_solver<lp::mpq, lp::mpq>::cleanup();
|
||||
|
@ -53,3 +54,4 @@ template void lp::lp_solver<lp::mpq, lp::mpq>::scale();
|
|||
template void lp::lp_solver<lp::mpq, lp::mpq>::set_scaled_cost(unsigned int);
|
||||
template lp::lp_solver<lp::mpq, lp::mpq>::~lp_solver();
|
||||
template double lp::lp_solver<double, double>::get_column_value_by_name(std::string) const;
|
||||
template std::string lp::lp_solver<lp::mpq, lp::mpq>::get_column_name(unsigned int) const;
|
||||
|
|
|
@ -67,31 +67,31 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
bool is_dense() const { return false; }
|
||||
bool is_dense() const override { return false; }
|
||||
|
||||
one_elem_on_diag(const one_elem_on_diag & o);
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
unsigned m_m;
|
||||
unsigned m_n;
|
||||
virtual void set_number_of_rows(unsigned m) { m_m = m; m_n = m; }
|
||||
virtual void set_number_of_columns(unsigned n) { m_m = n; m_n = n; }
|
||||
void set_number_of_rows(unsigned m) override { m_m = m; m_n = m; }
|
||||
void set_number_of_columns(unsigned n) override { m_m = n; m_n = n; }
|
||||
T m_one_over_val;
|
||||
|
||||
T get_elem (unsigned i, unsigned j) const;
|
||||
T get_elem (unsigned i, unsigned j) const override;
|
||||
|
||||
unsigned row_count() const { return m_m; } // not defined }
|
||||
unsigned column_count() const { return m_m; } // not defined }
|
||||
unsigned row_count() const override { return m_m; } // not defined }
|
||||
unsigned column_count() const override { return m_m; } // not defined }
|
||||
#endif
|
||||
void apply_from_left(vector<X> & w, lp_settings &) {
|
||||
void apply_from_left(vector<X> & w, lp_settings &) override {
|
||||
w[m_i] /= m_val;
|
||||
}
|
||||
|
||||
void apply_from_right(vector<T> & w) {
|
||||
void apply_from_right(vector<T> & w) override {
|
||||
w[m_i] /= m_val;
|
||||
}
|
||||
|
||||
void apply_from_right(indexed_vector<T> & w) {
|
||||
void apply_from_right(indexed_vector<T> & w) override {
|
||||
if (is_zero(w.m_data[m_i]))
|
||||
return;
|
||||
auto & v = w.m_data[m_i] /= m_val;
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings);
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override;
|
||||
|
||||
void conjugate_by_permutation(permutation_matrix<T, X> & p) {
|
||||
// this = p * this * p(-1)
|
||||
|
|
|
@ -95,7 +95,7 @@ inline vector<std::string> string_split(const std::string &source, const char *d
|
|||
return results;
|
||||
}
|
||||
|
||||
inline vector<std::string> split_and_trim(std::string line) {
|
||||
inline vector<std::string> split_and_trim(const std::string &line) {
|
||||
auto split = string_split(line, " \t", false);
|
||||
vector<std::string> ret;
|
||||
for (auto s : split) {
|
||||
|
@ -127,9 +127,9 @@ class mps_reader {
|
|||
std::string m_name;
|
||||
bound * m_bound;
|
||||
unsigned m_index;
|
||||
column(std::string name, unsigned index): m_name(name),
|
||||
m_bound(nullptr),
|
||||
m_index(index) {
|
||||
column(const std::string &name, unsigned index): m_name(name),
|
||||
m_bound(nullptr),
|
||||
m_index(index) {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -140,7 +140,7 @@ class mps_reader {
|
|||
unsigned m_index;
|
||||
T m_right_side;
|
||||
T m_range;
|
||||
row(row_type type, std::string name, unsigned index) :
|
||||
row(row_type type, const std::string &name, unsigned index) :
|
||||
m_type(type),
|
||||
m_name(name),
|
||||
m_index(index),
|
||||
|
@ -254,7 +254,7 @@ class mps_reader {
|
|||
} while (m_is_OK);
|
||||
}
|
||||
|
||||
void read_column_by_columns(std::string column_name, std::string column_data) {
|
||||
void read_column_by_columns(const std::string & column_name, std::string column_data) {
|
||||
// uph, let us try to work with columns
|
||||
if (column_data.size() >= 22) {
|
||||
std::string ss = column_data.substr(0, 8);
|
||||
|
@ -283,7 +283,7 @@ class mps_reader {
|
|||
}
|
||||
}
|
||||
|
||||
void read_column(std::string column_name, std::string column_data){
|
||||
void read_column(const std::string & column_name, const std::string & column_data){
|
||||
auto tokens = split_and_trim(column_data);
|
||||
for (unsigned i = 0; i < tokens.size() - 1; i+= 2) {
|
||||
auto row_name = tokens[i];
|
||||
|
@ -421,7 +421,7 @@ class mps_reader {
|
|||
}
|
||||
|
||||
|
||||
void read_bound_by_columns(std::string colstr) {
|
||||
void read_bound_by_columns(const std::string & colstr) {
|
||||
if (colstr.size() < 14) {
|
||||
(*m_message_stream) << "line is too short" << std::endl;
|
||||
(*m_message_stream) << m_line << std::endl;
|
||||
|
@ -763,7 +763,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
mps_reader(std::string file_name):
|
||||
mps_reader(const std::string & file_name):
|
||||
m_is_OK(true),
|
||||
m_file_name(file_name),
|
||||
m_file_stream(file_name),
|
||||
|
|
|
@ -38,10 +38,10 @@ template <typename T> class numeric_traits {};
|
|||
template <> class numeric_traits<unsigned> {
|
||||
public:
|
||||
static bool precise() { return true; }
|
||||
static unsigned const zero() { return 0; }
|
||||
static unsigned const one() { return 1; }
|
||||
static unsigned zero() { return 0; }
|
||||
static unsigned one() { return 1; }
|
||||
static bool is_zero(unsigned v) { return v == 0; }
|
||||
static double const get_double(unsigned const & d) { return d; }
|
||||
static double get_double(unsigned const & d) { return d; }
|
||||
};
|
||||
|
||||
template <> class numeric_traits<double> {
|
||||
|
@ -66,7 +66,7 @@ template <> class numeric_traits<double> {
|
|||
static rational const & zero() { return rational::zero(); }
|
||||
static rational const & one() { return rational::one(); }
|
||||
static bool is_zero(const rational & v) { return v.is_zero(); }
|
||||
static double const get_double(const rational & d) { return d.get_double();}
|
||||
static double get_double(const rational & d) { return d.get_double();}
|
||||
static rational log(rational const& r) { UNREACHABLE(); return r; }
|
||||
static rational from_string(std::string const & str) { return rational(str.c_str()); }
|
||||
static bool is_pos(const rational & d) {return d.is_pos();}
|
||||
|
|
|
@ -64,7 +64,7 @@ class permutation_matrix : public tail_matrix<T, X> {
|
|||
// create a unit permutation of the given length
|
||||
void init(unsigned length);
|
||||
unsigned get_rev(unsigned i) { return m_rev[i]; }
|
||||
bool is_dense() const { return false; }
|
||||
bool is_dense() const override { return false; }
|
||||
#ifdef Z3DEBUG
|
||||
permutation_matrix get_inverse() const {
|
||||
return permutation_matrix(size(), m_rev);
|
||||
|
@ -76,13 +76,13 @@ class permutation_matrix : public tail_matrix<T, X> {
|
|||
|
||||
unsigned operator[](unsigned i) const { return m_permutation[i]; }
|
||||
|
||||
void apply_from_left(vector<X> & w, lp_settings &);
|
||||
void apply_from_left(vector<X> & w, lp_settings &) override;
|
||||
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings);
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override;
|
||||
|
||||
void apply_from_right(vector<T> & w);
|
||||
void apply_from_right(vector<T> & w) override;
|
||||
|
||||
void apply_from_right(indexed_vector<T> & w);
|
||||
void apply_from_right(indexed_vector<T> & w) override;
|
||||
|
||||
template <typename L>
|
||||
void copy_aside(vector<L> & t, vector<unsigned> & tmp_index, indexed_vector<L> & w);
|
||||
|
@ -109,13 +109,13 @@ class permutation_matrix : public tail_matrix<T, X> {
|
|||
|
||||
void transpose_from_right(unsigned i, unsigned j);
|
||||
#ifdef Z3DEBUG
|
||||
T get_elem(unsigned i, unsigned j) const{
|
||||
T get_elem(unsigned i, unsigned j) const override {
|
||||
return m_permutation[i] == j? numeric_traits<T>::one() : numeric_traits<T>::zero();
|
||||
}
|
||||
unsigned row_count() const{ return size(); }
|
||||
unsigned column_count() const { return size(); }
|
||||
virtual void set_number_of_rows(unsigned /*m*/) { }
|
||||
virtual void set_number_of_columns(unsigned /*n*/) { }
|
||||
unsigned row_count() const override { return size(); }
|
||||
unsigned column_count() const override { return size(); }
|
||||
void set_number_of_rows(unsigned /*m*/) override { }
|
||||
void set_number_of_columns(unsigned /*n*/) override { }
|
||||
#endif
|
||||
void multiply_by_permutation_from_left(permutation_matrix<T, X> & p);
|
||||
|
||||
|
@ -132,7 +132,7 @@ class permutation_matrix : public tail_matrix<T, X> {
|
|||
|
||||
unsigned size() const { return static_cast<unsigned>(m_rev.size()); }
|
||||
|
||||
unsigned * values() const { return m_permutation; }
|
||||
unsigned * values() const { return m_permutation.c_ptr(); }
|
||||
|
||||
void resize(unsigned size) {
|
||||
unsigned old_size = m_permutation.size();
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
m_row_start(row_start), m_row(row) {
|
||||
}
|
||||
|
||||
bool is_dense() const { return false; }
|
||||
bool is_dense() const override { return false; }
|
||||
|
||||
void print(std::ostream & out) {
|
||||
print_matrix(*this, out);
|
||||
|
@ -60,12 +60,12 @@ public:
|
|||
return m_row_vector.m_data[m_row];
|
||||
}
|
||||
|
||||
void apply_from_left(vector<X> & w, lp_settings &);
|
||||
void apply_from_left(vector<X> & w, lp_settings &) override;
|
||||
|
||||
void apply_from_left_local_to_T(indexed_vector<T> & w, lp_settings & settings);
|
||||
void apply_from_left_local_to_X(indexed_vector<X> & w, lp_settings & settings);
|
||||
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) {
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override {
|
||||
apply_from_left_local_to_T(w, settings);
|
||||
}
|
||||
|
||||
|
@ -74,16 +74,16 @@ public:
|
|||
m_row_vector.push_back(row_index, val);
|
||||
}
|
||||
|
||||
void apply_from_right(vector<T> & w);
|
||||
void apply_from_right(indexed_vector<T> & w);
|
||||
void apply_from_right(vector<T> & w) override;
|
||||
void apply_from_right(indexed_vector<T> & w) override;
|
||||
|
||||
void conjugate_by_permutation(permutation_matrix<T, X> & p);
|
||||
#ifdef Z3DEBUG
|
||||
T get_elem(unsigned row, unsigned col) const;
|
||||
unsigned row_count() const { return m_dimension; }
|
||||
unsigned column_count() const { return m_dimension; }
|
||||
void set_number_of_rows(unsigned m) { m_dimension = m; }
|
||||
void set_number_of_columns(unsigned n) { m_dimension = n; }
|
||||
T get_elem(unsigned row, unsigned col) const override;
|
||||
unsigned row_count() const override { return m_dimension; }
|
||||
unsigned column_count() const override { return m_dimension; }
|
||||
void set_number_of_rows(unsigned m) override { m_dimension = m; }
|
||||
void set_number_of_columns(unsigned n) override { m_dimension = n; }
|
||||
#endif
|
||||
}; // end of row_eta_matrix
|
||||
}
|
||||
|
|
|
@ -162,8 +162,8 @@ public:
|
|||
unsigned dimension() const {return static_cast<unsigned>(m_row_permutation.size());}
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
unsigned row_count() const {return dimension();}
|
||||
unsigned column_count() const {return dimension();}
|
||||
unsigned row_count() const override {return dimension();}
|
||||
unsigned column_count() const override {return dimension();}
|
||||
#endif
|
||||
|
||||
void init_row_headers();
|
||||
|
@ -302,11 +302,11 @@ public:
|
|||
void solve_U_y_indexed_only(indexed_vector<L> & y, const lp_settings&, vector<unsigned> & sorted_active_rows );
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
T get_elem(unsigned i, unsigned j) const { return get(i, j); }
|
||||
T get_elem(unsigned i, unsigned j) const override { return get(i, j); }
|
||||
unsigned get_number_of_rows() const { return dimension(); }
|
||||
unsigned get_number_of_columns() const { return dimension(); }
|
||||
virtual void set_number_of_rows(unsigned /*m*/) { }
|
||||
virtual void set_number_of_columns(unsigned /*n*/) { }
|
||||
void set_number_of_rows(unsigned /*m*/) override { }
|
||||
void set_number_of_columns(unsigned /*n*/) override { }
|
||||
#endif
|
||||
template <typename L>
|
||||
L dot_product_with_row (unsigned row, const vector<L> & y) const;
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
void init(sparse_matrix<T, X> *parent_matrix, unsigned index_start);
|
||||
|
||||
bool is_dense() const { return true; }
|
||||
bool is_dense() const override { return true; }
|
||||
|
||||
ref operator[] (unsigned i) {
|
||||
SASSERT(i >= m_index_start);
|
||||
|
@ -137,13 +137,13 @@ public:
|
|||
|
||||
bool is_L_matrix() const;
|
||||
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) {
|
||||
void apply_from_left_to_T(indexed_vector<T> & w, lp_settings & settings) override {
|
||||
apply_from_left_local(w, settings);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void apply_from_right(indexed_vector<T> & w) {
|
||||
void apply_from_right(indexed_vector<T> & w) override {
|
||||
#if 1==0
|
||||
indexed_vector<T> wcopy = w;
|
||||
apply_from_right(wcopy.m_data);
|
||||
|
@ -207,18 +207,18 @@ public:
|
|||
w = m_work_vector;
|
||||
#endif
|
||||
}
|
||||
void apply_from_left(vector<X> & w, lp_settings & /*settings*/) {
|
||||
void apply_from_left(vector<X> & w, lp_settings & /*settings*/) override {
|
||||
apply_from_left_to_vector(w);// , settings);
|
||||
}
|
||||
|
||||
void apply_from_right(vector<T> & w);
|
||||
void apply_from_right(vector<T> & w) override;
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
T get_elem (unsigned i, unsigned j) const;
|
||||
unsigned row_count() const { return m_parent->row_count();}
|
||||
unsigned column_count() const { return row_count();}
|
||||
void set_number_of_rows(unsigned) {}
|
||||
void set_number_of_columns(unsigned) {};
|
||||
T get_elem (unsigned i, unsigned j) const override;
|
||||
unsigned row_count() const override { return m_parent->row_count();}
|
||||
unsigned column_count() const override { return row_count();}
|
||||
void set_number_of_rows(unsigned) override {}
|
||||
void set_number_of_columns(unsigned) override {}
|
||||
#endif
|
||||
void conjugate_by_permutation(permutation_matrix<T, X> & q);
|
||||
};
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
if (e) {
|
||||
v = e->get_data().m_value;
|
||||
}
|
||||
return (0 != e);
|
||||
return (nullptr != e);
|
||||
}
|
||||
|
||||
value const& get(key const& k, value const& default_value) const {
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
|
||||
|
||||
bool contains(key const & k) const {
|
||||
return find_core(k) != 0;
|
||||
return find_core(k) != nullptr;
|
||||
}
|
||||
|
||||
void remove(key const & k) {
|
||||
|
|
|
@ -128,7 +128,12 @@ public:
|
|||
turn = !turn;
|
||||
}
|
||||
if (clique.size() > 1) {
|
||||
cliques.push_back(clique);
|
||||
if (clique.size() == 2 && clique[0] == negate(clique[1])) {
|
||||
// no op
|
||||
}
|
||||
else {
|
||||
cliques.push_back(clique);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ Copyright (c) 2015 Microsoft Corporation
|
|||
#include "util/memory_manager.h"
|
||||
#include "util/error_codes.h"
|
||||
#include "util/z3_omp.h"
|
||||
#include "util/debug.h"
|
||||
// The following two function are automatically generated by the mk_make.py script.
|
||||
// The script collects ADD_INITIALIZER and ADD_FINALIZER commands in the .h files.
|
||||
// For example, rational.h contains
|
||||
|
@ -57,6 +58,7 @@ static void throw_out_of_memory() {
|
|||
{
|
||||
g_memory_out_of_memory = true;
|
||||
}
|
||||
|
||||
if (g_exit_when_out_of_memory) {
|
||||
std::cerr << g_out_of_memory_msg << "\n";
|
||||
exit(ERR_MEMOUT);
|
||||
|
@ -179,6 +181,22 @@ unsigned long long memory::get_max_used_memory() {
|
|||
return r;
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
unsigned long long memory::get_max_memory_size() {
|
||||
#if defined(_WINDOWS)
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof (statex);
|
||||
GlobalMemoryStatusEx (&statex);
|
||||
return statex.ullTotalPhys;
|
||||
#else
|
||||
// 16 GB
|
||||
return 1ull << 34ull;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long long memory::get_allocation_count() {
|
||||
return g_memory_alloc_count;
|
||||
}
|
||||
|
@ -282,6 +300,7 @@ void * memory::allocate(size_t s) {
|
|||
if (g_memory_thread_alloc_size > SYNCH_THRESHOLD) {
|
||||
synchronize_counters(true);
|
||||
}
|
||||
|
||||
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field
|
||||
}
|
||||
|
||||
|
@ -342,7 +361,7 @@ void * memory::allocate(size_t s) {
|
|||
if (counts_exceeded)
|
||||
throw_alloc_counts_exceeded();
|
||||
void * r = malloc(s);
|
||||
if (r == 0)
|
||||
if (r == nullptr)
|
||||
throw_out_of_memory();
|
||||
*(static_cast<size_t*>(r)) = s;
|
||||
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field
|
||||
|
@ -370,7 +389,7 @@ void* memory::reallocate(void *p, size_t s) {
|
|||
if (counts_exceeded)
|
||||
throw_alloc_counts_exceeded();
|
||||
void *r = realloc(real_p, s);
|
||||
if (r == 0)
|
||||
if (r == nullptr)
|
||||
throw_out_of_memory();
|
||||
*(static_cast<size_t*>(r)) = s;
|
||||
return static_cast<size_t*>(r) + 1; // we return a pointer to the location after the extra field
|
||||
|
|
|
@ -67,6 +67,7 @@ public:
|
|||
static unsigned long long get_allocation_size();
|
||||
static unsigned long long get_max_used_memory();
|
||||
static unsigned long long get_allocation_count();
|
||||
static unsigned long long get_max_memory_size();
|
||||
// temporary hack to avoid out-of-memory crash in z3.exe
|
||||
static void exit_when_out_of_memory(bool flag, char const * msg);
|
||||
};
|
||||
|
@ -90,7 +91,7 @@ void deallocf(char const* file, int line, T * ptr) {
|
|||
|
||||
template<typename T>
|
||||
void dealloc(T * ptr) {
|
||||
if (ptr == 0) return;
|
||||
if (ptr == nullptr) return;
|
||||
ptr->~T();
|
||||
memory::deallocate(ptr);
|
||||
}
|
||||
|
@ -111,7 +112,7 @@ T * alloc_vect(unsigned sz) {
|
|||
|
||||
template<typename T>
|
||||
void dealloc_vect(T * ptr, unsigned sz) {
|
||||
if (ptr == 0) return;
|
||||
if (ptr == nullptr) return;
|
||||
T * curr = ptr;
|
||||
for (unsigned i = 0; i < sz; i++, curr++)
|
||||
curr->~T();
|
||||
|
@ -122,7 +123,7 @@ void dealloc_vect(T * ptr, unsigned sz) {
|
|||
|
||||
template<typename T>
|
||||
void dealloc_svect(T * ptr) {
|
||||
if (ptr == 0) return;
|
||||
if (ptr == nullptr) return;
|
||||
memory::deallocate(ptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ void mpbq_manager::mul(mpbq const & a, mpz const & b, mpbq & r) {
|
|||
}
|
||||
|
||||
void mpbq_manager::power(mpbq & a, unsigned k) {
|
||||
SASSERT(static_cast<uint64>(k) * static_cast<uint64>(a.k()) <= static_cast<uint64>(UINT_MAX));
|
||||
SASSERT(static_cast<uint64_t>(k) * static_cast<uint64_t>(a.k()) <= static_cast<uint64_t>(UINT_MAX));
|
||||
// We don't need to normalize because:
|
||||
// If a.m_k == 0, then a is an integer, and the result be an integer
|
||||
// If a.m_k > 0, then a.m_num must be odd, and the (a.m_num)^k will also be odd
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
void set(mpbq & a, mpz const & n, unsigned k) { m_manager.set(a.m_num, n); a.m_k = k; normalize(a); }
|
||||
void set(mpbq & a, mpz const & n) { m_manager.set(a.m_num, n); a.m_k = 0; }
|
||||
void set(mpbq & a, mpbq const & b) { m_manager.set(a.m_num, b.m_num); a.m_k = b.m_k; }
|
||||
void set(mpbq & a, int64 n, unsigned k) { m_manager.set(a.m_num, n); a.m_k = k; normalize(a); }
|
||||
void set(mpbq & a, int64_t n, unsigned k) { m_manager.set(a.m_num, n); a.m_k = k; normalize(a); }
|
||||
|
||||
bool is_int(mpbq const & a) const { return a.m_k == 0; }
|
||||
void get_numerator(mpbq const & a, mpz & n) { m_manager.set(n, a.m_num); }
|
||||
|
|
|
@ -115,11 +115,11 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, double value) {
|
|||
// double === mpf(11, 53)
|
||||
static_assert(sizeof(double) == 8, "doubles are 8 bytes");
|
||||
|
||||
uint64 raw;
|
||||
uint64_t raw;
|
||||
memcpy(&raw, &value, sizeof(double));
|
||||
bool sign = (raw >> 63) != 0;
|
||||
int64 e = ((raw & 0x7FF0000000000000ull) >> 52) - 1023;
|
||||
uint64 s = raw & 0x000FFFFFFFFFFFFFull;
|
||||
int64_t e = ((raw & 0x7FF0000000000000ull) >> 52) - 1023;
|
||||
uint64_t s = raw & 0x000FFFFFFFFFFFFFull;
|
||||
|
||||
TRACE("mpf_dbg", tout << "set: " << value << " is: raw=" << raw << " (double)" <<
|
||||
" sign=" << sign << " s=" << s << " e=" << e << std::endl;);
|
||||
|
@ -300,7 +300,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
|
|||
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 significand) {
|
||||
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64_t significand) {
|
||||
// Assumption: this represents (sign * -1) * (significand/2^sbits) * 2^exponent.
|
||||
o.ebits = ebits;
|
||||
o.sbits = sbits;
|
||||
|
@ -1194,7 +1194,7 @@ void mpf_manager::to_sbv_mpq(mpf_rounding_mode rm, const mpf & x, scoped_mpq & o
|
|||
m_mpz_manager.set(z, t.significand());
|
||||
mpf_exp_t e = (mpf_exp_t)t.exponent() - t.sbits() + 1;
|
||||
if (e < 0) {
|
||||
bool last = false, round = false, sticky = m_mpz_manager.is_odd(z);
|
||||
bool last = m_mpz_manager.is_odd(z), round = false, sticky = false;
|
||||
for (; e != 0; e++) {
|
||||
m_mpz_manager.machine_div2k(z, 1);
|
||||
sticky |= round;
|
||||
|
@ -1204,7 +1204,7 @@ void mpf_manager::to_sbv_mpq(mpf_rounding_mode rm, const mpf & x, scoped_mpq & o
|
|||
bool inc = false;
|
||||
switch (rm) {
|
||||
case MPF_ROUND_NEAREST_TEVEN: inc = round && (last || sticky); break;
|
||||
case MPF_ROUND_NEAREST_TAWAY: inc = round && (!last || sticky); break; // CMW: Check!
|
||||
case MPF_ROUND_NEAREST_TAWAY: inc = round; break;
|
||||
case MPF_ROUND_TOWARD_POSITIVE: inc = (!x.sign && (round || sticky)); break;
|
||||
case MPF_ROUND_TOWARD_NEGATIVE: inc = (x.sign && (round || sticky)); break;
|
||||
case MPF_ROUND_TOWARD_ZERO: inc = false; break;
|
||||
|
@ -1711,8 +1711,8 @@ void mpf_manager::to_rational(mpf const & x, unsynch_mpq_manager & qm, mpq & o)
|
|||
|
||||
double mpf_manager::to_double(mpf const & x) {
|
||||
SASSERT(x.ebits <= 11 && x.sbits <= 53);
|
||||
uint64 raw = 0;
|
||||
int64 sig = 0, exp = 0;
|
||||
uint64_t raw = 0;
|
||||
int64_t sig = 0, exp = 0;
|
||||
|
||||
sig = m_mpz_manager.get_uint64(x.significand);
|
||||
sig <<= 53 - x.sbits;
|
||||
|
@ -1741,7 +1741,7 @@ float mpf_manager::to_float(mpf const & x) {
|
|||
unsigned int raw = 0;
|
||||
unsigned int sig = 0, exp = 0;
|
||||
|
||||
uint64 q = m_mpz_manager.get_uint64(x.significand);
|
||||
uint64_t q = m_mpz_manager.get_uint64(x.significand);
|
||||
SASSERT(q < 4294967296ull);
|
||||
sig = q & 0x00000000FFFFFFFF;
|
||||
sig <<= 24 - x.sbits;
|
||||
|
@ -1751,7 +1751,7 @@ float mpf_manager::to_float(mpf const & x) {
|
|||
else if (has_bot_exp(x))
|
||||
exp = -127;
|
||||
else {
|
||||
int64 q = x.exponent;
|
||||
int64_t q = x.exponent;
|
||||
SASSERT(q < 4294967296ll);
|
||||
exp = q & 0x00000000FFFFFFFF;
|
||||
}
|
||||
|
@ -2045,7 +2045,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) {
|
|||
bool inc = false;
|
||||
switch (rm) {
|
||||
case MPF_ROUND_NEAREST_TEVEN: inc = round && (last || sticky); break;
|
||||
case MPF_ROUND_NEAREST_TAWAY: inc = round && (!last || sticky); break;
|
||||
case MPF_ROUND_NEAREST_TAWAY: inc = round; break;
|
||||
case MPF_ROUND_TOWARD_POSITIVE: inc = (!o.sign && (round || sticky)); break;
|
||||
case MPF_ROUND_TOWARD_NEGATIVE: inc = (o.sign && (round || sticky)); break;
|
||||
case MPF_ROUND_TOWARD_ZERO: inc = false; break;
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef enum {
|
|||
MPF_ROUND_TOWARD_ZERO
|
||||
} mpf_rounding_mode;
|
||||
|
||||
typedef int64 mpf_exp_t;
|
||||
typedef int64_t mpf_exp_t;
|
||||
|
||||
class mpf {
|
||||
friend class mpf_manager;
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpq const & value);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, char const * value);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpz const & exponent, mpq const & significand);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64 significand);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, uint64_t significand);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, bool sign, mpf_exp_t exponent, mpz const & significand);
|
||||
void set(mpf & o, mpf const & x);
|
||||
void set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode rm, mpf const & x);
|
||||
|
@ -190,8 +190,8 @@ public:
|
|||
void mk_pinf(unsigned ebits, unsigned sbits, mpf & o);
|
||||
void mk_ninf(unsigned ebits, unsigned sbits, mpf & o);
|
||||
|
||||
unsynch_mpz_manager & mpz_manager(void) { return m_mpz_manager; }
|
||||
unsynch_mpq_manager & mpq_manager(void) { return m_mpq_manager; }
|
||||
unsynch_mpz_manager & mpz_manager() { return m_mpz_manager; }
|
||||
unsynch_mpq_manager & mpq_manager() { return m_mpq_manager; }
|
||||
|
||||
unsigned hash(mpf const & a) {
|
||||
return hash_u_u(m_mpz_manager.hash(a.significand),
|
||||
|
|
|
@ -155,27 +155,27 @@ bool mpff_manager::is_uint64(mpff const & n) const {
|
|||
!has_one_at_first_k_bits(m_precision, sig(n), -n.m_exponent);
|
||||
}
|
||||
|
||||
uint64 mpff_manager::get_uint64(mpff const & a) const {
|
||||
uint64_t mpff_manager::get_uint64(mpff const & a) const {
|
||||
SASSERT(is_uint64(a));
|
||||
if (is_zero(a)) return 0;
|
||||
int exp = -a.m_exponent - sizeof(unsigned) * 8 * (m_precision - 2);
|
||||
SASSERT(exp >= 0);
|
||||
uint64 * s = reinterpret_cast<uint64*>(sig(a) + (m_precision - 2));
|
||||
uint64_t * s = reinterpret_cast<uint64_t*>(sig(a) + (m_precision - 2));
|
||||
return *s >> exp;
|
||||
}
|
||||
|
||||
int64 mpff_manager::get_int64(mpff const & a) const {
|
||||
int64_t mpff_manager::get_int64(mpff const & a) const {
|
||||
SASSERT(is_int64(a));
|
||||
if (is_zero(a)) return 0;
|
||||
int exp = -a.m_exponent - sizeof(unsigned) * 8 * (m_precision - 2);
|
||||
SASSERT(exp >= 0);
|
||||
uint64 * s = reinterpret_cast<uint64*>(sig(a) + (m_precision - 2));
|
||||
uint64_t * s = reinterpret_cast<uint64_t*>(sig(a) + (m_precision - 2));
|
||||
// INT64_MIN case
|
||||
if (exp == 0 && *s == 0x8000000000000000ull && is_neg(a)) {
|
||||
return INT64_MIN;
|
||||
}
|
||||
else {
|
||||
int64 r = *s >> exp;
|
||||
int64_t r = *s >> exp;
|
||||
if (is_neg(a))
|
||||
r = -r;
|
||||
return r;
|
||||
|
@ -249,26 +249,26 @@ void mpff_manager::set(mpff & n, unsigned v) {
|
|||
SASSERT(check(n));
|
||||
}
|
||||
|
||||
void mpff_manager::set(mpff & n, int64 v) {
|
||||
void mpff_manager::set(mpff & n, int64_t v) {
|
||||
if (v == 0) {
|
||||
reset(n);
|
||||
}
|
||||
else {
|
||||
if (v < 0) {
|
||||
set(n, 1 + static_cast<uint64>(-(1+v)));
|
||||
set(n, 1 + static_cast<uint64_t>(-(1+v)));
|
||||
n.m_sign = 1;
|
||||
}
|
||||
else {
|
||||
set(n, static_cast<uint64>(v));
|
||||
set(n, static_cast<uint64_t>(v));
|
||||
}
|
||||
}
|
||||
SASSERT(check(n));
|
||||
SASSERT(get_int64(n) == v);
|
||||
}
|
||||
|
||||
void mpff_manager::set(mpff & n, uint64 v) {
|
||||
void mpff_manager::set(mpff & n, uint64_t v) {
|
||||
#ifdef Z3DEBUG
|
||||
uint64 old_v = v;
|
||||
uint64_t old_v = v;
|
||||
#endif
|
||||
if (v == 0) {
|
||||
reset(n);
|
||||
|
@ -278,7 +278,7 @@ void mpff_manager::set(mpff & n, uint64 v) {
|
|||
n.m_sign = 0;
|
||||
unsigned * _v = reinterpret_cast<unsigned*>(&v);
|
||||
int num_leading_zeros = nlz(2, _v);
|
||||
n.m_exponent = static_cast<int>(8 * sizeof(uint64)) - num_leading_zeros - static_cast<int>(m_precision_bits);
|
||||
n.m_exponent = static_cast<int>(8 * sizeof(uint64_t)) - num_leading_zeros - static_cast<int>(m_precision_bits);
|
||||
v <<= num_leading_zeros;
|
||||
SASSERT(m_precision >= 2);
|
||||
unsigned * s = sig(n);
|
||||
|
@ -299,7 +299,7 @@ void mpff_manager::set(mpff & n, int num, unsigned den) {
|
|||
SASSERT(check(n));
|
||||
}
|
||||
|
||||
void mpff_manager::set(mpff & n, int64 num, uint64 den) {
|
||||
void mpff_manager::set(mpff & n, int64_t num, uint64_t den) {
|
||||
scoped_mpff a(*this), b(*this);
|
||||
set(a, num);
|
||||
set(b, den);
|
||||
|
@ -470,7 +470,7 @@ bool mpff_manager::lt(mpff const & a, mpff const & b) const {
|
|||
}
|
||||
}
|
||||
|
||||
void mpff_manager::inc_significand(unsigned * s, int64 & exp) {
|
||||
void mpff_manager::inc_significand(unsigned * s, int64_t & exp) {
|
||||
if (!::inc(m_precision, s)) {
|
||||
SASSERT(::is_zero(m_precision, s));
|
||||
s[m_precision - 1] = MIN_MSW;
|
||||
|
@ -597,7 +597,7 @@ void mpff_manager::prev(mpff & a) {
|
|||
SASSERT(check(a));
|
||||
}
|
||||
|
||||
void mpff_manager::set_big_exponent(mpff & a, int64 e) {
|
||||
void mpff_manager::set_big_exponent(mpff & a, int64_t e) {
|
||||
SASSERT(e > INT_MAX || e < INT_MIN);
|
||||
if (e > INT_MAX) {
|
||||
if (a.m_sign == 1) {
|
||||
|
@ -715,7 +715,7 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c
|
|||
else if (num_leading_zeros == sizeof(unsigned) * 8 - 1) {
|
||||
// shift 1 right
|
||||
bool _inc_significand = ((c.m_sign == 1) != m_to_plus_inf) && has_one_at_first_k_bits(m_precision*2, sig_r, 1);
|
||||
int64 exp_c = exp_a;
|
||||
int64_t exp_c = exp_a;
|
||||
exp_c++;
|
||||
shr(m_precision + 1, sig_r, 1, m_precision, sig_c);
|
||||
if (_inc_significand)
|
||||
|
@ -728,7 +728,7 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c
|
|||
// Now, we can assume sig_r has size m_precision
|
||||
SASSERT(num_leading_zeros > 0);
|
||||
// shift left num_leading_zeros
|
||||
int64 exp_c = exp_a;
|
||||
int64_t exp_c = exp_a;
|
||||
exp_c -= num_leading_zeros;
|
||||
shl(m_precision, sig_r, num_leading_zeros, m_precision, sig_c);
|
||||
set_exponent(c, exp_c);
|
||||
|
@ -752,7 +752,7 @@ void mpff_manager::add_sub(bool is_sub, mpff const & a, mpff const & b, mpff & c
|
|||
reset(c);
|
||||
}
|
||||
else if (num_leading_zeros > 0) {
|
||||
int64 exp_c = exp_a;
|
||||
int64_t exp_c = exp_a;
|
||||
exp_c -= num_leading_zeros;
|
||||
shl(m_precision, sig_c, num_leading_zeros, m_precision, sig_c);
|
||||
set_exponent(c, exp_c);
|
||||
|
@ -787,10 +787,10 @@ void mpff_manager::mul(mpff const & a, mpff const & b, mpff & c) {
|
|||
allocate_if_needed(c);
|
||||
TRACE("mpff", tout << "mul("; display(tout, a); tout << ", "; display(tout, b); tout << ")\n";);
|
||||
c.m_sign = a.m_sign ^ b.m_sign;
|
||||
// use int64 to make sure we do not have overflows
|
||||
int64 exp_a = a.m_exponent;
|
||||
int64 exp_b = b.m_exponent;
|
||||
int64 exp_c = exp_a + exp_b;
|
||||
// use int64_t to make sure we do not have overflows
|
||||
int64_t exp_a = a.m_exponent;
|
||||
int64_t exp_b = b.m_exponent;
|
||||
int64_t exp_c = exp_a + exp_b;
|
||||
// store result in m_buffers[0]
|
||||
unsigned * r = m_buffers[0].c_ptr();
|
||||
m_mpn_manager.mul(sig(a), m_precision, sig(b), m_precision, r);
|
||||
|
@ -834,7 +834,7 @@ void mpff_manager::div(mpff const & a, mpff const & b, mpff & c) {
|
|||
#if 1
|
||||
else if (is_two(b)) {
|
||||
set(c, a);
|
||||
int64 exp_c = a.m_exponent;
|
||||
int64_t exp_c = a.m_exponent;
|
||||
exp_c--;
|
||||
set_exponent(c, exp_c);
|
||||
}
|
||||
|
@ -842,10 +842,10 @@ void mpff_manager::div(mpff const & a, mpff const & b, mpff & c) {
|
|||
else {
|
||||
allocate_if_needed(c);
|
||||
c.m_sign = a.m_sign ^ b.m_sign;
|
||||
// use int64 to make sure we do not have overflows
|
||||
int64 exp_a = a.m_exponent;
|
||||
int64 exp_b = b.m_exponent;
|
||||
int64 exp_c = exp_a - exp_b;
|
||||
// use int64_t to make sure we do not have overflows
|
||||
int64_t exp_a = a.m_exponent;
|
||||
int64_t exp_b = b.m_exponent;
|
||||
int64_t exp_c = exp_a - exp_b;
|
||||
|
||||
exp_c -= m_precision_bits; // we will multiplying (shifting) a by 2^m_precision_bits.
|
||||
// copy a to buffer 0, and shift by m_precision_bits
|
||||
|
@ -1023,7 +1023,7 @@ void mpff_manager::power(mpff const & a, unsigned p, mpff & b) {
|
|||
b.m_sign = 0;
|
||||
else
|
||||
b.m_sign = a.m_sign;
|
||||
int64 exp = a.m_exponent;
|
||||
int64_t exp = a.m_exponent;
|
||||
exp *= p;
|
||||
if (exp > INT_MAX || exp < INT_MIN)
|
||||
throw overflow_exception();
|
||||
|
@ -1057,7 +1057,7 @@ void mpff_manager::power(mpff const & a, unsigned p, mpff & b) {
|
|||
bool mpff_manager::is_power_of_two(mpff const & a, unsigned & k) const {
|
||||
if (!is_power_of_two(a))
|
||||
return false;
|
||||
int64 exp = a.m_exponent + m_precision_bits - 1;
|
||||
int64_t exp = a.m_exponent + m_precision_bits - 1;
|
||||
SASSERT(exp >= 0);
|
||||
k = static_cast<unsigned>(exp);
|
||||
return true;
|
||||
|
@ -1132,7 +1132,7 @@ void mpff_manager::to_mpq_core(mpff const & n, mpq_manager<SYNCH> & m, mpq & t)
|
|||
if (exp < 0) {
|
||||
// Avoid -INT_MIN == INT_MIN issue. It is not really useful, since we will run out of memory anyway.
|
||||
if (exp == INT_MIN)
|
||||
abs_exp = static_cast<unsigned>(-static_cast<int64>(INT_MIN));
|
||||
abs_exp = static_cast<unsigned>(-static_cast<int64_t>(INT_MIN));
|
||||
else
|
||||
abs_exp = -exp;
|
||||
}
|
||||
|
@ -1177,7 +1177,7 @@ void mpff_manager::display(std::ostream & out, mpff const & n) const {
|
|||
svector<unsigned> & u_buffer = const_cast<mpff_manager*>(this)->m_buffers[0];
|
||||
int num_trailing_zeros = ntz(m_precision, u_buffer.c_ptr());
|
||||
int shift = 0;
|
||||
int64 exp = n.m_exponent; // use int64 to avoid -INT_MIN == INT_MIN issue
|
||||
int64_t exp = n.m_exponent; // use int64_t to avoid -INT_MIN == INT_MIN issue
|
||||
if (exp < 0) {
|
||||
if (num_trailing_zeros >= -exp) {
|
||||
shift = static_cast<int>(-exp);
|
||||
|
@ -1194,7 +1194,7 @@ void mpff_manager::display(std::ostream & out, mpff const & n) const {
|
|||
out << m_mpn_manager.to_string(u_buffer.c_ptr(), m_precision, str_buffer.begin(), str_buffer.size());
|
||||
if (exp > 0) {
|
||||
if (exp <= 63) {
|
||||
uint64 _exp = 1;
|
||||
uint64_t _exp = 1;
|
||||
_exp <<= exp;
|
||||
out << "*" << _exp;
|
||||
}
|
||||
|
@ -1209,7 +1209,7 @@ void mpff_manager::display(std::ostream & out, mpff const & n) const {
|
|||
else if (exp < 0) {
|
||||
exp = -exp;
|
||||
if (exp <= 63) {
|
||||
uint64 _exp = 1;
|
||||
uint64_t _exp = 1;
|
||||
_exp <<= exp;
|
||||
out << "/" << _exp;
|
||||
}
|
||||
|
@ -1225,8 +1225,8 @@ void mpff_manager::display(std::ostream & out, mpff const & n) const {
|
|||
|
||||
void mpff_manager::display_decimal(std::ostream & out, mpff const & n, unsigned prec, unsigned min_exponent) {
|
||||
// The result in scientific notation when n.m_exponent >= min_exponent or n.m_exponent <= - min_exponent - m_precision_bits
|
||||
int64 exp = n.m_exponent;
|
||||
if (exp >= min_exponent || exp <= -static_cast<int64>(min_exponent) - m_precision_bits || is_int(n)) {
|
||||
int64_t exp = n.m_exponent;
|
||||
if (exp >= min_exponent || exp <= -static_cast<int64_t>(min_exponent) - m_precision_bits || is_int(n)) {
|
||||
display(out, n);
|
||||
return;
|
||||
}
|
||||
|
@ -1327,7 +1327,7 @@ void mpff_manager::display_smt2(std::ostream & out, mpff const & n, bool decimal
|
|||
svector<unsigned> & u_buffer = const_cast<mpff_manager*>(this)->m_buffers[0];
|
||||
int num_trailing_zeros = ntz(m_precision, u_buffer.c_ptr());
|
||||
int shift = 0;
|
||||
int64 exp = n.m_exponent;
|
||||
int64_t exp = n.m_exponent;
|
||||
if (exp < 0) {
|
||||
if (num_trailing_zeros >= -exp) {
|
||||
shift = static_cast<int>(-exp);
|
||||
|
@ -1353,7 +1353,7 @@ void mpff_manager::display_smt2(std::ostream & out, mpff const & n, bool decimal
|
|||
if (exp != 0) {
|
||||
if (exp < 0) exp = -exp;
|
||||
if (exp <= 63) {
|
||||
uint64 _exp = 1;
|
||||
uint64_t _exp = 1;
|
||||
_exp <<= exp;
|
||||
out << _exp;
|
||||
if (decimal) out << ".0";
|
||||
|
@ -1387,8 +1387,8 @@ unsigned mpff_manager::prev_power_of_two(mpff const & a) {
|
|||
return 0;
|
||||
if (a.m_exponent <= -static_cast<int>(m_precision_bits))
|
||||
return 0; // Number is smaller than 1
|
||||
SASSERT(static_cast<int64>(a.m_exponent) + static_cast<int64>(m_precision_bits) - 1 >= 0);
|
||||
SASSERT(static_cast<int64>(a.m_exponent) + static_cast<int64>(m_precision_bits) - 1 <= static_cast<int64>(static_cast<uint64>(UINT_MAX)));
|
||||
SASSERT(static_cast<int64_t>(a.m_exponent) + static_cast<int64_t>(m_precision_bits) - 1 >= 0);
|
||||
SASSERT(static_cast<int64_t>(a.m_exponent) + static_cast<int64_t>(m_precision_bits) - 1 <= static_cast<int64_t>(static_cast<uint64_t>(UINT_MAX)));
|
||||
return m_precision_bits + a.m_exponent - 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class mpff_manager {
|
|||
//
|
||||
// Remarks:
|
||||
//
|
||||
// - All values of type int, unsigned, int64 and uint64 can be precisely represented as mpff numerals.
|
||||
// - All values of type int, unsigned, int64_t and uint64_t can be precisely represented as mpff numerals.
|
||||
//
|
||||
// - Hardware float and double values (corresponding to rationals) can also be precisely represented as mpff numerals.
|
||||
// That is, NaN, +oo and -oo are not supported by this module.
|
||||
|
@ -141,14 +141,14 @@ class mpff_manager {
|
|||
// copy (and shift by m_precision_bits) n to buffer idx
|
||||
void to_buffer_shifting(unsigned idx, mpff const & n) const;
|
||||
|
||||
void inc_significand(unsigned * s, int64 & exp);
|
||||
void inc_significand(unsigned * s, int64_t & exp);
|
||||
void inc_significand(mpff & a);
|
||||
void dec_significand(mpff & a);
|
||||
bool min_significand(mpff const & a) const;
|
||||
void set_min_significand(mpff & a);
|
||||
void set_max_significand(mpff & a);
|
||||
void set_big_exponent(mpff & a, int64 e);
|
||||
void set_exponent(mpff & a, int64 e) {
|
||||
void set_big_exponent(mpff & a, int64_t e);
|
||||
void set_exponent(mpff & a, int64_t e) {
|
||||
if (e > INT_MAX || e < INT_MIN)
|
||||
set_big_exponent(a, e);
|
||||
else
|
||||
|
@ -178,15 +178,15 @@ public:
|
|||
static bool field() { return true; }
|
||||
|
||||
class exception : public z3_exception {
|
||||
virtual char const * msg() const { return "multi-precision floating point (mpff) exception"; }
|
||||
char const * msg() const override { return "multi-precision floating point (mpff) exception"; }
|
||||
};
|
||||
|
||||
class overflow_exception : public exception {
|
||||
virtual char const * msg() const { return "multi-precision floating point (mpff) overflow"; }
|
||||
char const * msg() const override { return "multi-precision floating point (mpff) overflow"; }
|
||||
};
|
||||
|
||||
class div0_exception : public exception {
|
||||
virtual char const * msg() const { return "multi-precision floating point (mpff) division by zero"; }
|
||||
char const * msg() const override { return "multi-precision floating point (mpff) division by zero"; }
|
||||
};
|
||||
|
||||
mpff_manager(unsigned prec = 2, unsigned initial_capacity = 1024);
|
||||
|
@ -286,12 +286,12 @@ public:
|
|||
bool is_plus_epsilon(mpff const & a) const;
|
||||
|
||||
/**
|
||||
\brief Return true if \c a is an integer and fits in an int64 machine integer.
|
||||
\brief Return true if \c a is an integer and fits in an int64_t machine integer.
|
||||
*/
|
||||
bool is_int64(mpff const & a) const;
|
||||
|
||||
/**
|
||||
\brief Return true if \c a is a non-negative integer and fits in an int64 machine integer.
|
||||
\brief Return true if \c a is a non-negative integer and fits in an int64_t machine integer.
|
||||
*/
|
||||
bool is_uint64(mpff const & a) const;
|
||||
|
||||
|
@ -372,10 +372,10 @@ public:
|
|||
|
||||
void set(mpff & n, int v);
|
||||
void set(mpff & n, unsigned v);
|
||||
void set(mpff & n, int64 v);
|
||||
void set(mpff & n, uint64 v);
|
||||
void set(mpff & n, int64_t v);
|
||||
void set(mpff & n, uint64_t v);
|
||||
void set(mpff & n, int num, unsigned den);
|
||||
void set(mpff & n, int64 num, uint64 den);
|
||||
void set(mpff & n, int64_t num, uint64_t den);
|
||||
void set(mpff & n, mpff const & v);
|
||||
void set(mpff & n, unsynch_mpz_manager & m, mpz const & v);
|
||||
void set(mpff & n, synch_mpz_manager & m, mpz const & v);
|
||||
|
@ -448,14 +448,14 @@ public:
|
|||
|
||||
\pre is_int64(n)
|
||||
*/
|
||||
int64 get_int64(mpff const & n) const;
|
||||
int64_t get_int64(mpff const & n) const;
|
||||
|
||||
/**
|
||||
\brief Return n as an uint64.
|
||||
|
||||
\pre is_uint64(n)
|
||||
*/
|
||||
uint64 get_uint64(mpff const & n) const;
|
||||
uint64_t get_uint64(mpff const & n) const;
|
||||
|
||||
/**
|
||||
\brief Return the biggest k s.t. 2^k <= a.
|
||||
|
|
|
@ -164,10 +164,10 @@ void mpfx_manager::set(mpfx & n, unsigned v) {
|
|||
SASSERT(check(n));
|
||||
}
|
||||
|
||||
void mpfx_manager::set(mpfx & n, int64 v) {
|
||||
void mpfx_manager::set(mpfx & n, int64_t v) {
|
||||
if (m_int_part_sz == 1) {
|
||||
if (v < -static_cast<int64>(static_cast<uint64>(UINT_MAX)) ||
|
||||
v > static_cast<int64>(static_cast<uint64>(UINT_MAX)))
|
||||
if (v < -static_cast<int64_t>(static_cast<uint64_t>(UINT_MAX)) ||
|
||||
v > static_cast<int64_t>(static_cast<uint64_t>(UINT_MAX)))
|
||||
throw overflow_exception();
|
||||
}
|
||||
if (v == 0) {
|
||||
|
@ -175,11 +175,11 @@ void mpfx_manager::set(mpfx & n, int64 v) {
|
|||
}
|
||||
else {
|
||||
if (v < 0) {
|
||||
set(n, static_cast<uint64>(-v));
|
||||
set(n, static_cast<uint64_t>(-v));
|
||||
n.m_sign = 1;
|
||||
}
|
||||
else {
|
||||
set(n, static_cast<uint64>(v));
|
||||
set(n, static_cast<uint64_t>(v));
|
||||
}
|
||||
}
|
||||
SASSERT(is_int(n));
|
||||
|
@ -187,9 +187,9 @@ void mpfx_manager::set(mpfx & n, int64 v) {
|
|||
SASSERT(check(n));
|
||||
}
|
||||
|
||||
void mpfx_manager::set(mpfx & n, uint64 v) {
|
||||
void mpfx_manager::set(mpfx & n, uint64_t v) {
|
||||
if (m_int_part_sz == 1) {
|
||||
if (v > static_cast<uint64>(UINT_MAX))
|
||||
if (v > static_cast<uint64_t>(UINT_MAX))
|
||||
throw overflow_exception();
|
||||
}
|
||||
|
||||
|
@ -200,8 +200,8 @@ void mpfx_manager::set(mpfx & n, uint64 v) {
|
|||
allocate_if_needed(n);
|
||||
n.m_sign = 0;
|
||||
unsigned * w = words(n);
|
||||
uint64 * _vp = &v;
|
||||
unsigned * _v = 0;
|
||||
uint64_t * _vp = &v;
|
||||
unsigned * _v = nullptr;
|
||||
memcpy(&_v, &_vp, sizeof(unsigned*));
|
||||
for (unsigned i = 0; i < m_total_sz; i++)
|
||||
w[i] = 0;
|
||||
|
@ -226,7 +226,7 @@ void mpfx_manager::set(mpfx & n, int num, unsigned den) {
|
|||
SASSERT(check(n));
|
||||
}
|
||||
|
||||
void mpfx_manager::set(mpfx & n, int64 num, uint64 den) {
|
||||
void mpfx_manager::set(mpfx & n, int64_t num, uint64_t den) {
|
||||
scoped_mpfx a(*this), b(*this);
|
||||
set(a, num);
|
||||
set(b, den);
|
||||
|
@ -677,27 +677,27 @@ bool mpfx_manager::is_power_of_two(mpfx const & a) const {
|
|||
return is_power_of_two(a, k);
|
||||
}
|
||||
|
||||
int64 mpfx_manager::get_int64(mpfx const & n) const {
|
||||
int64_t mpfx_manager::get_int64(mpfx const & n) const {
|
||||
SASSERT(is_int64(n));
|
||||
unsigned * w = words(n);
|
||||
w += m_frac_part_sz;
|
||||
uint64 r = 0;
|
||||
memcpy(&r, w, sizeof(uint64));
|
||||
uint64_t r = 0;
|
||||
memcpy(&r, w, sizeof(uint64_t));
|
||||
if (r == 0x8000000000000000ull) {
|
||||
SASSERT(is_neg(n));
|
||||
return INT64_MIN;
|
||||
}
|
||||
else {
|
||||
return is_neg(n) ? -static_cast<int64>(r) : r;
|
||||
return is_neg(n) ? -static_cast<int64_t>(r) : r;
|
||||
}
|
||||
}
|
||||
|
||||
uint64 mpfx_manager::get_uint64(mpfx const & n) const {
|
||||
uint64_t mpfx_manager::get_uint64(mpfx const & n) const {
|
||||
SASSERT(is_uint64(n));
|
||||
unsigned * w = words(n);
|
||||
w += m_frac_part_sz;
|
||||
uint64 r = 0;
|
||||
memcpy(&r, w, sizeof(uint64));
|
||||
uint64_t r = 0;
|
||||
memcpy(&r, w, sizeof(uint64_t));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -125,15 +125,15 @@ public:
|
|||
static bool field() { return true; }
|
||||
|
||||
class exception : public z3_exception {
|
||||
virtual char const * msg() const { return "multi-precision fixed point (mpfx) exception"; }
|
||||
char const * msg() const override { return "multi-precision fixed point (mpfx) exception"; }
|
||||
};
|
||||
|
||||
class overflow_exception : public exception {
|
||||
virtual char const * msg() const { return "multi-precision fixed point (mpfx) overflow"; }
|
||||
char const * msg() const override { return "multi-precision fixed point (mpfx) overflow"; }
|
||||
};
|
||||
|
||||
class div0_exception : public exception {
|
||||
virtual char const * msg() const { return "multi-precision fixed point (mpfx) division by zero"; }
|
||||
char const * msg() const override { return "multi-precision fixed point (mpfx) division by zero"; }
|
||||
};
|
||||
|
||||
mpfx_manager(unsigned int_sz = 2, unsigned frac_sz = 1, unsigned initial_capacity = 1024);
|
||||
|
@ -200,12 +200,12 @@ public:
|
|||
bool is_minus_one(mpfx const & n) const { return is_neg(n) && is_abs_one(n); }
|
||||
|
||||
/**
|
||||
\brief Return true if \c a is an integer and fits in an int64 machine integer.
|
||||
\brief Return true if \c a is an integer and fits in an \c int64_t machine integer.
|
||||
*/
|
||||
bool is_int64(mpfx const & a) const;
|
||||
|
||||
/**
|
||||
\brief Return true if \c a is a non-negative integer and fits in an int64 machine integer.
|
||||
\brief Return true if \c a is a non-negative integer and fits in an \c int64_t machine integer.
|
||||
*/
|
||||
bool is_uint64(mpfx const & a) const;
|
||||
|
||||
|
@ -306,10 +306,10 @@ public:
|
|||
|
||||
void set(mpfx & n, int v);
|
||||
void set(mpfx & n, unsigned v);
|
||||
void set(mpfx & n, int64 v);
|
||||
void set(mpfx & n, uint64 v);
|
||||
void set(mpfx & n, int64_t v);
|
||||
void set(mpfx & n, uint64_t v);
|
||||
void set(mpfx & n, int num, unsigned den);
|
||||
void set(mpfx & n, int64 num, uint64 den);
|
||||
void set(mpfx & n, int64_t num, uint64_t den);
|
||||
void set(mpfx & n, mpfx const & v);
|
||||
void set(mpfx & n, unsynch_mpz_manager & m, mpz const & v);
|
||||
void set(mpfx & n, synch_mpz_manager & m, mpz const & v);
|
||||
|
@ -343,14 +343,14 @@ public:
|
|||
|
||||
\pre is_int64(n)
|
||||
*/
|
||||
int64 get_int64(mpfx const & n) const;
|
||||
int64_t get_int64(mpfx const & n) const;
|
||||
|
||||
/**
|
||||
\brief Return n as an uint64.
|
||||
|
||||
\pre is_uint64(n)
|
||||
*/
|
||||
uint64 get_uint64(mpfx const & n) const;
|
||||
uint64_t get_uint64(mpfx const & n) const;
|
||||
|
||||
/**
|
||||
\brief Convert n into a mpz numeral.
|
||||
|
|
|
@ -23,7 +23,7 @@ Revision History:
|
|||
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
typedef uint64 mpn_double_digit;
|
||||
typedef uint64_t mpn_double_digit;
|
||||
static_assert(sizeof(mpn_double_digit) == 2 * sizeof(mpn_digit), "size alignment");
|
||||
|
||||
const mpn_digit mpn_manager::zero = 0;
|
||||
|
|
|
@ -501,6 +501,8 @@ public:
|
|||
|
||||
void machine_div(mpz const & a, mpz const & b, mpz & c) { mpz_manager<SYNCH>::machine_div(a, b, c); }
|
||||
|
||||
void machine_div_rem(mpz const & a, mpz const & b, mpz & c, mpz& d) { mpz_manager<SYNCH>::machine_div_rem(a, b, c, d); }
|
||||
|
||||
void div(mpz const & a, mpz const & b, mpz & c) { mpz_manager<SYNCH>::div(a, b, c); }
|
||||
|
||||
void rat_div(mpz const & a, mpz const & b, mpq & c) {
|
||||
|
@ -515,6 +517,13 @@ public:
|
|||
reset_denominator(c);
|
||||
}
|
||||
|
||||
void machine_idiv_rem(mpq const & a, mpq const & b, mpq & c, mpq & d) {
|
||||
SASSERT(is_int(a) && is_int(b));
|
||||
machine_div_rem(a.m_num, b.m_num, c.m_num, d.m_num);
|
||||
reset_denominator(c);
|
||||
reset_denominator(d);
|
||||
}
|
||||
|
||||
void machine_idiv(mpq const & a, mpq const & b, mpz & c) {
|
||||
SASSERT(is_int(a) && is_int(b));
|
||||
machine_div(a.m_num, b.m_num, c);
|
||||
|
@ -686,7 +695,7 @@ public:
|
|||
normalize(a);
|
||||
}
|
||||
|
||||
void set(mpq & a, int64 n, uint64 d) {
|
||||
void set(mpq & a, int64_t n, uint64_t d) {
|
||||
SASSERT(d != 0);
|
||||
set(a.m_num, n);
|
||||
set(a.m_den, d);
|
||||
|
@ -718,16 +727,16 @@ public:
|
|||
|
||||
void set(mpq & a, char const * val);
|
||||
|
||||
void set(mpz & a, int64 val) { mpz_manager<SYNCH>::set(a, val); }
|
||||
void set(mpz & a, int64_t val) { mpz_manager<SYNCH>::set(a, val); }
|
||||
|
||||
void set(mpq & a, int64 val) {
|
||||
void set(mpq & a, int64_t val) {
|
||||
set(a.m_num, val);
|
||||
reset_denominator(a);
|
||||
}
|
||||
|
||||
void set(mpz & a, uint64 val) { mpz_manager<SYNCH>::set(a, val); }
|
||||
void set(mpz & a, uint64_t val) { mpz_manager<SYNCH>::set(a, val); }
|
||||
|
||||
void set(mpq & a, uint64 val) {
|
||||
void set(mpq & a, uint64_t val) {
|
||||
set(a.m_num, val);
|
||||
reset_denominator(a);
|
||||
}
|
||||
|
@ -765,17 +774,17 @@ public:
|
|||
|
||||
bool is_int64(mpz const & a) const { return mpz_manager<SYNCH>::is_int64(a); }
|
||||
|
||||
uint64 get_uint64(mpz const & a) const { return mpz_manager<SYNCH>::get_uint64(a); }
|
||||
uint64_t get_uint64(mpz const & a) const { return mpz_manager<SYNCH>::get_uint64(a); }
|
||||
|
||||
int64 get_int64(mpz const & a) const { return mpz_manager<SYNCH>::get_int64(a); }
|
||||
int64_t get_int64(mpz const & a) const { return mpz_manager<SYNCH>::get_int64(a); }
|
||||
|
||||
bool is_uint64(mpq const & a) const { return is_int(a) && is_uint64(a.m_num); }
|
||||
|
||||
bool is_int64(mpq const & a) const { return is_int(a) && is_int64(a.m_num); }
|
||||
|
||||
uint64 get_uint64(mpq const & a) const { SASSERT(is_uint64(a)); return get_uint64(a.m_num); }
|
||||
uint64_t get_uint64(mpq const & a) const { SASSERT(is_uint64(a)); return get_uint64(a.m_num); }
|
||||
|
||||
int64 get_int64(mpq const & a) const { SASSERT(is_int64(a)); return get_int64(a.m_num); }
|
||||
int64_t get_int64(mpq const & a) const { SASSERT(is_int64(a)); return get_int64(a.m_num); }
|
||||
|
||||
double get_double(mpz const & a) const { return mpz_manager<SYNCH>::get_double(a); }
|
||||
|
||||
|
|
204
src/util/mpz.cpp
204
src/util/mpz.cpp
|
@ -45,43 +45,93 @@ Revision History:
|
|||
#define LEHMER_GCD
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
static T gcd_core(T u, T v) {
|
||||
if (u == 0)
|
||||
return v;
|
||||
if (v == 0)
|
||||
return u;
|
||||
|
||||
int k;
|
||||
|
||||
for (k = 0; ((u | v) & 1) == 0; ++k) {
|
||||
u >>= 1;
|
||||
v >>= 1;
|
||||
}
|
||||
|
||||
while ((u & 1) == 0)
|
||||
u >>= 1;
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define _trailing_zeros32(X) __builtin_ctz(X)
|
||||
#else
|
||||
#define _trailing_zeros32(X) _tzcnt_u32(X)
|
||||
#endif
|
||||
|
||||
#if defined(_AMD64_)
|
||||
#if defined(__GNUC__)
|
||||
#define _trailing_zeros64(X) __builtin_ctzll(X)
|
||||
#else
|
||||
#define _trailing_zeros64(X) _tzcnt_u64(X)
|
||||
#endif
|
||||
#else
|
||||
inline uint64_t _trailing_zeros64(uint64_t x) {
|
||||
uint64_t r = 0;
|
||||
for (; 0 == (x & 1) && r < 64; ++r, x >>= 1);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define _bit_min(x, y) (y + ((x - y) & ((int)(x - y) >> 31)))
|
||||
#define _bit_max(x, y) (x - ((x - y) & ((int)(x - y) >> 31)))
|
||||
|
||||
|
||||
unsigned u_gcd(unsigned u, unsigned v) {
|
||||
if (u == 0) return v;
|
||||
if (v == 0) return u;
|
||||
unsigned shift = _trailing_zeros32(u | v);
|
||||
u >>= _trailing_zeros32(u);
|
||||
if (u == 1 || v == 1) return 1 << shift;
|
||||
if (u == v) return u << shift;
|
||||
do {
|
||||
while ((v & 1) == 0)
|
||||
v >>= 1;
|
||||
|
||||
if (u < v) {
|
||||
v -= u;
|
||||
}
|
||||
else {
|
||||
T diff = u - v;
|
||||
u = v;
|
||||
v = diff;
|
||||
}
|
||||
v >>= 1;
|
||||
} while (v != 0);
|
||||
|
||||
return u << k;
|
||||
v >>= _trailing_zeros32(v);
|
||||
#if 1
|
||||
unsigned diff = u - v;
|
||||
unsigned mdiff = diff & (unsigned)((int)diff >> 31);
|
||||
u = v + mdiff; // min
|
||||
v = diff - 2 * mdiff; // if v <= u: u - v, if v > u: v - u = u - v - 2 * (u - v)
|
||||
#endif
|
||||
#if 0
|
||||
unsigned t = _bit_max(u, v);
|
||||
u = _bit_min(u, v);
|
||||
v = t;
|
||||
v -= u;
|
||||
#endif
|
||||
#if 0
|
||||
unsigned t = std::max(u, v);
|
||||
u = std::min(u,v);
|
||||
v = t;
|
||||
v -= u;
|
||||
#endif
|
||||
#if 0
|
||||
if (u > v) std::swap(u, v);
|
||||
v -= u;
|
||||
#endif
|
||||
#if 0
|
||||
unsigned d1 = u - v;
|
||||
unsigned d2 = v - u;
|
||||
unsigned md21 = d2 & (unsigned)((int)d1 >> 31);
|
||||
unsigned md12 = d1 & (unsigned)((int)d2 >> 31);
|
||||
u = _bit_min(u, v);
|
||||
v = md12 | md21;
|
||||
#endif
|
||||
}
|
||||
while (v != 0);
|
||||
return u << shift;
|
||||
}
|
||||
|
||||
uint64_t u64_gcd(uint64_t u, uint64_t v) {
|
||||
if (u == 0) return v;
|
||||
if (v == 0) return u;
|
||||
if (u == 1 || v == 1) return 1;
|
||||
auto shift = _trailing_zeros64(u | v);
|
||||
u >>= _trailing_zeros64(u);
|
||||
do {
|
||||
v >>= _trailing_zeros64(v);
|
||||
if (u > v) std::swap(u, v);
|
||||
v -= u;
|
||||
}
|
||||
while (v != 0);
|
||||
return u << shift;
|
||||
}
|
||||
|
||||
unsigned u_gcd(unsigned u, unsigned v) { return gcd_core(u, v); }
|
||||
uint64 u64_gcd(uint64 u, uint64 v) { return gcd_core(u, v); }
|
||||
|
||||
template<bool SYNCH>
|
||||
mpz_manager<SYNCH>::mpz_manager():
|
||||
|
@ -89,7 +139,7 @@ mpz_manager<SYNCH>::mpz_manager():
|
|||
if (SYNCH)
|
||||
omp_init_nest_lock(&m_lock);
|
||||
#ifndef _MP_GMP
|
||||
if (sizeof(digit_t) == sizeof(uint64)) {
|
||||
if (sizeof(digit_t) == sizeof(uint64_t)) {
|
||||
// 64-bit machine
|
||||
m_init_cell_capacity = 4;
|
||||
}
|
||||
|
@ -101,7 +151,7 @@ mpz_manager<SYNCH>::mpz_manager():
|
|||
m_arg[i] = allocate(m_init_cell_capacity);
|
||||
m_arg[i]->m_size = 1;
|
||||
}
|
||||
set(m_int_min, -static_cast<int64>(INT_MIN));
|
||||
set(m_int_min, -static_cast<int64_t>(INT_MIN));
|
||||
#else
|
||||
// GMP
|
||||
mpz_init(m_tmp);
|
||||
|
@ -122,8 +172,8 @@ mpz_manager<SYNCH>::mpz_manager():
|
|||
mpz_init(m_int64_max);
|
||||
mpz_init(m_int64_min);
|
||||
|
||||
max_l = static_cast<unsigned>(INT64_MAX % static_cast<int64>(UINT_MAX));
|
||||
max_h = static_cast<unsigned>(INT64_MAX / static_cast<int64>(UINT_MAX));
|
||||
max_l = static_cast<unsigned>(INT64_MAX % static_cast<int64_t>(UINT_MAX));
|
||||
max_h = static_cast<unsigned>(INT64_MAX / static_cast<int64_t>(UINT_MAX));
|
||||
mpz_set_ui(m_int64_max, max_h);
|
||||
mpz_set_ui(m_tmp, UINT_MAX);
|
||||
mpz_mul(m_int64_max, m_tmp, m_int64_max);
|
||||
|
@ -134,7 +184,7 @@ mpz_manager<SYNCH>::mpz_manager():
|
|||
#endif
|
||||
|
||||
mpz one(1);
|
||||
set(m_two64, (uint64)UINT64_MAX);
|
||||
set(m_two64, (uint64_t)UINT64_MAX);
|
||||
add(m_two64, one, m_two64);
|
||||
}
|
||||
|
||||
|
@ -162,13 +212,13 @@ mpz_manager<SYNCH>::~mpz_manager() {
|
|||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64 v) {
|
||||
void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64_t v) {
|
||||
#ifndef _MP_GMP
|
||||
if (is_small(c)) {
|
||||
c.m_ptr = allocate(m_init_cell_capacity);
|
||||
}
|
||||
SASSERT(capacity(c) >= m_init_cell_capacity);
|
||||
uint64 _v;
|
||||
uint64_t _v;
|
||||
if (v < 0) {
|
||||
_v = -v;
|
||||
c.m_val = -1;
|
||||
|
@ -177,7 +227,7 @@ void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64 v) {
|
|||
_v = v;
|
||||
c.m_val = 1;
|
||||
}
|
||||
if (sizeof(digit_t) == sizeof(uint64)) {
|
||||
if (sizeof(digit_t) == sizeof(uint64_t)) {
|
||||
// 64-bit machine
|
||||
digits(c)[0] = static_cast<digit_t>(_v);
|
||||
c.m_ptr->m_size = 1;
|
||||
|
@ -192,7 +242,7 @@ void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64 v) {
|
|||
if (is_small(c)) {
|
||||
c.m_ptr = allocate();
|
||||
}
|
||||
uint64 _v;
|
||||
uint64_t _v;
|
||||
bool sign;
|
||||
if (v < 0) {
|
||||
_v = -v;
|
||||
|
@ -212,14 +262,14 @@ void mpz_manager<SYNCH>::set_big_i64(mpz & c, int64 v) {
|
|||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
void mpz_manager<SYNCH>::set_big_ui64(mpz & c, uint64 v) {
|
||||
void mpz_manager<SYNCH>::set_big_ui64(mpz & c, uint64_t v) {
|
||||
#ifndef _MP_GMP
|
||||
if (is_small(c)) {
|
||||
c.m_ptr = allocate(m_init_cell_capacity);
|
||||
}
|
||||
SASSERT(capacity(c) >= m_init_cell_capacity);
|
||||
c.m_val = 1;
|
||||
if (sizeof(digit_t) == sizeof(uint64)) {
|
||||
if (sizeof(digit_t) == sizeof(uint64_t)) {
|
||||
// 64-bit machine
|
||||
digits(c)[0] = static_cast<digit_t>(v);
|
||||
c.m_ptr->m_size = 1;
|
||||
|
@ -726,7 +776,7 @@ void mpz_manager<SYNCH>::gcd(mpz const & a, mpz const & b, mpz & c) {
|
|||
// For now, it only works if sizeof(digit_t) == sizeof(unsigned)
|
||||
static_assert(sizeof(digit_t) == sizeof(unsigned), "");
|
||||
|
||||
int64 a_hat, b_hat, A, B, C, D, T, q, a_sz, b_sz;
|
||||
int64_t a_hat, b_hat, A, B, C, D, T, q, a_sz, b_sz;
|
||||
mpz a1, b1, t, r, tmp;
|
||||
set(a1, a);
|
||||
set(b1, b);
|
||||
|
@ -766,10 +816,10 @@ void mpz_manager<SYNCH>::gcd(mpz const & a, mpz const & b, mpz & c) {
|
|||
D = 1;
|
||||
while (true) {
|
||||
// Loop invariants
|
||||
SASSERT(a_hat + A <= static_cast<int64>(UINT_MAX) + 1);
|
||||
SASSERT(a_hat + B < static_cast<int64>(UINT_MAX) + 1);
|
||||
SASSERT(b_hat + C < static_cast<int64>(UINT_MAX) + 1);
|
||||
SASSERT(b_hat + D <= static_cast<int64>(UINT_MAX) + 1);
|
||||
SASSERT(a_hat + A <= static_cast<int64_t>(UINT_MAX) + 1);
|
||||
SASSERT(a_hat + B < static_cast<int64_t>(UINT_MAX) + 1);
|
||||
SASSERT(b_hat + C < static_cast<int64_t>(UINT_MAX) + 1);
|
||||
SASSERT(b_hat + D <= static_cast<int64_t>(UINT_MAX) + 1);
|
||||
// overflows can't happen since I'm using int64
|
||||
if (b_hat + C == 0 || b_hat + D == 0)
|
||||
break;
|
||||
|
@ -1035,7 +1085,7 @@ void mpz_manager<SYNCH>::bitwise_or(mpz const & a, mpz const & b, mpz & c) {
|
|||
mod(a1, m_two64, a2);
|
||||
mod(b1, m_two64, b2);
|
||||
TRACE("mpz", tout << "a2: " << to_string(a2) << ", b2: " << to_string(b2) << "\n";);
|
||||
uint64 v = get_uint64(a2) | get_uint64(b2);
|
||||
uint64_t v = get_uint64(a2) | get_uint64(b2);
|
||||
TRACE("mpz", tout << "uint(a2): " << get_uint64(a2) << ", uint(b2): " << get_uint64(b2) << "\n";);
|
||||
set(tmp, v);
|
||||
mul(tmp, m, tmp);
|
||||
|
@ -1082,7 +1132,7 @@ void mpz_manager<SYNCH>::bitwise_and(mpz const & a, mpz const & b, mpz & c) {
|
|||
while (!is_zero(a1) && !is_zero(b1)) {
|
||||
mod(a1, m_two64, a2);
|
||||
mod(b1, m_two64, b2);
|
||||
uint64 v = get_uint64(a2) & get_uint64(b2);
|
||||
uint64_t v = get_uint64(a2) & get_uint64(b2);
|
||||
set(tmp, v);
|
||||
mul(tmp, m, tmp);
|
||||
add(c, tmp, c); // c += m * v
|
||||
|
@ -1119,7 +1169,7 @@ void mpz_manager<SYNCH>::bitwise_xor(mpz const & a, mpz const & b, mpz & c) {
|
|||
while (!is_zero(a1) && !is_zero(b1)) {
|
||||
mod(a1, m_two64, a2);
|
||||
mod(b1, m_two64, b2);
|
||||
uint64 v = get_uint64(a2) ^ get_uint64(b2);
|
||||
uint64_t v = get_uint64(a2) ^ get_uint64(b2);
|
||||
set(tmp, v);
|
||||
mul(tmp, m, tmp);
|
||||
add(c, tmp, c); // c += m * v
|
||||
|
@ -1151,7 +1201,7 @@ template<bool SYNCH>
|
|||
void mpz_manager<SYNCH>::bitwise_not(unsigned sz, mpz const & a, mpz & c) {
|
||||
SASSERT(is_nonneg(a));
|
||||
if (is_small(a) && sz <= 63) {
|
||||
int64 mask = (static_cast<int64>(1) << sz) - static_cast<int64>(1);
|
||||
int64_t mask = (static_cast<int64_t>(1) << sz) - static_cast<int64_t>(1);
|
||||
set_i64(c, (~ i64(a)) & mask);
|
||||
}
|
||||
else {
|
||||
|
@ -1161,11 +1211,11 @@ void mpz_manager<SYNCH>::bitwise_not(unsigned sz, mpz const & a, mpz & c) {
|
|||
set(c, 0);
|
||||
while (sz > 0) {
|
||||
mod(a1, m_two64, a2);
|
||||
uint64 n = get_uint64(a2);
|
||||
uint64 v = ~n;
|
||||
uint64_t n = get_uint64(a2);
|
||||
uint64_t v = ~n;
|
||||
SASSERT(~v == n);
|
||||
if (sz < 64) {
|
||||
uint64 mask = (1ull << static_cast<uint64>(sz)) - 1ull;
|
||||
uint64_t mask = (1ull << static_cast<uint64_t>(sz)) - 1ull;
|
||||
v = mask & v;
|
||||
}
|
||||
TRACE("bitwise_not", tout << "sz: " << sz << ", v: " << v << ", n: " << n << "\n";);
|
||||
|
@ -1265,7 +1315,7 @@ bool mpz_manager<SYNCH>::is_uint64(mpz const & a) const {
|
|||
return false;
|
||||
if (is_small(a))
|
||||
return true;
|
||||
if (sizeof(digit_t) == sizeof(uint64)) {
|
||||
if (sizeof(digit_t) == sizeof(uint64_t)) {
|
||||
return size(a) <= 1;
|
||||
}
|
||||
else {
|
||||
|
@ -1286,9 +1336,9 @@ bool mpz_manager<SYNCH>::is_int64(mpz const & a) const {
|
|||
#ifndef _MP_GMP
|
||||
if (!is_abs_uint64(a))
|
||||
return false;
|
||||
uint64 num = big_abs_to_uint64(a);
|
||||
uint64 msb = static_cast<uint64>(1) << 63;
|
||||
uint64 msb_val = msb & num;
|
||||
uint64_t num = big_abs_to_uint64(a);
|
||||
uint64_t msb = static_cast<uint64_t>(1) << 63;
|
||||
uint64_t msb_val = msb & num;
|
||||
if (a.m_val >= 0) {
|
||||
// non-negative number.
|
||||
return (0 == msb_val);
|
||||
|
@ -1307,54 +1357,54 @@ bool mpz_manager<SYNCH>::is_int64(mpz const & a) const {
|
|||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
uint64 mpz_manager<SYNCH>::get_uint64(mpz const & a) const {
|
||||
uint64_t mpz_manager<SYNCH>::get_uint64(mpz const & a) const {
|
||||
if (is_small(a))
|
||||
return static_cast<uint64>(a.m_val);
|
||||
return static_cast<uint64_t>(a.m_val);
|
||||
#ifndef _MP_GMP
|
||||
SASSERT(a.m_ptr->m_size > 0);
|
||||
return big_abs_to_uint64(a);
|
||||
#else
|
||||
// GMP version
|
||||
if (sizeof(uint64) == sizeof(unsigned long)) {
|
||||
if (sizeof(uint64_t) == sizeof(unsigned long)) {
|
||||
return mpz_get_ui(*a.m_ptr);
|
||||
}
|
||||
else {
|
||||
mpz_manager * _this = const_cast<mpz_manager*>(this);
|
||||
mpz_set(_this->m_tmp, *a.m_ptr);
|
||||
mpz_mod(_this->m_tmp, m_tmp, m_two32);
|
||||
uint64 r = static_cast<uint64>(mpz_get_ui(m_tmp));
|
||||
uint64_t r = static_cast<uint64_t>(mpz_get_ui(m_tmp));
|
||||
mpz_set(_this->m_tmp, *a.m_ptr);
|
||||
mpz_div(_this->m_tmp, m_tmp, m_two32);
|
||||
r += static_cast<uint64>(mpz_get_ui(m_tmp)) << static_cast<uint64>(32);
|
||||
r += static_cast<uint64_t>(mpz_get_ui(m_tmp)) << static_cast<uint64_t>(32);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template<bool SYNCH>
|
||||
int64 mpz_manager<SYNCH>::get_int64(mpz const & a) const {
|
||||
int64_t mpz_manager<SYNCH>::get_int64(mpz const & a) const {
|
||||
if (is_small(a))
|
||||
return static_cast<int64>(a.m_val);
|
||||
return static_cast<int64_t>(a.m_val);
|
||||
#ifndef _MP_GMP
|
||||
SASSERT(is_int64(a));
|
||||
uint64 num = big_abs_to_uint64(a);
|
||||
uint64_t num = big_abs_to_uint64(a);
|
||||
if (a.m_val < 0) {
|
||||
if (num != 0 && (num << 1) == 0)
|
||||
return INT64_MIN;
|
||||
return -static_cast<int64>(num);
|
||||
return -static_cast<int64_t>(num);
|
||||
}
|
||||
return static_cast<int64>(num);
|
||||
return static_cast<int64_t>(num);
|
||||
#else
|
||||
// GMP
|
||||
if (sizeof(int64) == sizeof(long) || mpz_fits_slong_p(*a.m_ptr)) {
|
||||
if (sizeof(int64_t) == sizeof(long) || mpz_fits_slong_p(*a.m_ptr)) {
|
||||
return mpz_get_si(*a.m_ptr);
|
||||
}
|
||||
else {
|
||||
mpz_manager * _this = const_cast<mpz_manager*>(this);
|
||||
mpz_mod(_this->m_tmp, *a.m_ptr, m_two32);
|
||||
int64 r = static_cast<int64>(mpz_get_ui(m_tmp));
|
||||
int64_t r = static_cast<int64_t>(mpz_get_ui(m_tmp));
|
||||
mpz_div(_this->m_tmp, *a.m_ptr, m_two32);
|
||||
r += static_cast<int64>(mpz_get_si(m_tmp)) << static_cast<int64>(32);
|
||||
r += static_cast<int64_t>(mpz_get_si(m_tmp)) << static_cast<int64_t>(32);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
@ -1370,7 +1420,7 @@ double mpz_manager<SYNCH>::get_double(mpz const & a) const {
|
|||
unsigned sz = size(a);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
r += d * static_cast<double>(digits(a)[i]);
|
||||
if (sizeof(digit_t) == sizeof(uint64))
|
||||
if (sizeof(digit_t) == sizeof(uint64_t))
|
||||
d *= static_cast<double>(UINT64_MAX); // 64-bit version
|
||||
else
|
||||
d *= static_cast<double>(UINT_MAX); // 32-bit version
|
||||
|
@ -1696,7 +1746,7 @@ void mpz_manager<SYNCH>::mul2k(mpz & a, unsigned k) {
|
|||
if (k == 0 || is_zero(a))
|
||||
return;
|
||||
if (is_small(a) && k < 32) {
|
||||
set_i64(a, i64(a) * (static_cast<int64>(1) << k));
|
||||
set_i64(a, i64(a) * (static_cast<int64_t>(1) << k));
|
||||
return;
|
||||
}
|
||||
#ifndef _MP_GMP
|
||||
|
@ -1798,9 +1848,9 @@ unsigned mpz_manager<SYNCH>::power_of_two_multiple(mpz const & a) {
|
|||
if (sizeof(digit_t) == 8) {
|
||||
// TODO: we can remove this if after we move to MPN
|
||||
// In MPN the digit_t is always an unsigned integer
|
||||
if (static_cast<uint64>(v) % (static_cast<uint64>(1) << 32) == 0) {
|
||||
if (static_cast<uint64_t>(v) % (static_cast<uint64_t>(1) << 32) == 0) {
|
||||
r += 32;
|
||||
v = static_cast<digit_t>(static_cast<uint64>(v) / (static_cast<uint64>(1) << 32));
|
||||
v = static_cast<digit_t>(static_cast<uint64_t>(v) / (static_cast<uint64_t>(1) << 32));
|
||||
}
|
||||
}
|
||||
COUNT_DIGIT_RIGHT_ZEROS();
|
||||
|
|
|
@ -30,7 +30,7 @@ Revision History:
|
|||
#include "util/mpn.h"
|
||||
|
||||
unsigned u_gcd(unsigned u, unsigned v);
|
||||
uint64 u64_gcd(uint64 u, uint64 v);
|
||||
uint64_t u64_gcd(uint64_t u, uint64_t v);
|
||||
|
||||
#ifdef _MP_GMP
|
||||
typedef unsigned digit_t;
|
||||
|
@ -92,9 +92,9 @@ class mpz {
|
|||
friend class mpbq_manager;
|
||||
mpz & operator=(mpz const & other) { UNREACHABLE(); return *this; }
|
||||
public:
|
||||
mpz(int v):m_val(v), m_ptr(0) {}
|
||||
mpz():m_val(0), m_ptr(0) {}
|
||||
mpz(mpz && other) : m_val(other.m_val), m_ptr(0) {
|
||||
mpz(int v):m_val(v), m_ptr(nullptr) {}
|
||||
mpz():m_val(0), m_ptr(nullptr) {}
|
||||
mpz(mpz && other) : m_val(other.m_val), m_ptr(nullptr) {
|
||||
std::swap(m_ptr, other.m_ptr);
|
||||
}
|
||||
void swap(mpz & other) {
|
||||
|
@ -187,16 +187,16 @@ class mpz_manager {
|
|||
|
||||
/**
|
||||
\brief Set \c a with the value stored at m_tmp[IDX], and the given sign.
|
||||
\c sz is an overapproximation of the the size of the number stored at \c tmp.
|
||||
\c sz is an overapproximation of the size of the number stored at \c tmp.
|
||||
*/
|
||||
template<int IDX>
|
||||
void set(mpz & a, int sign, unsigned sz);
|
||||
|
||||
static int64 i64(mpz const & a) { return static_cast<int64>(a.m_val); }
|
||||
static int64_t i64(mpz const & a) { return static_cast<int64_t>(a.m_val); }
|
||||
|
||||
void set_big_i64(mpz & c, int64 v);
|
||||
void set_big_i64(mpz & c, int64_t v);
|
||||
|
||||
void set_i64(mpz & c, int64 v) {
|
||||
void set_i64(mpz & c, int64_t v) {
|
||||
if (v >= INT_MIN && v <= INT_MAX) {
|
||||
del(c);
|
||||
c.m_val = static_cast<int>(v);
|
||||
|
@ -208,7 +208,7 @@ class mpz_manager {
|
|||
}
|
||||
}
|
||||
|
||||
void set_big_ui64(mpz & c, uint64 v);
|
||||
void set_big_ui64(mpz & c, uint64_t v);
|
||||
|
||||
#ifndef _MP_GMP
|
||||
static unsigned capacity(mpz const & c) { return c.m_ptr->m_capacity; }
|
||||
|
@ -221,24 +221,24 @@ class mpz_manager {
|
|||
static bool is_abs_uint64(mpz const & a) {
|
||||
if (is_small(a))
|
||||
return true;
|
||||
if (sizeof(digit_t) == sizeof(uint64))
|
||||
if (sizeof(digit_t) == sizeof(uint64_t))
|
||||
return size(a) <= 1;
|
||||
else
|
||||
return size(a) <= 2;
|
||||
}
|
||||
|
||||
// CAST the absolute value into a UINT64
|
||||
static uint64 big_abs_to_uint64(mpz const & a) {
|
||||
static uint64_t big_abs_to_uint64(mpz const & a) {
|
||||
SASSERT(is_abs_uint64(a));
|
||||
SASSERT(!is_small(a));
|
||||
if (a.m_ptr->m_size == 1)
|
||||
return digits(a)[0];
|
||||
if (sizeof(digit_t) == sizeof(uint64))
|
||||
if (sizeof(digit_t) == sizeof(uint64_t))
|
||||
// 64-bit machine
|
||||
return digits(a)[0];
|
||||
else
|
||||
// 32-bit machine
|
||||
return ((static_cast<uint64>(digits(a)[1]) << 32) | (static_cast<uint64>(digits(a)[0])));
|
||||
return ((static_cast<uint64_t>(digits(a)[1]) << 32) | (static_cast<uint64_t>(digits(a)[0])));
|
||||
}
|
||||
|
||||
template<int IDX>
|
||||
|
@ -333,16 +333,16 @@ public:
|
|||
|
||||
~mpz_manager();
|
||||
|
||||
static bool is_small(mpz const & a) { return a.m_ptr == 0; }
|
||||
static bool is_small(mpz const & a) { return a.m_ptr == nullptr; }
|
||||
|
||||
static mpz mk_z(int val) { return mpz(val); }
|
||||
|
||||
void del(mpz & a) {
|
||||
if (a.m_ptr != 0) {
|
||||
if (a.m_ptr != nullptr) {
|
||||
MPZ_BEGIN_CRITICAL();
|
||||
deallocate(a.m_ptr);
|
||||
MPZ_END_CRITICAL();
|
||||
a.m_ptr = 0;
|
||||
a.m_ptr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,8 +426,8 @@ public:
|
|||
void 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) << ") == ";);
|
||||
if (is_small(a) && is_small(b)) {
|
||||
int64 _a = i64(a);
|
||||
int64 _b = i64(b);
|
||||
int64_t _a = i64(a);
|
||||
int64_t _b = i64(b);
|
||||
set_i64(q, _a / _b);
|
||||
set_i64(r, _a % _b);
|
||||
}
|
||||
|
@ -686,16 +686,16 @@ public:
|
|||
if (val <= INT_MAX)
|
||||
set(a, static_cast<int>(val));
|
||||
else
|
||||
set(a, static_cast<int64>(static_cast<uint64>(val)));
|
||||
set(a, static_cast<int64_t>(static_cast<uint64_t>(val)));
|
||||
}
|
||||
|
||||
void set(mpz & a, char const * val);
|
||||
|
||||
void set(mpz & a, int64 val) {
|
||||
void set(mpz & a, int64_t val) {
|
||||
set_i64(a, val);
|
||||
}
|
||||
|
||||
void set(mpz & a, uint64 val) {
|
||||
void set(mpz & a, uint64_t val) {
|
||||
if (val < INT_MAX) {
|
||||
del(a);
|
||||
a.m_val = static_cast<int>(val);
|
||||
|
@ -729,9 +729,9 @@ public:
|
|||
|
||||
bool is_int64(mpz const & a) const;
|
||||
|
||||
uint64 get_uint64(mpz const & a) const;
|
||||
uint64_t get_uint64(mpz const & a) const;
|
||||
|
||||
int64 get_int64(mpz const & a) const;
|
||||
int64_t get_int64(mpz const & a) const;
|
||||
|
||||
bool is_uint(mpz const & a) const { return is_uint64(a) && get_uint64(a) < UINT_MAX; }
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
setup_p();
|
||||
}
|
||||
|
||||
mpzzp_manager(numeral_manager & _m, uint64 p, bool prime = true):
|
||||
mpzzp_manager(numeral_manager & _m, uint64_t p, bool prime = true):
|
||||
m_manager(_m),
|
||||
m_z(false) {
|
||||
m().set(m_p, p);
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
|
||||
void set_z() { m_z = true; }
|
||||
void set_zp(mpz const & new_p) { m_z = false; m_p_prime = true; m().set(m_p, new_p); setup_p(); }
|
||||
void set_zp(uint64 new_p) { m_z = false; m_p_prime = true; m().set(m_p, new_p); setup_p(); }
|
||||
void set_zp(uint64_t new_p) { m_z = false; m_p_prime = true; m().set(m_p, new_p); setup_p(); }
|
||||
// p = p^2
|
||||
void set_p_sq() { SASSERT(!m_z); m_p_prime = false; m().mul(m_p, m_p, m_p); setup_p(); }
|
||||
void set_zp_swap(mpz & new_p) { SASSERT(!m_z); m().swap(m_p, new_p); setup_p(); }
|
||||
|
@ -230,14 +230,14 @@ public:
|
|||
void set(mpz & a, int val) { m().set(a, val); p_normalize(a); }
|
||||
void set(mpz & a, unsigned val) { m().set(a, val); p_normalize(a); }
|
||||
void set(mpz & a, char const * val) { m().set(a, val); p_normalize(a); }
|
||||
void set(mpz & a, int64 val) { m().set(a, val); p_normalize(a); }
|
||||
void set(mpz & a, uint64 val) { m().set(a, val); p_normalize(a); }
|
||||
void set(mpz & a, int64_t val) { m().set(a, val); p_normalize(a); }
|
||||
void set(mpz & a, uint64_t val) { m().set(a, val); p_normalize(a); }
|
||||
void set(mpz & a, mpz const & val) { m().set(a, val); p_normalize(a); }
|
||||
|
||||
bool is_uint64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().is_uint64(a); }
|
||||
bool is_int64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().is_int64(a); }
|
||||
uint64 get_uint64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_uint64(a); }
|
||||
int64 get_int64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_int64(a); }
|
||||
uint64_t get_uint64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_uint64(a); }
|
||||
int64_t get_int64(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_int64(a); }
|
||||
double get_double(mpz & a) const { const_cast<mpzzp_manager*>(this)->p_normalize(a); return m().get_double(a); }
|
||||
void power(mpz const & a, unsigned k, mpz & b) {
|
||||
SASSERT(is_p_normalized(a));
|
||||
|
@ -265,8 +265,8 @@ public:
|
|||
|
||||
bool is_uint64(mpz const & a) const { return m().is_uint64(a); }
|
||||
bool is_int64(mpz const & a) const { return m().is_int64(a); }
|
||||
uint64 get_uint64(mpz const & a) const { return m().get_uint64(a); }
|
||||
int64 get_int64(mpz const & a) const { return m().get_int64(a); }
|
||||
uint64_t get_uint64(mpz const & a) const { return m().get_uint64(a); }
|
||||
int64_t get_int64(mpz const & a) const { return m().get_int64(a); }
|
||||
|
||||
void mul2k(mpz & a, unsigned k) { m().mul2k(a, k); p_normalize(a); }
|
||||
void mul2k(mpz const & a, unsigned k, mpz & r) { m().mul2k(a, k, r); p_normalize(r); }
|
||||
|
|
|
@ -33,9 +33,9 @@ class obj_hash_entry {
|
|||
T * m_ptr;
|
||||
public:
|
||||
typedef T * data;
|
||||
obj_hash_entry():m_ptr(0) {}
|
||||
obj_hash_entry():m_ptr(nullptr) {}
|
||||
unsigned get_hash() const { return m_ptr->hash(); }
|
||||
bool is_free() const { return m_ptr == 0; }
|
||||
bool is_free() const { return m_ptr == nullptr; }
|
||||
bool is_deleted() const { return m_ptr == reinterpret_cast<T *>(1); }
|
||||
bool is_used() const { return m_ptr != reinterpret_cast<T *>(0) && m_ptr != reinterpret_cast<T *>(1); }
|
||||
T * get_data() const { return m_ptr; }
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
void set_data(T * d) { m_ptr = d; }
|
||||
void set_hash(unsigned h) { SASSERT(h == m_ptr->hash()); }
|
||||
void mark_as_deleted() { m_ptr = reinterpret_cast<T *>(1); }
|
||||
void mark_as_free() { m_ptr = 0; }
|
||||
void mark_as_free() { m_ptr = nullptr; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
struct key_data {
|
||||
Key * m_key;
|
||||
Value m_value;
|
||||
key_data():m_key(0) {
|
||||
key_data():m_key(nullptr) {
|
||||
}
|
||||
key_data(Key * k):
|
||||
m_key(k) {
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
typedef key_data data;
|
||||
obj_map_entry() {}
|
||||
unsigned get_hash() const { return m_data.hash(); }
|
||||
bool is_free() const { return m_data.m_key == 0; }
|
||||
bool is_free() const { return m_data.m_key == nullptr; }
|
||||
bool is_deleted() const { return m_data.m_key == reinterpret_cast<Key *>(1); }
|
||||
bool is_used() const { return m_data.m_key != reinterpret_cast<Key *>(0) && m_data.m_key != reinterpret_cast<Key *>(1); }
|
||||
key_data const & get_data() const { return m_data; }
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
void set_data(key_data && d) { m_data = std::move(d); }
|
||||
void set_hash(unsigned h) { SASSERT(h == m_data.hash()); }
|
||||
void mark_as_deleted() { m_data.m_key = reinterpret_cast<Key *>(1); }
|
||||
void mark_as_free() { m_data.m_key = 0; }
|
||||
void mark_as_free() { m_data.m_key = nullptr; }
|
||||
};
|
||||
|
||||
typedef core_hashtable<obj_map_entry, obj_hash<key_data>, default_eq<key_data> > table;
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
if (e) {
|
||||
v = e->get_data().m_value;
|
||||
}
|
||||
return (0 != e);
|
||||
return (nullptr != e);
|
||||
}
|
||||
|
||||
value const & find(key * k) const {
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
}
|
||||
|
||||
bool contains(Key * k) const {
|
||||
return find_core(k) != 0;
|
||||
return find_core(k) != nullptr;
|
||||
}
|
||||
|
||||
void remove(Key * k) {
|
||||
|
@ -204,6 +204,14 @@ public:
|
|||
|
||||
unsigned long long get_num_collision() const { return m_table.get_num_collision(); }
|
||||
|
||||
void get_collisions(Key * k, vector<Key*>& collisions) {
|
||||
vector<key_data> cs;
|
||||
m_table.get_collisions(key_data(k), cs);
|
||||
for (key_data const& kd : cs) {
|
||||
collisions.push_back(kd.m_key);
|
||||
}
|
||||
}
|
||||
|
||||
void swap(obj_map & other) {
|
||||
m_table.swap(other.m_table);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class obj_pair_hash_entry {
|
|||
|
||||
public:
|
||||
typedef std::pair<T1*, T2*> data;
|
||||
obj_pair_hash_entry():m_data(static_cast<T1*>(0),static_cast<T2*>(0)) {}
|
||||
obj_pair_hash_entry():m_data(static_cast<T1*>(nullptr),static_cast<T2*>(nullptr)) {}
|
||||
unsigned get_hash() const { return m_hash; }
|
||||
bool is_free() const { return m_data.first == 0; }
|
||||
bool is_deleted() const { return m_data.first == reinterpret_cast<T1 *>(1); }
|
||||
|
@ -68,8 +68,8 @@ public:
|
|||
friend class entry;
|
||||
public:
|
||||
key_data():
|
||||
m_key1(0),
|
||||
m_key2(0),
|
||||
m_key1(nullptr),
|
||||
m_key2(nullptr),
|
||||
m_hash(0) {
|
||||
}
|
||||
key_data(Key1 * k1, Key2 * k2):
|
||||
|
@ -96,7 +96,7 @@ protected:
|
|||
typedef key_data data;
|
||||
entry() {}
|
||||
unsigned get_hash() const { return m_data.hash(); }
|
||||
bool is_free() const { return m_data.m_key1 == 0; }
|
||||
bool is_free() const { return m_data.m_key1 == nullptr; }
|
||||
bool is_deleted() const { return m_data.m_key1 == reinterpret_cast<Key1 *>(1); }
|
||||
bool is_used() const { return m_data.m_key1 != reinterpret_cast<Key1 *>(0) && m_data.m_key1 != reinterpret_cast<Key1 *>(1); }
|
||||
key_data const & get_data() const { return m_data; }
|
||||
|
@ -104,7 +104,7 @@ protected:
|
|||
void set_data(key_data const & d) { m_data = d; }
|
||||
void set_hash(unsigned h) { SASSERT(h == m_data.hash()); }
|
||||
void mark_as_deleted() { m_data.m_key1 = reinterpret_cast<Key1 *>(1); }
|
||||
void mark_as_free() { m_data.m_key1 = 0; }
|
||||
void mark_as_free() { m_data.m_key1 = nullptr; }
|
||||
};
|
||||
|
||||
typedef core_hashtable<entry, obj_hash<key_data>, default_eq<key_data> > table;
|
||||
|
@ -158,11 +158,24 @@ public:
|
|||
if (e) {
|
||||
v = e->get_data().get_value();
|
||||
}
|
||||
return (0 != e);
|
||||
return (nullptr != e);
|
||||
}
|
||||
|
||||
Value const & find(Key1 * k1, Key2 * k2) const {
|
||||
entry * e = find_core(k1, k2);
|
||||
return e->get_data().get_value();
|
||||
}
|
||||
|
||||
Value const& operator[](std::pair<Key1 *, Key2 *> const& key) const {
|
||||
return find(key.first, key.second);
|
||||
}
|
||||
|
||||
bool contains(Key1 * k1, Key2 * k2) const {
|
||||
return find_core(k1, k2) != 0;
|
||||
return find_core(k1, k2) != nullptr;
|
||||
}
|
||||
|
||||
bool contains(std::pair<Key1 *, Key2 *> const& key) const {
|
||||
return contains(key.first, key.second);
|
||||
}
|
||||
|
||||
void erase(Key1 * k1, Key2 * k2) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
}
|
||||
|
||||
explicit obj_ref(TManager & m):
|
||||
m_obj(0),
|
||||
m_obj(nullptr),
|
||||
m_manager(m) {
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
inc_ref();
|
||||
}
|
||||
|
||||
obj_ref(obj_ref && other) : m_obj(0), m_manager(other.m_manager) {
|
||||
obj_ref(obj_ref && other) : m_obj(nullptr), m_manager(other.m_manager) {
|
||||
std::swap(m_obj, other.m_obj);
|
||||
}
|
||||
|
||||
|
@ -67,9 +67,9 @@ public:
|
|||
|
||||
T * get() const { return m_obj; }
|
||||
|
||||
operator bool() const { return m_obj != 0; }
|
||||
operator bool() const { return m_obj != nullptr; }
|
||||
|
||||
bool operator!() const { return m_obj == 0; }
|
||||
bool operator!() const { return m_obj == nullptr; }
|
||||
|
||||
operator T*() const { return m_obj; }
|
||||
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
|
||||
void reset() {
|
||||
dec_ref();
|
||||
m_obj = 0;
|
||||
m_obj = nullptr;
|
||||
}
|
||||
|
||||
void swap(obj_ref & n) {
|
||||
|
|
|
@ -70,9 +70,9 @@ public:
|
|||
friend class entry;
|
||||
public:
|
||||
key_data():
|
||||
m_key1(0),
|
||||
m_key2(0),
|
||||
m_key3(0),
|
||||
m_key1(nullptr),
|
||||
m_key2(nullptr),
|
||||
m_key3(nullptr),
|
||||
m_hash(0) {
|
||||
}
|
||||
key_data(Key1 * k1, Key2 * k2, Key3 * k3):
|
||||
|
@ -102,7 +102,7 @@ protected:
|
|||
typedef key_data data;
|
||||
entry() {}
|
||||
unsigned get_hash() const { return m_data.hash(); }
|
||||
bool is_free() const { return m_data.m_key1 == 0; }
|
||||
bool is_free() const { return m_data.m_key1 == nullptr; }
|
||||
bool is_deleted() const { return m_data.m_key1 == reinterpret_cast<Key1 *>(1); }
|
||||
bool is_used() const { return m_data.m_key1 != reinterpret_cast<Key1 *>(0) && m_data.m_key1 != reinterpret_cast<Key1 *>(1); }
|
||||
key_data const & get_data() const { return m_data; }
|
||||
|
@ -110,7 +110,7 @@ protected:
|
|||
void set_data(key_data const & d) { m_data = d; }
|
||||
void set_hash(unsigned h) { SASSERT(h == m_data.hash()); }
|
||||
void mark_as_deleted() { m_data.m_key1 = reinterpret_cast<Key1 *>(1); }
|
||||
void mark_as_free() { m_data.m_key1 = 0; }
|
||||
void mark_as_free() { m_data.m_key1 = nullptr; }
|
||||
};
|
||||
|
||||
typedef core_hashtable<entry, obj_hash<key_data>, default_eq<key_data> > table;
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
if (e) {
|
||||
v = e->get_data().get_value();
|
||||
}
|
||||
return (0 != e);
|
||||
return (nullptr != e);
|
||||
}
|
||||
|
||||
bool contains(Key1 * k1, Key2 * k2, Key3 * k3) const {
|
||||
|
|
|
@ -34,14 +34,14 @@ class optional {
|
|||
void destroy() {
|
||||
if (m_initialized == 1) {
|
||||
dealloc(m_obj);
|
||||
m_obj = 0;
|
||||
m_obj = nullptr;
|
||||
}
|
||||
m_initialized = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
optional():
|
||||
m_obj(0), m_initialized(0) {}
|
||||
m_obj(nullptr), m_initialized(0) {}
|
||||
|
||||
explicit optional(const T & val) {
|
||||
construct(val);
|
||||
|
@ -128,7 +128,7 @@ class optional<T*> {
|
|||
|
||||
public:
|
||||
|
||||
optional():m_ptr(0) {}
|
||||
optional():m_ptr(nullptr) {}
|
||||
|
||||
explicit optional(T * val):m_ptr(val) {}
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
|
||||
operator bool() const { return m_ptr != 0; }
|
||||
|
||||
bool operator!() const { return m_ptr == 0; }
|
||||
bool operator!() const { return m_ptr == nullptr; }
|
||||
|
||||
void reset() { m_ptr = 0; }
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ inline char * alloc_page(size_t s) { char * r = alloc_svect(char, s+PAGE_HEADER_
|
|||
inline void del_page(char * page) { dealloc_svect(page - PAGE_HEADER_SZ); }
|
||||
|
||||
void del_pages(char * page) {
|
||||
while (page != 0) {
|
||||
while (page != nullptr) {
|
||||
char * prev = prev_page(page);
|
||||
del_page(page);
|
||||
page = prev;
|
||||
|
|
|
@ -24,7 +24,7 @@ Notes:
|
|||
params_ref params_ref::g_empty_params_ref;
|
||||
|
||||
std::string norm_param_name(char const * n) {
|
||||
if (n == 0)
|
||||
if (n == nullptr)
|
||||
return "_";
|
||||
if (*n == ':')
|
||||
n++;
|
||||
|
@ -62,9 +62,9 @@ struct param_descrs::imp {
|
|||
|
||||
info():
|
||||
m_kind(CPK_INVALID),
|
||||
m_descr(0),
|
||||
m_default(0),
|
||||
m_module(0) {
|
||||
m_descr(nullptr),
|
||||
m_default(nullptr),
|
||||
m_module(nullptr) {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -130,21 +130,21 @@ struct param_descrs::imp {
|
|||
info i;
|
||||
if (m_info.find(name, i))
|
||||
return i.m_module;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char const * get_descr(symbol const & name) const {
|
||||
info i;
|
||||
if (m_info.find(name, i))
|
||||
return i.m_descr;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char const * get_default(symbol const & name) const {
|
||||
info i;
|
||||
if (m_info.find(name, i))
|
||||
return i.m_default;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned size() const {
|
||||
|
@ -191,7 +191,7 @@ struct param_descrs::imp {
|
|||
out << " (" << d.m_kind << ")";
|
||||
if (include_descr)
|
||||
out << " " << d.m_descr;
|
||||
if (d.m_default != 0)
|
||||
if (d.m_default != nullptr)
|
||||
out << " (default: " << d.m_default << ")";
|
||||
out << "\n";
|
||||
}
|
||||
|
@ -323,7 +323,6 @@ class params {
|
|||
typedef std::pair<symbol, value> entry;
|
||||
svector<entry> m_entries;
|
||||
unsigned m_ref_count;
|
||||
|
||||
void del_value(entry & e);
|
||||
void del_values();
|
||||
|
||||
|
@ -334,7 +333,10 @@ public:
|
|||
}
|
||||
|
||||
void inc_ref() { m_ref_count++; }
|
||||
void dec_ref() { SASSERT(m_ref_count > 0); m_ref_count--; if (m_ref_count == 0) dealloc(this); }
|
||||
void dec_ref() {
|
||||
SASSERT(m_ref_count > 0);
|
||||
if (--m_ref_count == 0) dealloc(this);
|
||||
}
|
||||
|
||||
bool empty() const { return m_entries.empty(); }
|
||||
bool contains(symbol const & k) const;
|
||||
|
@ -344,7 +346,6 @@ public:
|
|||
void reset(symbol const & k);
|
||||
void reset(char const * k);
|
||||
|
||||
|
||||
void validate(param_descrs const & p) {
|
||||
svector<params::entry>::iterator it = m_entries.begin();
|
||||
svector<params::entry>::iterator end = m_entries.end();
|
||||
|
@ -510,7 +511,7 @@ params_ref::~params_ref() {
|
|||
}
|
||||
|
||||
params_ref::params_ref(params_ref const & p):
|
||||
m_params(0) {
|
||||
m_params(nullptr) {
|
||||
operator=(p);
|
||||
}
|
||||
|
||||
|
@ -554,7 +555,7 @@ params_ref & params_ref::operator=(params_ref const & p) {
|
|||
}
|
||||
|
||||
void params_ref::copy(params_ref const & src) {
|
||||
if (m_params == 0)
|
||||
if (m_params == nullptr)
|
||||
operator=(src);
|
||||
else {
|
||||
init();
|
||||
|
@ -563,29 +564,27 @@ void params_ref::copy(params_ref const & src) {
|
|||
}
|
||||
|
||||
void params_ref::copy_core(params const * src) {
|
||||
if (src == 0)
|
||||
if (src == nullptr)
|
||||
return;
|
||||
svector<params::entry>::const_iterator it = src->m_entries.begin();
|
||||
svector<params::entry>::const_iterator end = src->m_entries.end();
|
||||
for (; it != end; ++it) {
|
||||
switch (it->second.m_kind) {
|
||||
for (auto const& p : src->m_entries) {
|
||||
switch (p.second.m_kind) {
|
||||
case CPK_BOOL:
|
||||
m_params->set_bool(it->first, it->second.m_bool_value);
|
||||
m_params->set_bool(p.first, p.second.m_bool_value);
|
||||
break;
|
||||
case CPK_UINT:
|
||||
m_params->set_uint(it->first, it->second.m_uint_value);
|
||||
m_params->set_uint(p.first, p.second.m_uint_value);
|
||||
break;
|
||||
case CPK_DOUBLE:
|
||||
m_params->set_double(it->first, it->second.m_double_value);
|
||||
m_params->set_double(p.first, p.second.m_double_value);
|
||||
break;
|
||||
case CPK_NUMERAL:
|
||||
m_params->set_rat(it->first, *(it->second.m_rat_value));
|
||||
m_params->set_rat(p.first, *(p.second.m_rat_value));
|
||||
break;
|
||||
case CPK_SYMBOL:
|
||||
m_params->set_sym(it->first, symbol::mk_symbol_from_c_ptr(it->second.m_sym_value));
|
||||
m_params->set_sym(p.first, symbol::mk_symbol_from_c_ptr(p.second.m_sym_value));
|
||||
break;
|
||||
case CPK_STRING:
|
||||
m_params->set_str(it->first, it->second.m_str_value);
|
||||
m_params->set_str(p.first, p.second.m_str_value);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
|
|
@ -37,7 +37,7 @@ class params_ref {
|
|||
void init();
|
||||
void copy_core(params const * p);
|
||||
public:
|
||||
params_ref():m_params(0) {}
|
||||
params_ref():m_params(nullptr) {}
|
||||
params_ref(params_ref const & p);
|
||||
~params_ref();
|
||||
|
||||
|
@ -115,8 +115,8 @@ public:
|
|||
param_descrs();
|
||||
~param_descrs();
|
||||
void copy(param_descrs & other);
|
||||
void insert(char const * name, param_kind k, char const * descr, char const * def = 0, char const* module = 0);
|
||||
void insert(symbol const & name, param_kind k, char const * descr, char const * def = 0, char const* module = 0);
|
||||
void insert(char const * name, param_kind k, char const * descr, char const * def = nullptr, char const* module = nullptr);
|
||||
void insert(symbol const & name, param_kind k, char const * descr, char const * def = nullptr, char const* module = nullptr);
|
||||
bool contains(char const * name) const;
|
||||
bool contains(symbol const & name) const;
|
||||
void erase(char const * name);
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
typedef typename C::allocator allocator;
|
||||
private:
|
||||
static size_t capacity(value * vs) {
|
||||
return vs == 0 ? 0 : (reinterpret_cast<size_t*>(vs))[-1];
|
||||
return vs == nullptr ? 0 : (reinterpret_cast<size_t*>(vs))[-1];
|
||||
}
|
||||
|
||||
value * allocate_values(size_t c) {
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
}
|
||||
|
||||
void deallocate_values(value * vs) {
|
||||
if (vs == 0)
|
||||
if (vs == nullptr)
|
||||
return;
|
||||
size_t c = capacity(vs);
|
||||
TRACE("parray_mem", tout << "deallocated values[" << c << "]: " << vs << "\n";);
|
||||
|
@ -73,7 +73,7 @@ private:
|
|||
unsigned size() const { SASSERT(kind() == ROOT); return m_size; }
|
||||
cell * next() const { SASSERT(kind() != ROOT); return m_next; }
|
||||
value const & elem() const { SASSERT(kind() == SET || kind() == PUSH_BACK); return m_elem; }
|
||||
cell(ckind k):m_ref_count(1), m_kind(k), m_size(0), m_values(0) {}
|
||||
cell(ckind k):m_ref_count(1), m_kind(k), m_size(0), m_values(nullptr) {}
|
||||
};
|
||||
|
||||
value_manager & m_vmanager;
|
||||
|
@ -105,7 +105,7 @@ private:
|
|||
|
||||
void del(cell * c) {
|
||||
while (true) {
|
||||
cell * next = 0;
|
||||
cell * next = nullptr;
|
||||
switch (c->kind()) {
|
||||
case SET:
|
||||
case PUSH_BACK:
|
||||
|
@ -123,7 +123,7 @@ private:
|
|||
TRACE("parray_mem", tout << "deallocated cell: " << c << "\n";);
|
||||
c->~cell();
|
||||
m_allocator.deallocate(sizeof(cell), c);
|
||||
if (next == 0)
|
||||
if (next == nullptr)
|
||||
return;
|
||||
SASSERT(next->m_ref_count > 0);
|
||||
next->m_ref_count--;
|
||||
|
@ -214,7 +214,7 @@ private:
|
|||
}
|
||||
SASSERT(r->kind() == ROOT);
|
||||
unsigned sz = r->m_size;
|
||||
vs = 0;
|
||||
vs = nullptr;
|
||||
copy_values(r->m_values, sz, vs);
|
||||
unsigned i = cs.size();
|
||||
while (i > 0) {
|
||||
|
@ -246,7 +246,7 @@ private:
|
|||
dec_ref(c->m_next);
|
||||
if (c->kind() == SET || c->kind() == PUSH_BACK)
|
||||
dec_ref(c->m_elem);
|
||||
c->m_next = 0;
|
||||
c->m_next = nullptr;
|
||||
c->m_kind = ROOT;
|
||||
c->m_size = sz;
|
||||
c->m_values = vs;
|
||||
|
@ -262,7 +262,7 @@ public:
|
|||
bool unshared() const { return m_ref->m_ref_count == 1; }
|
||||
friend class parray_manager;
|
||||
public:
|
||||
ref():m_ref(0), m_updt_counter(0) {}
|
||||
ref():m_ref(nullptr), m_updt_counter(0) {}
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -283,7 +283,7 @@ public:
|
|||
|
||||
void del(ref & r) {
|
||||
dec_ref(r.m_ref);
|
||||
r.m_ref = 0;
|
||||
r.m_ref = nullptr;
|
||||
r.m_updt_counter = 0;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ public:
|
|||
|
||||
unsigned size(ref const & r) const {
|
||||
cell * c = r.m_ref;
|
||||
if (c == 0) return 0;
|
||||
if (c == nullptr) return 0;
|
||||
while (true) {
|
||||
switch (c->kind()) {
|
||||
case SET:
|
||||
|
@ -397,7 +397,7 @@ public:
|
|||
}
|
||||
|
||||
void push_back(ref & r, value const & v) {
|
||||
if (r.m_ref == 0)
|
||||
if (r.m_ref == nullptr)
|
||||
mk(r);
|
||||
if (r.root()) {
|
||||
if (r.unshared()) {
|
||||
|
|
|
@ -27,7 +27,12 @@ class plugin_manager {
|
|||
ptr_vector<Plugin> m_plugins;
|
||||
public:
|
||||
~plugin_manager() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
std::for_each(m_plugins.begin(), m_plugins.end(), delete_proc<Plugin>());
|
||||
release();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +53,7 @@ public:
|
|||
|
||||
Plugin * get_plugin(family_id fid) const {
|
||||
if (fid == null_family_id) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
return m_fid2plugins.get(fid, 0);
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ prime_generator::prime_generator() {
|
|||
process_next_k_numbers(128);
|
||||
}
|
||||
|
||||
void prime_generator::process_next_k_numbers(uint64 k) {
|
||||
svector<uint64> todo;
|
||||
uint64 begin = m_primes.back() + 2;
|
||||
uint64 end = begin + k;
|
||||
for (uint64 i = begin; i < end; i+=2) {
|
||||
void prime_generator::process_next_k_numbers(uint64_t k) {
|
||||
svector<uint64_t> todo;
|
||||
uint64_t begin = m_primes.back() + 2;
|
||||
uint64_t end = begin + k;
|
||||
for (uint64_t i = begin; i < end; i+=2) {
|
||||
todo.push_back(i);
|
||||
}
|
||||
unsigned j = 1;
|
||||
|
@ -38,7 +38,7 @@ void prime_generator::process_next_k_numbers(uint64 k) {
|
|||
while (!todo.empty()) {
|
||||
unsigned sz = m_primes.size();
|
||||
for (; j < sz; j++) {
|
||||
uint64 p = m_primes[j];
|
||||
uint64_t p = m_primes[j];
|
||||
unsigned todo_sz = todo.size();
|
||||
unsigned k1 = 0;
|
||||
unsigned k2 = 0;
|
||||
|
@ -59,7 +59,7 @@ void prime_generator::process_next_k_numbers(uint64 k) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
uint64 p = m_primes.back();
|
||||
uint64_t p = m_primes.back();
|
||||
p = p*p;
|
||||
unsigned todo_sz = todo.size();
|
||||
unsigned k1 = 0;
|
||||
|
@ -83,7 +83,7 @@ void prime_generator::finalize() {
|
|||
m_primes.finalize();
|
||||
}
|
||||
|
||||
uint64 prime_generator::operator()(unsigned idx) {
|
||||
uint64_t prime_generator::operator()(unsigned idx) {
|
||||
if (idx < m_primes.size())
|
||||
return m_primes[idx];
|
||||
if (idx > PRIME_LIST_MAX_SIZE)
|
||||
|
@ -99,7 +99,7 @@ uint64 prime_generator::operator()(unsigned idx) {
|
|||
prime_generator g_prime_generator;
|
||||
|
||||
prime_iterator::prime_iterator(prime_generator * g):m_idx(0) {
|
||||
if (g == 0) {
|
||||
if (g == nullptr) {
|
||||
m_generator = &g_prime_generator;
|
||||
m_global = true;
|
||||
}
|
||||
|
@ -109,14 +109,14 @@ prime_iterator::prime_iterator(prime_generator * g):m_idx(0) {
|
|||
}
|
||||
}
|
||||
|
||||
uint64 prime_iterator::next() {
|
||||
uint64_t prime_iterator::next() {
|
||||
unsigned idx = m_idx;
|
||||
m_idx++;
|
||||
if (!m_global) {
|
||||
return (*m_generator)(idx);
|
||||
}
|
||||
else {
|
||||
uint64 r;
|
||||
uint64_t r;
|
||||
#pragma omp critical (prime_iterator)
|
||||
{
|
||||
r = (*m_generator)(idx);
|
||||
|
|
|
@ -32,11 +32,11 @@ public:
|
|||
\brief Prime generator
|
||||
*/
|
||||
class prime_generator {
|
||||
svector<uint64> m_primes;
|
||||
void process_next_k_numbers(uint64 k);
|
||||
svector<uint64_t> m_primes;
|
||||
void process_next_k_numbers(uint64_t k);
|
||||
public:
|
||||
prime_generator();
|
||||
uint64 operator()(unsigned idx);
|
||||
uint64_t operator()(unsigned idx);
|
||||
void finalize();
|
||||
};
|
||||
|
||||
|
@ -45,8 +45,8 @@ class prime_iterator {
|
|||
prime_generator * m_generator;
|
||||
bool m_global;
|
||||
public:
|
||||
prime_iterator(prime_generator * g = 0);
|
||||
uint64 next();
|
||||
prime_iterator(prime_generator * g = nullptr);
|
||||
uint64_t next();
|
||||
static void finalize();
|
||||
/*
|
||||
ADD_FINALIZER('prime_iterator::finalize();')
|
||||
|
|
73
src/util/queue.h
Normal file
73
src/util/queue.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*++
|
||||
Copyright (c) 2017 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
queue.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Generic queue.
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2017-4-17
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _QUEUE_H_
|
||||
#define _QUEUE_H_
|
||||
|
||||
#include "vector.h"
|
||||
|
||||
template<class T>
|
||||
class queue {
|
||||
vector<T> m_elems;
|
||||
unsigned m_head;
|
||||
unsigned m_capacity;
|
||||
|
||||
public:
|
||||
|
||||
queue(): m_head(0), m_capacity(0) {}
|
||||
|
||||
void push(T const& t) { m_elems.push_back(t); }
|
||||
|
||||
bool empty() const {
|
||||
return m_head == m_elems.size();
|
||||
}
|
||||
|
||||
T top() const {
|
||||
return m_elems[m_head];
|
||||
}
|
||||
|
||||
T pop_front() {
|
||||
SASSERT(!empty());
|
||||
m_capacity = std::max(m_capacity, m_elems.size());
|
||||
SASSERT(m_head < m_elems.size());
|
||||
if (2 * m_head > m_capacity && m_capacity > 10) {
|
||||
for (unsigned i = 0; i < m_elems.size() - m_head; ++i) {
|
||||
m_elems[i] = m_elems[i + m_head];
|
||||
}
|
||||
m_elems.shrink(m_elems.size() - m_head);
|
||||
m_head = 0;
|
||||
}
|
||||
return m_elems[m_head++];
|
||||
}
|
||||
|
||||
|
||||
T back() const {
|
||||
return m_elems[m_elems.size() - 1];
|
||||
}
|
||||
|
||||
T pop_back() {
|
||||
SASSERT(!empty());
|
||||
SASSERT(m_head < m_elems.size());
|
||||
T result = back();
|
||||
m_elems.shrink(m_elems.size() - 1);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -23,7 +23,7 @@ Revision History:
|
|||
#include<strsafe.h>
|
||||
#endif
|
||||
|
||||
synch_mpq_manager * rational::g_mpq_manager = 0;
|
||||
synch_mpq_manager * rational::g_mpq_manager = nullptr;
|
||||
rational rational::m_zero;
|
||||
rational rational::m_one;
|
||||
rational rational::m_minus_one;
|
||||
|
@ -80,6 +80,6 @@ void rational::finalize() {
|
|||
m_one.~rational();
|
||||
m_minus_one.~rational();
|
||||
dealloc(g_mpq_manager);
|
||||
g_mpq_manager = 0;
|
||||
g_mpq_manager = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,10 +59,10 @@ public:
|
|||
explicit rational(char const * v) { m().set(m_val, v); }
|
||||
|
||||
struct i64 {};
|
||||
rational(int64 i, i64) { m().set(m_val, i); }
|
||||
rational(int64_t i, i64) { m().set(m_val, i); }
|
||||
|
||||
struct ui64 {};
|
||||
rational(uint64 i, ui64) { m().set(m_val, i); }
|
||||
rational(uint64_t i, ui64) { m().set(m_val, i); }
|
||||
|
||||
~rational() { m().del(m_val); }
|
||||
|
||||
|
@ -98,9 +98,9 @@ public:
|
|||
|
||||
bool is_int64() const { return m().is_int64(m_val); }
|
||||
|
||||
uint64 get_uint64() const { return m().get_uint64(m_val); }
|
||||
uint64_t get_uint64() const { return m().get_uint64(m_val); }
|
||||
|
||||
int64 get_int64() const { return m().get_int64(m_val); }
|
||||
int64_t get_int64() const { return m().get_int64(m_val); }
|
||||
|
||||
bool is_unsigned() const { return is_uint64() && (get_uint64() < (1ull << 32)); }
|
||||
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
if (is_small() && is_int()) return true;
|
||||
// we don't assume that if it is small, then it is int32.
|
||||
if (!is_int64()) return false;
|
||||
int64 v = get_int64();
|
||||
int64_t v = get_int64();
|
||||
return INT_MIN <= v && v <= INT_MAX;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class ref {
|
|||
|
||||
public:
|
||||
ref():
|
||||
m_ptr(0) {
|
||||
m_ptr(nullptr) {
|
||||
}
|
||||
|
||||
ref(T * ptr):
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
}
|
||||
|
||||
operator bool() const {
|
||||
return m_ptr != 0;
|
||||
return m_ptr != nullptr;
|
||||
}
|
||||
|
||||
const T & operator*() const {
|
||||
|
@ -100,12 +100,12 @@ public:
|
|||
|
||||
void reset() {
|
||||
dec_ref();
|
||||
m_ptr = 0;
|
||||
m_ptr = nullptr;
|
||||
}
|
||||
|
||||
T* detach() {
|
||||
T* tmp = m_ptr;
|
||||
m_ptr = 0;
|
||||
m_ptr = nullptr;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,9 @@ public:
|
|||
return m_buffer[idx];
|
||||
}
|
||||
|
||||
T* const* begin() const { return c_ptr(); }
|
||||
T* const* end() const { return c_ptr() + size(); }
|
||||
|
||||
void set(unsigned idx, T * n) {
|
||||
inc_ref(n);
|
||||
dec_ref(m_buffer[idx]);
|
||||
|
|
|
@ -38,11 +38,11 @@ inline void region::allocate_page() {
|
|||
}
|
||||
|
||||
region::region() {
|
||||
m_curr_page = 0;
|
||||
m_curr_ptr = 0;
|
||||
m_curr_end_ptr = 0;
|
||||
m_free_pages = 0;
|
||||
m_mark = 0;
|
||||
m_curr_page = nullptr;
|
||||
m_curr_ptr = nullptr;
|
||||
m_curr_end_ptr = nullptr;
|
||||
m_free_pages = nullptr;
|
||||
m_mark = nullptr;
|
||||
allocate_page();
|
||||
}
|
||||
|
||||
|
@ -81,13 +81,13 @@ inline void region::recycle_curr_page() {
|
|||
}
|
||||
|
||||
void region::reset() {
|
||||
while (m_curr_page != 0) {
|
||||
while (m_curr_page != nullptr) {
|
||||
recycle_curr_page();
|
||||
}
|
||||
SASSERT(m_curr_page == 0);
|
||||
m_curr_ptr = 0;
|
||||
m_curr_end_ptr = 0;
|
||||
m_mark = 0;
|
||||
m_curr_ptr = nullptr;
|
||||
m_curr_end_ptr = nullptr;
|
||||
m_mark = nullptr;
|
||||
allocate_page();
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ void region::pop_scope() {
|
|||
void region::display_mem_stats(std::ostream & out) const {
|
||||
unsigned n = 0;
|
||||
char * page = m_curr_page;
|
||||
while (page != 0) {
|
||||
while (page != nullptr) {
|
||||
n++;
|
||||
page = prev_page(page);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ reslimit::reslimit():
|
|||
m_limit(0) {
|
||||
}
|
||||
|
||||
uint64 reslimit::count() const {
|
||||
uint64_t reslimit::count() const {
|
||||
return m_count;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ bool reslimit::inc(unsigned offset) {
|
|||
}
|
||||
|
||||
void reslimit::push(unsigned delta_limit) {
|
||||
uint64 new_limit = delta_limit + m_count;
|
||||
uint64_t new_limit = delta_limit + m_count;
|
||||
if (new_limit <= m_count) {
|
||||
new_limit = 0;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ Revision History:
|
|||
class reslimit {
|
||||
volatile unsigned m_cancel;
|
||||
bool m_suspend;
|
||||
uint64 m_count;
|
||||
uint64 m_limit;
|
||||
svector<uint64> m_limits;
|
||||
uint64_t m_count;
|
||||
uint64_t m_limit;
|
||||
svector<uint64_t> m_limits;
|
||||
ptr_vector<reslimit> m_children;
|
||||
|
||||
void set_cancel(unsigned f);
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
bool inc();
|
||||
bool inc(unsigned offset);
|
||||
uint64 count() const;
|
||||
uint64_t count() const;
|
||||
|
||||
|
||||
bool get_cancel_flag() const { return m_cancel > 0 && !m_suspend; }
|
||||
|
|
|
@ -24,7 +24,7 @@ s_integer s_integer::m_one(1);
|
|||
s_integer s_integer::m_minus_one(-1);
|
||||
|
||||
s_integer::s_integer(const char * str) {
|
||||
m_val = static_cast<int>(strtol(str, 0, 10));
|
||||
m_val = static_cast<int>(strtol(str, nullptr, 10));
|
||||
}
|
||||
|
||||
s_integer power(const s_integer & r, unsigned p) {
|
||||
|
|
|
@ -46,9 +46,9 @@ public:
|
|||
s_integer(const s_integer & r):m_val(r.m_val) {}
|
||||
explicit s_integer(int n):m_val(n) {}
|
||||
struct i64 {};
|
||||
explicit s_integer(int64 i, i64):m_val(static_cast<int>(i)) {}
|
||||
explicit s_integer(int64_t i, i64):m_val(static_cast<int>(i)) {}
|
||||
struct ui64 {};
|
||||
explicit s_integer(uint64 i, ui64):m_val(static_cast<int>(i)) {}
|
||||
explicit s_integer(uint64_t i, ui64):m_val(static_cast<int>(i)) {}
|
||||
explicit s_integer(const char * str);
|
||||
explicit s_integer(const rational & r):m_val(static_cast<int>(r.get_int64())) {}
|
||||
|
||||
|
@ -60,8 +60,8 @@ public:
|
|||
static bool is_int64() { return true; }
|
||||
static bool is_uint64() { return true; }
|
||||
int get_int() const { return m_val; }
|
||||
int64 get_int64() const { return m_val; }
|
||||
uint64 get_uint64() const { return m_val; }
|
||||
int64_t get_int64() const { return m_val; }
|
||||
uint64_t get_uint64() const { return m_val; }
|
||||
static bool is_unsigned() { return true; }
|
||||
unsigned get_unsigned() const { return static_cast<unsigned>(m_val); }
|
||||
s_integer const& get_s_integer() const { return *this; }
|
||||
|
|
|
@ -20,7 +20,7 @@ Revision History:
|
|||
#include<iostream>
|
||||
#include "util/scoped_ctrl_c.h"
|
||||
|
||||
scoped_ctrl_c * scoped_ctrl_c::g_obj = 0;
|
||||
scoped_ctrl_c * scoped_ctrl_c::g_obj = nullptr;
|
||||
|
||||
void scoped_ctrl_c::on_ctrl_c(int) {
|
||||
if (g_obj->m_first) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
~scoped_ptr_vector() { reset(); }
|
||||
void reset() { std::for_each(m_vector.begin(), m_vector.end(), delete_proc<T>()); m_vector.reset(); }
|
||||
void push_back(T * ptr) { m_vector.push_back(ptr); }
|
||||
void pop_back() { SASSERT(!empty()); set(size()-1, 0); m_vector.pop_back(); }
|
||||
void pop_back() { SASSERT(!empty()); set(size()-1, nullptr); m_vector.pop_back(); }
|
||||
T * operator[](unsigned idx) const { return m_vector[idx]; }
|
||||
void set(unsigned idx, T * ptr) {
|
||||
if (m_vector[idx] == ptr)
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
}
|
||||
else {
|
||||
for (unsigned i = m_vector.size(); i < sz; i++)
|
||||
push_back(0);
|
||||
push_back(nullptr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -33,8 +33,8 @@ Revision History:
|
|||
#include<sys/time.h>
|
||||
#include<sys/errno.h>
|
||||
#include<pthread.h>
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_)
|
||||
// Linux
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NetBSD_)
|
||||
// Linux & FreeBSD & NetBSD
|
||||
#include<errno.h>
|
||||
#include<pthread.h>
|
||||
#include<sched.h>
|
||||
|
@ -66,8 +66,8 @@ struct scoped_timer::imp {
|
|||
pthread_mutex_t m_mutex;
|
||||
pthread_cond_t m_condition_var;
|
||||
struct timespec m_end_time;
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_)
|
||||
// Linux & FreeBSD
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_)
|
||||
// Linux & FreeBSD & NetBSD
|
||||
pthread_t m_thread_id;
|
||||
pthread_mutex_t m_mutex;
|
||||
pthread_cond_t m_cond;
|
||||
|
@ -104,7 +104,7 @@ struct scoped_timer::imp {
|
|||
|
||||
return st;
|
||||
}
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_)
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_)
|
||||
static void* thread_func(void *arg) {
|
||||
scoped_timer::imp *st = static_cast<scoped_timer::imp*>(arg);
|
||||
|
||||
|
@ -157,9 +157,9 @@ struct scoped_timer::imp {
|
|||
m_interval = ms?ms:0xFFFFFFFF;
|
||||
if (pthread_attr_init(&m_attributes) != 0)
|
||||
throw default_exception("failed to initialize timer thread attributes");
|
||||
if (pthread_cond_init(&m_condition_var, NULL) != 0)
|
||||
if (pthread_cond_init(&m_condition_var, nullptr) != 0)
|
||||
throw default_exception("failed to initialize timer condition variable");
|
||||
if (pthread_mutex_init(&m_mutex, NULL) != 0)
|
||||
if (pthread_mutex_init(&m_mutex, nullptr) != 0)
|
||||
throw default_exception("failed to initialize timer mutex");
|
||||
|
||||
clock_serv_t host_clock;
|
||||
|
@ -175,8 +175,8 @@ struct scoped_timer::imp {
|
|||
|
||||
if (pthread_create(&m_thread_id, &m_attributes, &thread_func, this) != 0)
|
||||
throw default_exception("failed to start timer thread");
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_)
|
||||
// Linux & FreeBSD
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_)
|
||||
// Linux & FreeBSD & NetBSD
|
||||
m_ms = ms;
|
||||
m_initialized = false;
|
||||
m_signal_sent = false;
|
||||
|
@ -208,16 +208,24 @@ struct scoped_timer::imp {
|
|||
pthread_cond_signal(&m_condition_var);
|
||||
pthread_mutex_unlock(&m_mutex);
|
||||
|
||||
if (pthread_join(m_thread_id, NULL) != 0)
|
||||
throw default_exception("failed to join thread");
|
||||
if (pthread_mutex_destroy(&m_mutex) != 0)
|
||||
throw default_exception("failed to destroy pthread mutex");
|
||||
if (pthread_cond_destroy(&m_condition_var) != 0)
|
||||
throw default_exception("failed to destroy pthread condition variable");
|
||||
if (pthread_attr_destroy(&m_attributes) != 0)
|
||||
throw default_exception("failed to destroy pthread attributes object");
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_)
|
||||
// Linux & FreeBSD
|
||||
if (pthread_join(m_thread_id, nullptr) != 0) {
|
||||
warning_msg("failed to join thread");
|
||||
return;
|
||||
}
|
||||
if (pthread_mutex_destroy(&m_mutex) != 0) {
|
||||
warning_msg("failed to destroy pthread mutex");
|
||||
return;
|
||||
}
|
||||
if (pthread_cond_destroy(&m_condition_var) != 0) {
|
||||
warning_msg("failed to destroy pthread condition variable");
|
||||
return;
|
||||
}
|
||||
if (pthread_attr_destroy(&m_attributes) != 0) {
|
||||
warning_msg("failed to destroy pthread attributes object");
|
||||
return;
|
||||
}
|
||||
#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_)
|
||||
// Linux & FreeBSD & NetBSD
|
||||
bool init = false;
|
||||
|
||||
// spin until timer thread has been created
|
||||
|
@ -248,7 +256,7 @@ scoped_timer::scoped_timer(unsigned ms, event_handler * eh) {
|
|||
if (ms != UINT_MAX && ms != 0)
|
||||
m_imp = alloc(imp, ms, eh);
|
||||
else
|
||||
m_imp = 0;
|
||||
m_imp = nullptr;
|
||||
}
|
||||
|
||||
scoped_timer::~scoped_timer() {
|
||||
|
|
|
@ -27,8 +27,8 @@ Revision History:
|
|||
|
||||
small_object_allocator::small_object_allocator(char const * id) {
|
||||
for (unsigned i = 0; i < NUM_SLOTS; i++) {
|
||||
m_chunks[i] = 0;
|
||||
m_free_list[i] = 0;
|
||||
m_chunks[i] = nullptr;
|
||||
m_free_list[i] = nullptr;
|
||||
}
|
||||
DEBUG_CODE({
|
||||
m_id = id;
|
||||
|
@ -60,8 +60,8 @@ void small_object_allocator::reset() {
|
|||
dealloc(c);
|
||||
c = next;
|
||||
}
|
||||
m_chunks[i] = 0;
|
||||
m_free_list[i] = 0;
|
||||
m_chunks[i] = nullptr;
|
||||
m_free_list[i] = nullptr;
|
||||
}
|
||||
m_alloc_size = 0;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ void small_object_allocator::deallocate(size_t size, void * p) {
|
|||
|
||||
|
||||
void * small_object_allocator::allocate(size_t size) {
|
||||
if (size == 0) return 0;
|
||||
if (size == 0) return nullptr;
|
||||
|
||||
#if defined(Z3DEBUG) && !defined(_WINDOWS)
|
||||
// Valgrind friendly
|
||||
|
@ -113,7 +113,7 @@ void * small_object_allocator::allocate(size_t size) {
|
|||
slot_id++;
|
||||
SASSERT(slot_id < NUM_SLOTS);
|
||||
SASSERT(slot_id > 0);
|
||||
if (m_free_list[slot_id] != 0) {
|
||||
if (m_free_list[slot_id] != nullptr) {
|
||||
void * r = m_free_list[slot_id];
|
||||
m_free_list[slot_id] = *(reinterpret_cast<void **>(r));
|
||||
return r;
|
||||
|
@ -121,7 +121,7 @@ void * small_object_allocator::allocate(size_t size) {
|
|||
chunk * c = m_chunks[slot_id];
|
||||
size = slot_id << PTR_ALIGNMENT;
|
||||
SASSERT(size >= osize);
|
||||
if (c != 0) {
|
||||
if (c != nullptr) {
|
||||
char * new_curr = c->m_curr + size;
|
||||
if (new_curr < c->m_data + CHUNK_SIZE) {
|
||||
void * r = c->m_curr;
|
||||
|
@ -142,7 +142,7 @@ size_t small_object_allocator::get_wasted_size() const {
|
|||
for (unsigned slot_id = 0; slot_id < NUM_SLOTS; slot_id++) {
|
||||
size_t slot_obj_size = slot_id << PTR_ALIGNMENT;
|
||||
void ** ptr = reinterpret_cast<void **>(const_cast<small_object_allocator*>(this)->m_free_list[slot_id]);
|
||||
while (ptr != 0) {
|
||||
while (ptr != nullptr) {
|
||||
r += slot_obj_size;
|
||||
ptr = reinterpret_cast<void**>(*ptr);
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ size_t small_object_allocator::get_num_free_objs() const {
|
|||
size_t r = 0;
|
||||
for (unsigned slot_id = 0; slot_id < NUM_SLOTS; slot_id++) {
|
||||
void ** ptr = reinterpret_cast<void **>(const_cast<small_object_allocator*>(this)->m_free_list[slot_id]);
|
||||
while (ptr != 0) {
|
||||
while (ptr != nullptr) {
|
||||
r ++;
|
||||
ptr = reinterpret_cast<void**>(*ptr);
|
||||
}
|
||||
|
@ -177,17 +177,17 @@ void small_object_allocator::consolidate() {
|
|||
ptr_vector<chunk> chunks;
|
||||
ptr_vector<char> free_objs;
|
||||
for (unsigned slot_id = 1; slot_id < NUM_SLOTS; slot_id++) {
|
||||
if (m_free_list[slot_id] == 0)
|
||||
if (m_free_list[slot_id] == nullptr)
|
||||
continue;
|
||||
chunks.reset();
|
||||
free_objs.reset();
|
||||
chunk * c = m_chunks[slot_id];
|
||||
while (c != 0) {
|
||||
while (c != nullptr) {
|
||||
chunks.push_back(c);
|
||||
c = c->m_next;
|
||||
}
|
||||
char * ptr = static_cast<char*>(m_free_list[slot_id]);
|
||||
while (ptr != 0) {
|
||||
while (ptr != nullptr) {
|
||||
free_objs.push_back(ptr);
|
||||
ptr = *(reinterpret_cast<char**>(ptr));
|
||||
}
|
||||
|
@ -198,8 +198,8 @@ void small_object_allocator::consolidate() {
|
|||
SASSERT(!chunks.empty());
|
||||
std::sort(chunks.begin(), chunks.end(), ptr_lt<chunk>());
|
||||
std::sort(free_objs.begin(), free_objs.end(), ptr_lt<char>());
|
||||
chunk * last_chunk = 0;
|
||||
void * last_free_obj = 0;
|
||||
chunk * last_chunk = nullptr;
|
||||
void * last_free_obj = nullptr;
|
||||
unsigned chunk_idx = 0;
|
||||
unsigned obj_idx = 0;
|
||||
unsigned num_chunks = chunks.size();
|
||||
|
|
|
@ -29,11 +29,21 @@ bool is_smt2_simple_symbol_char(char s) {
|
|||
}
|
||||
|
||||
bool is_smt2_quoted_symbol(char const * s) {
|
||||
if (s == 0)
|
||||
if (s == nullptr)
|
||||
return false;
|
||||
if ('0' <= s[0] && s[0] <= '9')
|
||||
return true;
|
||||
unsigned len = static_cast<unsigned>(strlen(s));
|
||||
if (len >= 2 && s[0] == '|' && s[len-1] == '|') {
|
||||
for (unsigned i = 1; i + 1 < len; i++) {
|
||||
if (s[i] == '\\' && i + 2 < len && (s[i+1] == '\\' || s[i+1] == '|')) {
|
||||
i++;
|
||||
}
|
||||
else if (s[i] == '\\' || s[i] == '|')
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
if (!is_smt2_simple_symbol_char(s[i]))
|
||||
return true;
|
||||
|
|
|
@ -24,6 +24,28 @@ Notes:
|
|||
#ifndef SORTING_NETWORK_H_
|
||||
#define SORTING_NETWORK_H_
|
||||
|
||||
enum sorting_network_encoding {
|
||||
grouped_at_most_1,
|
||||
bimander_at_most_1,
|
||||
ordered_at_most_1
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, sorting_network_encoding enc) {
|
||||
switch (enc) {
|
||||
case grouped_at_most_1: return out << "grouped";
|
||||
case bimander_at_most_1: return out << "bimander";
|
||||
case ordered_at_most_1: return out << "ordered";
|
||||
}
|
||||
return out << "???";
|
||||
}
|
||||
|
||||
struct sorting_network_config {
|
||||
sorting_network_encoding m_encoding;
|
||||
sorting_network_config() {
|
||||
m_encoding = grouped_at_most_1;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Ext>
|
||||
class sorting_network {
|
||||
typedef typename Ext::vector vect;
|
||||
|
@ -88,7 +110,7 @@ Notes:
|
|||
}
|
||||
|
||||
public:
|
||||
sorting_network(Ext& ext):
|
||||
sorting_network(Ext& ext):
|
||||
m_ext(ext),
|
||||
m_current(&m_currentv),
|
||||
m_next(&m_nextv)
|
||||
|
@ -119,8 +141,9 @@ Notes:
|
|||
// Described in Abio et.al. CP 2013.
|
||||
template<class psort_expr>
|
||||
class psort_nw {
|
||||
typedef typename psort_expr::literal literal;
|
||||
typedef typename psort_expr::literal_vector literal_vector;
|
||||
typedef typename psort_expr::pliteral literal;
|
||||
typedef typename psort_expr::pliteral_vector literal_vector;
|
||||
sorting_network_config m_cfg;
|
||||
|
||||
class vc {
|
||||
unsigned v; // number of vertices
|
||||
|
@ -187,6 +210,8 @@ Notes:
|
|||
|
||||
psort_nw(psort_expr& c): ctx(c) {}
|
||||
|
||||
sorting_network_config& cfg() { return m_cfg; }
|
||||
|
||||
literal ge(bool full, unsigned k, unsigned n, literal const* xs) {
|
||||
if (k > n) {
|
||||
return ctx.mk_false();
|
||||
|
@ -220,7 +245,17 @@ Notes:
|
|||
else if (k == 1) {
|
||||
literal_vector ors;
|
||||
// scoped_stats _ss(m_stats, k, n);
|
||||
return mk_at_most_1(full, n, xs, ors, false);
|
||||
switch (m_cfg.m_encoding) {
|
||||
case grouped_at_most_1:
|
||||
return mk_at_most_1(full, n, xs, ors, false);
|
||||
case bimander_at_most_1:
|
||||
return mk_at_most_1_bimander(full, n, xs, ors);
|
||||
case ordered_at_most_1:
|
||||
return mk_ordered_atmost_1(full, n, xs);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return xs[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
SASSERT(2*k <= n);
|
||||
|
@ -278,7 +313,7 @@ Notes:
|
|||
if (n == 1) {
|
||||
return ors[0];
|
||||
}
|
||||
literal result = fresh();
|
||||
literal result = fresh("or");
|
||||
add_implies_or(result, n, ors);
|
||||
add_or_implies(result, n, ors);
|
||||
return result;
|
||||
|
@ -293,15 +328,15 @@ Notes:
|
|||
}
|
||||
|
||||
void add_implies_and(literal l, literal_vector const& xs) {
|
||||
for (unsigned j = 0; j < xs.size(); ++j) {
|
||||
add_clause(ctx.mk_not(l), xs[j]);
|
||||
for (literal const& x : xs) {
|
||||
add_clause(ctx.mk_not(l), x);
|
||||
}
|
||||
}
|
||||
|
||||
void add_and_implies(literal l, literal_vector const& xs) {
|
||||
literal_vector lits;
|
||||
for (unsigned j = 0; j < xs.size(); ++j) {
|
||||
lits.push_back(ctx.mk_not(xs[j]));
|
||||
for (literal const& x : xs) {
|
||||
lits.push_back(ctx.mk_not(x));
|
||||
}
|
||||
lits.push_back(l);
|
||||
add_clause(lits);
|
||||
|
@ -317,15 +352,29 @@ Notes:
|
|||
if (ands.size() == 1) {
|
||||
return ands[0];
|
||||
}
|
||||
literal result = fresh();
|
||||
literal result = fresh("and");
|
||||
add_implies_and(result, ands);
|
||||
add_and_implies(result, ands);
|
||||
return result;
|
||||
}
|
||||
|
||||
literal mk_exactly_1(bool full, unsigned n, literal const* xs) {
|
||||
TRACE("pb", tout << "exactly 1 with " << n << " arguments " << (full?"full":"not full") << "\n";);
|
||||
literal_vector ors;
|
||||
literal r1 = mk_at_most_1(full, n, xs, ors, true);
|
||||
literal r1;
|
||||
switch (m_cfg.m_encoding) {
|
||||
case grouped_at_most_1:
|
||||
r1 = mk_at_most_1(full, n, xs, ors, true);
|
||||
break;
|
||||
case bimander_at_most_1:
|
||||
r1 = mk_at_most_1_bimander(full, n, xs, ors);
|
||||
break;
|
||||
case ordered_at_most_1:
|
||||
return mk_ordered_exactly_1(full, n, xs);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return mk_ordered_exactly_1(full, n, xs);
|
||||
}
|
||||
|
||||
if (full) {
|
||||
r1 = mk_and(r1, mk_or(ors));
|
||||
|
@ -337,15 +386,11 @@ Notes:
|
|||
}
|
||||
|
||||
literal mk_at_most_1(bool full, unsigned n, literal const* xs, literal_vector& ors, bool use_ors) {
|
||||
TRACE("pb", tout << (full?"full":"partial") << " ";
|
||||
TRACE("pb_verbose", tout << (full?"full":"partial") << " ";
|
||||
for (unsigned i = 0; i < n; ++i) tout << xs[i] << " ";
|
||||
tout << "\n";);
|
||||
|
||||
if (n >= 4 && false) {
|
||||
return mk_at_most_1_bimander(full, n, xs, ors);
|
||||
}
|
||||
literal_vector in(n, xs);
|
||||
literal result = fresh();
|
||||
literal result = fresh("at-most-1");
|
||||
unsigned inc_size = 4;
|
||||
literal_vector ands;
|
||||
ands.push_back(result);
|
||||
|
@ -387,7 +432,7 @@ Notes:
|
|||
|
||||
// xs[0] + ... + xs[n-1] <= 1 => and_x
|
||||
if (full) {
|
||||
literal and_i = fresh();
|
||||
literal and_i = fresh("and");
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
literal_vector lits;
|
||||
lits.push_back(and_i);
|
||||
|
@ -407,29 +452,6 @@ Notes:
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
literal result = fresh();
|
||||
|
||||
// result => xs[0] + ... + xs[n-1] <= 1
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
for (unsigned j = i + 1; j < n; ++j) {
|
||||
add_clause(ctx.mk_not(result), ctx.mk_not(xs[i]), ctx.mk_not(xs[j]));
|
||||
}
|
||||
}
|
||||
|
||||
// xs[0] + ... + xs[n-1] <= 1 => result
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
literal_vector lits;
|
||||
lits.push_back(result);
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
if (j != i) lits.push_back(xs[j]);
|
||||
}
|
||||
add_clause(lits);
|
||||
}
|
||||
|
||||
return result;
|
||||
#endif
|
||||
#if 1
|
||||
// r <=> and( or(!xi,!xj))
|
||||
//
|
||||
literal_vector ands;
|
||||
|
@ -439,30 +461,105 @@ Notes:
|
|||
}
|
||||
}
|
||||
return mk_and(ands);
|
||||
#else
|
||||
// r <=> or (and !x_{j != i})
|
||||
|
||||
literal_vector ors;
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
literal_vector ands;
|
||||
for (unsigned j = 0; j < n; ++j) {
|
||||
if (j != i) {
|
||||
ands.push_back(ctx.mk_not(xs[j]));
|
||||
}
|
||||
}
|
||||
ors.push_back(mk_and(ands));
|
||||
}
|
||||
return mk_or(ors);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
literal mk_ordered_exactly_1(bool full, unsigned n, literal const* xs) {
|
||||
return mk_ordered_1(full, true, n, xs);
|
||||
}
|
||||
|
||||
literal mk_ordered_atmost_1(bool full, unsigned n, literal const* xs) {
|
||||
return mk_ordered_1(full, false, n, xs);
|
||||
}
|
||||
|
||||
literal mk_ordered_1(bool full, bool is_eq, unsigned n, literal const* xs) {
|
||||
if (n <= 1 && !is_eq) {
|
||||
return ctx.mk_true();
|
||||
}
|
||||
if (n == 0) {
|
||||
return ctx.mk_false();
|
||||
}
|
||||
if (n == 1) {
|
||||
return xs[0];
|
||||
}
|
||||
|
||||
SASSERT(n > 1);
|
||||
|
||||
// y0 -> y1
|
||||
// x0 -> y0
|
||||
// x1 -> y1
|
||||
// r, y0 -> ~x1
|
||||
// r, y1 -> ~x2
|
||||
// r -> x3 | y1
|
||||
// r -> ~x3 | ~y1
|
||||
|
||||
// x0,x1,x2, .., x_{n-1}, x_n
|
||||
// y0,y1,y2, .., y_{n-1}
|
||||
// y_i -> y_{i+1} i = 0, ..., n - 2
|
||||
// x_i -> y_i i = 0, ..., n - 1
|
||||
// r, y_i -> ~x_{i+1} i = 0, ..., n - 1
|
||||
// exactly 1:
|
||||
// r -> x_n | y_{n-1}
|
||||
// full (exactly 1):
|
||||
// two_i -> y_i & x_{i+1}
|
||||
// zero -> ~x_n
|
||||
// zero -> ~y_{n-1}
|
||||
// r | zero | two_0 | ... | two_{n-1}
|
||||
// full atmost 1:
|
||||
// r | two | two_0 | ... | two_{n-1}
|
||||
|
||||
literal r = fresh("ordered");
|
||||
literal_vector ys;
|
||||
for (unsigned i = 0; i + 1 < n; ++i) {
|
||||
ys.push_back(fresh("y"));
|
||||
}
|
||||
for (unsigned i = 0; i + 2 < n; ++i) {
|
||||
add_clause(ctx.mk_not(ys[i]), ys[i + 1]);
|
||||
}
|
||||
for (unsigned i = 0; i + 1 < n; ++i) {
|
||||
add_clause(ctx.mk_not(xs[i]), ys[i]);
|
||||
add_clause(ctx.mk_not(r), ctx.mk_not(ys[i]), ctx.mk_not(xs[i + 1]));
|
||||
}
|
||||
|
||||
if (is_eq) {
|
||||
add_clause(ctx.mk_not(r), ys[n-2], xs[n-1]);
|
||||
}
|
||||
for (unsigned i = 1; i < n - 1; ++i) {
|
||||
add_clause(ctx.mk_not(ys[i]), xs[i], ys[i-1]);
|
||||
}
|
||||
|
||||
add_clause(ctx.mk_not(ys[0]), xs[0]);
|
||||
if (full) {
|
||||
literal_vector twos;
|
||||
for (unsigned i = 0; i < n - 1; ++i) {
|
||||
twos.push_back(fresh("two"));
|
||||
}
|
||||
add_clause(ctx.mk_not(twos[0]), ys[0]);
|
||||
add_clause(ctx.mk_not(twos[0]), xs[1]);
|
||||
for (unsigned i = 1; i < n - 1; ++i) {
|
||||
add_clause(ctx.mk_not(twos[i]), ys[i], twos[i-1]);
|
||||
add_clause(ctx.mk_not(twos[i]), xs[i + 1], twos[i-1]);
|
||||
}
|
||||
if (is_eq) {
|
||||
literal zero = fresh("zero");
|
||||
add_clause(ctx.mk_not(zero), ctx.mk_not(xs[n-1]));
|
||||
add_clause(ctx.mk_not(zero), ctx.mk_not(ys[n-2]));
|
||||
add_clause(r, zero, twos.back());
|
||||
}
|
||||
else {
|
||||
add_clause(r, twos.back());
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
literal mk_at_most_1_bimander(bool full, unsigned n, literal const* xs, literal_vector& ors) {
|
||||
if (full) {
|
||||
return mk_at_most_1(full, n, xs, ors, true);
|
||||
}
|
||||
literal_vector in(n, xs);
|
||||
literal result = fresh();
|
||||
literal result = fresh("bimander");
|
||||
unsigned inc_size = 2;
|
||||
literal_vector ands;
|
||||
for (unsigned i = 0; i < n; i += inc_size) {
|
||||
|
@ -477,7 +574,7 @@ Notes:
|
|||
}
|
||||
literal_vector bits;
|
||||
for (unsigned k = 0; k < nbits; ++k) {
|
||||
bits.push_back(fresh());
|
||||
bits.push_back(fresh("bit"));
|
||||
}
|
||||
for (unsigned i = 0; i < ors.size(); ++i) {
|
||||
for (unsigned k = 0; k < nbits; ++k) {
|
||||
|
@ -494,7 +591,7 @@ Notes:
|
|||
}
|
||||
|
||||
std::ostream& pp(std::ostream& out, literal_vector const& lits) {
|
||||
for (unsigned i = 0; i < lits.size(); ++i) ctx.pp(out, lits[i]) << " ";
|
||||
for (literal const& l : lits) ctx.pp(out, l) << " ";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -513,7 +610,7 @@ Notes:
|
|||
for (unsigned i = 0; i < N; ++i) {
|
||||
in.push_back(ctx.mk_not(xs[i]));
|
||||
}
|
||||
TRACE("pb",
|
||||
TRACE("pb_verbose",
|
||||
pp(tout << N << ": ", in);
|
||||
tout << " ~ " << k << "\n";);
|
||||
return true;
|
||||
|
@ -539,9 +636,9 @@ Notes:
|
|||
return ctx.mk_min(a, b);
|
||||
}
|
||||
|
||||
literal fresh() {
|
||||
literal fresh(char const* n) {
|
||||
m_stats.m_num_compiled_vars++;
|
||||
return ctx.fresh();
|
||||
return ctx.fresh(n);
|
||||
}
|
||||
void add_clause(literal l1, literal l2, literal l3) {
|
||||
literal lits[3] = { l1, l2, l3 };
|
||||
|
@ -558,7 +655,6 @@ Notes:
|
|||
m_stats.m_num_compiled_clauses++;
|
||||
m_stats.m_num_clause_vars += n;
|
||||
literal_vector tmp(n, ls);
|
||||
TRACE("pb", for (unsigned i = 0; i < n; ++i) tout << ls[i] << " "; tout << "\n";);
|
||||
ctx.mk_clause(n, tmp.c_ptr());
|
||||
}
|
||||
|
||||
|
@ -595,7 +691,7 @@ Notes:
|
|||
}
|
||||
|
||||
void card(unsigned k, unsigned n, literal const* xs, literal_vector& out) {
|
||||
TRACE("pb", 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);
|
||||
}
|
||||
|
@ -609,7 +705,7 @@ Notes:
|
|||
card(k, n-l, xs + l, out2);
|
||||
smerge(k, out1.size(), out1.c_ptr(), out2.size(), out2.c_ptr(), out);
|
||||
}
|
||||
TRACE("pb", 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";);
|
||||
|
||||
|
@ -637,7 +733,7 @@ Notes:
|
|||
void merge(unsigned a, literal const* as,
|
||||
unsigned b, literal const* bs,
|
||||
literal_vector& out) {
|
||||
TRACE("pb", tout << "merge a: " << a << " b: " << b << "\n";);
|
||||
TRACE("pb_verbose", tout << "merge a: " << a << " b: " << b << "\n";);
|
||||
if (a == 1 && b == 1) {
|
||||
literal y1 = mk_max(as[0], bs[0]);
|
||||
literal y2 = mk_min(as[0], bs[0]);
|
||||
|
@ -672,7 +768,7 @@ Notes:
|
|||
odd_b.size(), odd_b.c_ptr(), out2);
|
||||
interleave(out1, out2, out);
|
||||
}
|
||||
TRACE("pb", tout << "merge a: " << a << " b: " << b << "\n";
|
||||
TRACE("pb_verbose", tout << "merge a: " << a << " b: " << b << "\n";
|
||||
pp(tout << "a:", a, as) << "\n";
|
||||
pp(tout << "b:", b, bs) << "\n";
|
||||
pp(tout << "out:", out) << "\n";);
|
||||
|
@ -709,7 +805,7 @@ Notes:
|
|||
void interleave(literal_vector const& as,
|
||||
literal_vector const& bs,
|
||||
literal_vector& out) {
|
||||
TRACE("pb", tout << "interleave: " << as.size() << " " << bs.size() << "\n";);
|
||||
TRACE("pb_verbose", tout << "interleave: " << as.size() << " " << bs.size() << "\n";);
|
||||
SASSERT(as.size() >= bs.size());
|
||||
SASSERT(as.size() <= bs.size() + 2);
|
||||
SASSERT(!as.empty());
|
||||
|
@ -729,7 +825,7 @@ Notes:
|
|||
out.push_back(as[sz+1]);
|
||||
}
|
||||
SASSERT(out.size() == as.size() + bs.size());
|
||||
TRACE("pb", tout << "interleave: " << as.size() << " " << bs.size() << "\n";
|
||||
TRACE("pb_verbose", tout << "interleave: " << as.size() << " " << bs.size() << "\n";
|
||||
pp(tout << "a: ", as) << "\n";
|
||||
pp(tout << "b: ", bs) << "\n";
|
||||
pp(tout << "out: ", out) << "\n";);
|
||||
|
@ -741,7 +837,7 @@ Notes:
|
|||
|
||||
public:
|
||||
void sorting(unsigned n, literal const* xs, literal_vector& out) {
|
||||
TRACE("pb", tout << "sorting: " << n << "\n";);
|
||||
TRACE("pb_verbose", tout << "sorting: " << n << "\n";);
|
||||
switch(n) {
|
||||
case 0:
|
||||
break;
|
||||
|
@ -766,7 +862,7 @@ Notes:
|
|||
}
|
||||
break;
|
||||
}
|
||||
TRACE("pb", tout << "sorting: " << n << "\n";
|
||||
TRACE("pb_verbose", tout << "sorting: " << n << "\n";
|
||||
pp(tout << "in:", n, xs) << "\n";
|
||||
pp(tout << "out:", out) << "\n";);
|
||||
}
|
||||
|
@ -802,7 +898,7 @@ Notes:
|
|||
unsigned a, literal const* as,
|
||||
unsigned b, literal const* bs,
|
||||
literal_vector& out) {
|
||||
TRACE("pb", tout << "smerge: c:" << c << " a:" << a << " b:" << b << "\n";);
|
||||
TRACE("pb_verbose", tout << "smerge: c:" << c << " a:" << a << " b:" << b << "\n";);
|
||||
if (a == 1 && b == 1 && c == 1) {
|
||||
literal y = mk_max(as[0], bs[0]);
|
||||
if (m_t != GE) {
|
||||
|
@ -876,7 +972,7 @@ Notes:
|
|||
out.push_back(y);
|
||||
}
|
||||
}
|
||||
TRACE("pb", tout << "smerge: c:" << c << " a:" << a << " b:" << b << "\n";
|
||||
TRACE("pb_verbose", tout << "smerge: c:" << c << " a:" << a << " b:" << b << "\n";
|
||||
pp(tout << "a:", a, as) << "\n";
|
||||
pp(tout << "b:", b, bs) << "\n";
|
||||
pp(tout << "out:", out) << "\n";
|
||||
|
@ -920,12 +1016,12 @@ Notes:
|
|||
unsigned a, literal const* as,
|
||||
unsigned b, literal const* bs,
|
||||
literal_vector& out) {
|
||||
TRACE("pb", tout << "dsmerge: c:" << c << " a:" << a << " b:" << b << "\n";);
|
||||
TRACE("pb_verbose", tout << "dsmerge: c:" << c << " a:" << a << " b:" << b << "\n";);
|
||||
SASSERT(a <= c);
|
||||
SASSERT(b <= c);
|
||||
SASSERT(a + b >= c);
|
||||
for (unsigned i = 0; i < c; ++i) {
|
||||
out.push_back(fresh());
|
||||
out.push_back(fresh("dsmerge"));
|
||||
}
|
||||
if (m_t != GE) {
|
||||
for (unsigned i = 0; i < a; ++i) {
|
||||
|
@ -979,11 +1075,11 @@ Notes:
|
|||
|
||||
void dsorting(unsigned m, unsigned n, literal const* xs,
|
||||
literal_vector& out) {
|
||||
TRACE("pb", tout << "dsorting m: " << m << " n: " << n << "\n";);
|
||||
TRACE("pb_verbose", tout << "dsorting m: " << m << " n: " << n << "\n";);
|
||||
SASSERT(m <= n);
|
||||
literal_vector lits;
|
||||
for (unsigned i = 0; i < m; ++i) {
|
||||
out.push_back(fresh());
|
||||
out.push_back(fresh("dsort"));
|
||||
}
|
||||
if (m_t != GE) {
|
||||
for (unsigned k = 1; k <= m; ++k) {
|
||||
|
@ -1014,7 +1110,7 @@ Notes:
|
|||
|
||||
void add_subset(bool polarity, unsigned k, unsigned offset, literal_vector& lits,
|
||||
unsigned n, literal const* xs) {
|
||||
TRACE("pb", 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);
|
||||
if (k == 0) {
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
|
||||
|
||||
/*
|
||||
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
Copyright (c) 2018 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
nat_set.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Wrapper for sstream.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2013
|
||||
|
||||
Revision History:
|
||||
|
||||
Author: Leonardo de Moura
|
||||
*/
|
||||
#pragma once
|
||||
#include <sstream>
|
||||
|
|
|
@ -62,10 +62,10 @@ inline void stack::store_mark(void * ptr, bool external) {
|
|||
}
|
||||
|
||||
stack::stack() {
|
||||
m_curr_page = 0;
|
||||
m_curr_ptr = 0;
|
||||
m_curr_end_ptr = 0;
|
||||
m_free_pages = 0;
|
||||
m_curr_page = nullptr;
|
||||
m_curr_ptr = nullptr;
|
||||
m_curr_end_ptr = nullptr;
|
||||
m_free_pages = nullptr;
|
||||
allocate_page(0);
|
||||
SASSERT(empty());
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ inline void print_stat(std::ostream& out, char const* msg, unsigned num) {
|
|||
}
|
||||
|
||||
inline void print_stat_f(std::ostream& out, char const* msg, float num) {
|
||||
if (num > 0.0) {
|
||||
if (num > 0.0f) {
|
||||
out << msg << num << "\n";
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue