diff options
author | Linus Nordberg <linus@nordberg.se> | 2000-03-31 16:37:59 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2000-03-31 16:37:59 +0200 |
commit | 465819797953c9c202dbf79d08f29e92c4cc2fd4 (patch) | |
tree | e895b4d14e98bf8a0ff55e66689f5400e0e500af /mpz/urandomm.c | |
parent | 424e0c8c3989c55000e6fb99c3f037f1ab15ac65 (diff) | |
download | gmp-465819797953c9c202dbf79d08f29e92c4cc2fd4.tar.gz |
Rename urandomn.c to urandomm.c
Diffstat (limited to 'mpz/urandomm.c')
-rw-r--r-- | mpz/urandomm.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/mpz/urandomm.c b/mpz/urandomm.c new file mode 100644 index 000000000..1152c05f7 --- /dev/null +++ b/mpz/urandomm.c @@ -0,0 +1,54 @@ +/* urandomm (rop, state, n) -- Generate a uniform pseudorandom integer + in the range 0 to N-1, using STATE as the random state previously + initialized by a call to gmp_rand_init(). + +Copyright (C) 1999, 2000 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at your +option) any later version. + +The GNU MP Library 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 Library General Public +License for more details. + +You should have received a copy of the GNU Library General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "gmp.h" +#include "gmp-impl.h" + + +void +#if __STDC__ +mpz_urandomm (mpz_t rop, gmp_rand_state s, mpz_t n) +#else +mpz_urandomm (rop, s, n) + mpz_t rop; + gmp_rand_state s; + mpz_t n; +#endif +{ +#if 0 + mp_ptr rp; + mp_size_t size, bsize; + unsigned cnt; /* FIXME: type? */ + + rp = PTR (rop); + size = SIZ (n); + count_leading_zeros (cnt, rp[size - 1]); + bsize = BITS_PER_MP_LIMP * size - cnt; + + mpn_rawrandom (tp, bsize + 20, s); + MPN_NORMALIZE (tp, size); + SIZ (rop) = size; + + mpz_tdiv_r (rop, rop, n); /* reduce to spec'd interval */ +#endif +} |