arb/arb_poly/randtest.c
2012-04-07 20:38:35 +02:00

50 lines
1.7 KiB
C

/*=============================================================================
This file is part of FLINT.
FLINT 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.
FLINT 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 FLINT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2012 Fredrik Johansson
******************************************************************************/
#include "arb_poly.h"
void
arb_poly_randtest(arb_poly_t x, flint_rand_t state, long len, long exp_bits)
{
long i;
_arb_poly_fit_length(x, len);
for (i = 0; i < len; i++)
fmpz_randtest(arb_poly_coeffs(x) + i, state, arb_poly_prec(x));
x->length = len;
if (n_randint(state, 4) == 0)
fmpz_zero(arb_poly_radref(x));
else
{
fmpz_randtest(arb_poly_radref(x), state, arb_poly_prec(x));
fmpz_abs(arb_poly_radref(x), arb_poly_radref(x));
}
if (n_randint(state, 4) == 0)
fmpz_zero(arb_poly_expref(x));
else
fmpz_randtest(arb_poly_expref(x), state, exp_bits);
}