diff options
author | Linus Nordberg <linus@nordberg.se> | 2000-04-01 16:00:06 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2000-04-01 16:00:06 +0200 |
commit | 85d25c7fe115730bcb1ef1a017a764acb15f51d4 (patch) | |
tree | dd4c7fb7d069c2c9018e8dd98a2ad3960f8d1075 | |
parent | 3513f4430fc55c130f48a5685c3599584eda158f (diff) | |
download | gmp-85d25c7fe115730bcb1ef1a017a764acb15f51d4.tar.gz |
New file.
-rw-r--r-- | randlc2x.c | 57 | ||||
-rw-r--r-- | randsd.c | 37 | ||||
-rw-r--r-- | randsdui.c | 37 |
3 files changed, 131 insertions, 0 deletions
diff --git a/randlc2x.c b/randlc2x.c new file mode 100644 index 000000000..e9412ff60 --- /dev/null +++ b/randlc2x.c @@ -0,0 +1,57 @@ +/* gmp_rand_init_lc_2exp (state, a, c, m2exp) -- Initialize random + state STATE for a linear congruental generator with multiplier A, + adder C, and modulus 2 ^ M2EXP. + +Copyright (C) 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__ +gmp_rand_init_lc_2exp (gmp_rand_state s, + mpz_t a, + unsigned long int c, + unsigned long int m2exp) +#else +gmp_rand_init_lc_2exp (s, a, c, m2exp) + gmp_rand_state s; + mpz_t a; + unsigned long int c; + unsigned long int m2exp; +#endif +{ + mpz_init_set_ui (s->seed, 0); + + /* Allocate algorithm specific data. */ + s->data.lc = (__gmp_rand_data_lc *) + (*_mp_allocate_func) (sizeof (__gmp_rand_data_lc)); + + mpz_init_set (s->data.lc->a, a); + s->data.lc->c = c; + + /* Cover weird case where m2exp is 0, which means that m is used + instead of m2exp. */ + if (m2exp == 0) + mpz_init_set_ui (s->data.lc->m, 0); + s->data.lc->m2exp = m2exp; + + s->alg = GMP_RAND_ALG_LC; +} diff --git a/randsd.c b/randsd.c new file mode 100644 index 000000000..7200833af --- /dev/null +++ b/randsd.c @@ -0,0 +1,37 @@ +/* gmp_rand_seed (state, seed) -- Set initial seed SEED in random + state STATE. + +Copyright (C) 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__ +gmp_rand_seed (gmp_rand_state s, + mpz_t seed) +#else +gmp_rand_seed (s, seed) + gmp_rand_state s; + mpz_t seed; +#endif +{ + mpz_set (s->seed, seed); +} diff --git a/randsdui.c b/randsdui.c new file mode 100644 index 000000000..788ff25fb --- /dev/null +++ b/randsdui.c @@ -0,0 +1,37 @@ +/* gmp_rand_seed_ui (state, seed) -- Set initial seed SEED in random + state STATE. + +Copyright (C) 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__ +gmp_rand_seed_ui (gmp_rand_state s, + unsigned long int seed) +#else +gmp_rand_seed_ui (s, seed) + gmp_rand_state s; + mpz_t seed; +#endif +{ + mpz_set_ui (s->seed, seed); +} |