mirror of
https://github.com/vale981/arb
synced 2025-03-06 01:41:39 -05:00
86 lines
2.5 KiB
C
86 lines
2.5 KiB
C
/*=============================================================================
|
|
|
|
This file is part of ARB.
|
|
|
|
ARB is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
ARB is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with ARB; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
=============================================================================*/
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2012, 2013 Fredrik Johansson
|
|
|
|
******************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
#include "bernoulli.h"
|
|
|
|
int main()
|
|
{
|
|
long iter;
|
|
flint_rand_t state;
|
|
|
|
printf("fmprb_ui....");
|
|
fflush(stdout);
|
|
|
|
flint_randinit(state);
|
|
|
|
for (iter = 0; iter < 10000; iter++)
|
|
{
|
|
fmprb_t b1, b2;
|
|
ulong n;
|
|
long prec1, prec2, acc1, acc2;
|
|
|
|
n = n_randint(state, 10000);
|
|
prec1 = 2 + n_randint(state, 10000);
|
|
prec2 = prec1 + 100;
|
|
|
|
fmprb_init(b1);
|
|
fmprb_init(b2);
|
|
|
|
bernoulli_fmprb_ui(b1, n, prec1);
|
|
bernoulli_fmprb_ui(b2, n, prec2);
|
|
|
|
if (!fmprb_overlaps(b1, b2))
|
|
{
|
|
printf("FAIL: overlap\n\n");
|
|
printf("n = %lu\n\n", n);
|
|
printf("b1 = "); fmprb_print(b1); printf("\n\n");
|
|
printf("b2 = "); fmprb_print(b2); printf("\n\n");
|
|
abort();
|
|
}
|
|
|
|
acc1 = fmprb_rel_accuracy_bits(b1);
|
|
acc2 = fmprb_rel_accuracy_bits(b2);
|
|
|
|
if (acc1 < prec1 - 2 || acc2 < prec2 - 2)
|
|
{
|
|
printf("FAIL: poor accuracy\n\n");
|
|
printf("prec1 = %ld\n", prec1);
|
|
printf("prec2 = %ld\n", prec2);
|
|
printf("b1 = "); fmprb_printd(b1, prec1 / 3.33); printf("\n\n");
|
|
printf("b2 = "); fmprb_printd(b2, prec2 / 3.33); printf("\n\n");
|
|
abort();
|
|
}
|
|
|
|
fmprb_clear(b1);
|
|
fmprb_clear(b2);
|
|
}
|
|
|
|
flint_randclear(state);
|
|
_fmpz_cleanup();
|
|
printf("PASS\n");
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|