test(numerics): add test to make sure that zeros of different precision mpfp numbers are the equal.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
467eff4662
commit
ff04c5a2e2
1 changed files with 18 additions and 0 deletions
|
@ -37,10 +37,28 @@ static void tst1() {
|
||||||
std::cout << "exp(b, UP ) = |" << exp(b, MPFR_RNDU) << "|" << std::endl;
|
std::cout << "exp(b, UP ) = |" << exp(b, MPFR_RNDU) << "|" << std::endl;
|
||||||
std::cout << "exp(b, NEAR) = |" << exp(b, MPFR_RNDN) << "|" << std::endl;
|
std::cout << "exp(b, NEAR) = |" << exp(b, MPFR_RNDN) << "|" << std::endl;
|
||||||
std::cout << "exp(b, DOWN) = |" << exp(b, MPFR_RNDD) << "|" << std::endl;
|
std::cout << "exp(b, DOWN) = |" << exp(b, MPFR_RNDD) << "|" << std::endl;
|
||||||
|
|
||||||
|
mpfp d = mpfp(6.141592, 512);
|
||||||
|
std::cout << "d = |" << d << "|" << std::endl;
|
||||||
|
std::cout << "exp(d, UP ) = |" << exp(d, MPFR_RNDU) << "|" << std::endl;
|
||||||
|
std::cout << "exp(d, NEAR) = |" << exp(d, MPFR_RNDN) << "|" << std::endl;
|
||||||
|
std::cout << "exp(d, DOWN) = |" << exp(d, MPFR_RNDD) << "|" << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tst2() {
|
||||||
|
mpfp a(10.0, 64);
|
||||||
|
mpfp b(10.0, 128);
|
||||||
|
lean_assert(a == b);
|
||||||
|
for (unsigned i = 16; i < 256; i++) {
|
||||||
|
for (unsigned j = 16; j < 256; j++) {
|
||||||
|
lean_assert_eq(mpfp(0.0, i), mpfp(0.0, j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
tst1();
|
tst1();
|
||||||
|
tst2();
|
||||||
return has_violations() ? 1 : 0;
|
return has_violations() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue