version 1.1.1.1, 2000/09/09 14:13:00 |
version 1.1.1.3, 2003/08/25 16:06:34 |
|
|
integer in the range 0 to N-1, using STATE as the random state |
integer in the range 0 to N-1, using STATE as the random state |
previously initialized by a call to gmp_randinit(). |
previously initialized by a call to gmp_randinit(). |
|
|
Copyright (C) 2000 Free Software Foundation, Inc. |
Copyright 2000 Free Software Foundation, Inc. |
|
|
This file is part of the GNU MP Library. |
This file is part of the GNU MP Library. |
|
|
Line 26 MA 02111-1307, USA. */ |
|
Line 26 MA 02111-1307, USA. */ |
|
#include "longlong.h" |
#include "longlong.h" |
|
|
void |
void |
#if __STDC__ |
mpz_urandomm (mpz_ptr rop, gmp_randstate_t rstate, mpz_srcptr n) |
mpz_urandomm (mpz_t rop, gmp_randstate_t rstate, mpz_t n) |
|
#else |
|
mpz_urandomm (rop, rstate, n) |
|
mpz_t rop; |
|
gmp_randstate_t rstate; |
|
mpz_t n; |
|
#endif |
|
{ |
{ |
mpz_t t, p, m; |
mpz_t t, p, m; |
mp_ptr tp; |
mp_ptr tp; |
mp_size_t nbits, size; |
mp_size_t nbits, size; |
int count; |
int count; |
|
TMP_DECL (marker); |
|
|
|
TMP_MARK (marker); |
|
|
/* FIXME: Should check for n == 0 and report error */ |
/* FIXME: Should check for n == 0 and report error */ |
|
|
size = SIZ (n); |
size = SIZ (n); |
Line 70 mpz_urandomm (rop, rstate, n) |
|
Line 66 mpz_urandomm (rop, rstate, n) |
|
while (mpz_cmp (t, p) >= 0); |
while (mpz_cmp (t, p) >= 0); |
|
|
mpz_mod (rop, t, n); |
mpz_mod (rop, t, n); |
|
|
|
TMP_FREE (marker); |
} |
} |