3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-11 09:44:43 +00:00

rp precise

This commit is contained in:
Lev Nachmanson 2023-03-07 08:20:32 -08:00
parent 569f5be91f
commit 9ec82632a3
15 changed files with 48 additions and 350 deletions

View file

@ -70,19 +70,12 @@ lp_status lp_status_from_string(std::string status) {
template <typename T>
bool vectors_are_equal(T * a, vector<T> &b, unsigned n) {
if (numeric_traits<T>::precise()) {
for (unsigned i = 0; i < n; i ++){
if (!numeric_traits<T>::is_zero(a[i] - b[i])) {
return false;
}
}
} else {
for (unsigned i = 0; i < n; i ++){
if (std::abs(numeric_traits<T>::get_double(a[i] - b[i])) > 0.000001) {
return false;
}
}
}
return true;
}
@ -91,27 +84,12 @@ template <typename T>
bool vectors_are_equal(const vector<T> & a, const vector<T> &b) {
unsigned n = static_cast<unsigned>(a.size());
if (n != b.size()) return false;
if (numeric_traits<T>::precise()) {
for (unsigned i = 0; i < n; i ++){
if (!numeric_traits<T>::is_zero(a[i] - b[i])) {
return false;
}
}
} else {
for (unsigned i = 0; i < n; i ++){
double da = numeric_traits<T>::get_double(a[i]);
double db = numeric_traits<T>::get_double(b[i]);
double amax = std::max(fabs(da), fabs(db));
if (amax > 1) {
da /= amax;
db /= amax;
}
if (fabs(da - db) > 0.000001) {
return false;
}
}
}
return true;
}
#ifdef Z3DEBUG