summaryrefslogtreecommitdiff
path: root/randlc2x.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2000-04-01 16:00:06 +0200
committerLinus Nordberg <linus@nordberg.se>2000-04-01 16:00:06 +0200
commit85d25c7fe115730bcb1ef1a017a764acb15f51d4 (patch)
treedd4c7fb7d069c2c9018e8dd98a2ad3960f8d1075 /randlc2x.c
parent3513f4430fc55c130f48a5685c3599584eda158f (diff)
downloadgmp-85d25c7fe115730bcb1ef1a017a764acb15f51d4.tar.gz
New file.
Diffstat (limited to 'randlc2x.c')
-rw-r--r--randlc2x.c57
1 files changed, 57 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;
+}