summaryrefslogtreecommitdiff
path: root/randmt.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-03-29 00:14:21 +0100
committerKevin Ryde <user42@zip.com.au>2003-03-29 00:14:21 +0100
commit62d2fd3454539dacc3322ea3edc9e2418b90f48d (patch)
tree46e41b58fa39e8407e75324f6b8066f56c9948f4 /randmt.c
parente5cb6a48690c3d418ecdb7afb723eaa304aa9640 (diff)
downloadgmp-62d2fd3454539dacc3322ea3edc9e2418b90f48d.tar.gz
* randlc2x.c, randmt.c: Add gmp_randinit_set support.
Diffstat (limited to 'randmt.c')
-rw-r--r--randmt.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/randmt.c b/randmt.c
index bb6ae6aa0..11379abc0 100644
--- a/randmt.c
+++ b/randmt.c
@@ -1,6 +1,6 @@
/* Mersenne Twister pseudo-random number generator functions.
-Copyright 2002 Free Software Foundation, Inc.
+Copyright 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -472,13 +472,34 @@ randclear_mt (gmp_randstate_t rstate)
sizeof (gmp_rand_mt_struct));
}
+static void randiset_mt __GMP_PROTO ((gmp_randstate_ptr dst, gmp_randstate_srcptr src));
static const gmp_randfnptr_t Mersenne_Twister_Generator = {
randseed_mt,
randget_mt,
- randclear_mt
+ randclear_mt,
+ randiset_mt
};
+static void
+randiset_mt (gmp_randstate_ptr dst, gmp_randstate_srcptr src)
+{
+ gmp_rand_mt_struct *dstp, *srcp;
+ int i;
+
+ srcp = (gmp_rand_mt_struct *) RNG_STATE (src);
+ dstp = (*__gmp_allocate_func) (sizeof (gmp_rand_mt_struct));
+
+ RNG_STATE (dst) = (void *) dstp;
+ RNG_FNPTR (dst) = (void *) &Mersenne_Twister_Generator;
+
+ for (i = 0; i < N; i++)
+ dstp->mt[i] = srcp->mt[i];
+
+ dstp->mti = srcp->mti;
+}
+
+
/* Initialize MT-specific data. */
void
gmp_randinit_mt (gmp_randstate_t rstate)