1 /*
2     Copyright (C) 2014 Fredrik Johansson
3 
4     This file is part of Arb.
5 
6     Arb is free software: you can redistribute it and/or modify it under
7     the terms of the GNU Lesser General Public License (LGPL) as published
8     by the Free Software Foundation; either version 2.1 of the License, or
9     (at your option) any later version.  See <http://www.gnu.org/licenses/>.
10 */
11 
12 #include "arf.h"
13 
14 void
arf_randtest(arf_t x,flint_rand_t state,slong bits,slong mag_bits)15 arf_randtest(arf_t x, flint_rand_t state, slong bits, slong mag_bits)
16 {
17     fmpz_t t;
18     fmpz_init(t);
19     fmpz_randtest(t, state, bits);
20     arf_set_fmpz(x, t);
21     if (!arf_is_zero(x))
22         fmpz_randtest(ARF_EXPREF(x), state, mag_bits);
23     fmpz_clear(t);
24 }
25 
26 void
arf_randtest_not_zero(arf_t x,flint_rand_t state,slong bits,slong mag_bits)27 arf_randtest_not_zero(arf_t x, flint_rand_t state, slong bits, slong mag_bits)
28 {
29     fmpz_t t;
30     fmpz_init(t);
31     fmpz_randtest_not_zero(t, state, bits);
32     arf_set_fmpz(x, t);
33     fmpz_randtest(ARF_EXPREF(x), state, mag_bits);
34     fmpz_clear(t);
35 }
36 
37 void
arf_randtest_special(arf_t x,flint_rand_t state,slong bits,slong mag_bits)38 arf_randtest_special(arf_t x, flint_rand_t state, slong bits, slong mag_bits)
39 {
40     switch (n_randint(state, 32))
41     {
42         case 0:
43             arf_zero(x);
44             break;
45         case 1:
46             arf_pos_inf(x);
47             break;
48         case 2:
49             arf_neg_inf(x);
50             break;
51         case 3:
52             arf_nan(x);
53             break;
54         default:
55             arf_randtest_not_zero(x, state, bits, mag_bits);
56     }
57 }
58 
59