mirror of
https://github.com/vale981/arb
synced 2025-03-05 17:31:38 -05:00
slightly stronger test code for fmpr_normalise
This commit is contained in:
parent
2fb26f42ca
commit
605e503325
1 changed files with 30 additions and 4 deletions
|
@ -38,19 +38,27 @@ int main()
|
|||
|
||||
for (iter = 0; iter < 1000000; iter++)
|
||||
{
|
||||
fmpr_t x, y;
|
||||
long prec, ret1, ret2;
|
||||
fmpr_t x, xcopy, y, err_bound, err;
|
||||
long prec, ret1, ret2, bits, ebits;
|
||||
fmpr_rnd_t rnd;
|
||||
|
||||
fmpr_init(x);
|
||||
fmpr_init(xcopy);
|
||||
fmpr_init(y);
|
||||
fmpr_init(err_bound);
|
||||
fmpr_init(err);
|
||||
|
||||
fmpz_randtest(fmpr_manref(x), state, 2000);
|
||||
fmpz_randtest(fmpr_expref(x), state, 200);
|
||||
bits = 2 + n_randint(state, 2000);
|
||||
ebits = 2 + n_randint(state, 200);
|
||||
|
||||
fmpz_randtest_not_zero(fmpr_manref(x), state, bits);
|
||||
fmpz_randtest(fmpr_expref(x), state, ebits);
|
||||
|
||||
fmpz_set(fmpr_manref(y), fmpr_manref(x));
|
||||
fmpz_set(fmpr_expref(y), fmpr_expref(x));
|
||||
|
||||
fmpr_set(xcopy, x);
|
||||
|
||||
switch (n_randint(state, 4))
|
||||
{
|
||||
case 0: rnd = FMPR_RND_DOWN; break;
|
||||
|
@ -73,8 +81,26 @@ int main()
|
|||
abort();
|
||||
}
|
||||
|
||||
fmpr_sub(err, x, xcopy, FMPR_PREC_EXACT, FMPR_RND_DOWN);
|
||||
fmpr_abs(err, err);
|
||||
fmpr_set_error_result(err_bound, x, ret1);
|
||||
|
||||
if (fmpr_cmp(err, err_bound) > 0)
|
||||
{
|
||||
printf("FAIL (error bound)!\n");
|
||||
printf("x (original) = "); fmpr_print(xcopy); printf("\n\n");
|
||||
printf("x = "); fmpr_print(x); printf("\n\n");
|
||||
printf("error: "); fmpr_print(err); printf("\n\n");
|
||||
printf("error bound: "); fmpr_print(err_bound); printf("\n\n");
|
||||
printf("ret = %ld\n", ret1);
|
||||
abort();
|
||||
}
|
||||
|
||||
fmpr_clear(x);
|
||||
fmpr_clear(xcopy);
|
||||
fmpr_clear(y);
|
||||
fmpr_clear(err_bound);
|
||||
fmpr_clear(err);
|
||||
}
|
||||
|
||||
flint_randclear(state);
|
||||
|
|
Loading…
Add table
Reference in a new issue