1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.rng.core.source32;
18
19 /**
20 * This class implements the WELL44497b pseudo-random number generator
21 * from François Panneton, Pierre L'Ecuyer and Makoto Matsumoto.
22 * <p>
23 * This generator is described in a paper by François Panneton,
24 * Pierre L'Ecuyer and Makoto Matsumoto
25 * <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf">
26 * Improved Long-Period Generators Based on Linear Recurrences Modulo 2</a>
27 * ACM Transactions on Mathematical Software, 32, 1 (2006).
28 * The errata for the paper are in
29 * <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng-errata.txt">wellrng-errata.txt</a>.
30 * </p>
31 *
32 * @see <a href="http://www.iro.umontreal.ca/~panneton/WELLRNG.html">WELL Random number generator</a>
33 * @since 1.0
34 */
35 public class Well44497b extends Well44497a {
36 /**
37 * Creates a new random number generator.
38 *
39 * @param seed Initial seed.
40 */
41 public Well44497b(int[] seed) {
42 super(seed);
43 }
44
45 /** {@inheritDoc} */
46 @Override
47 public int next() {
48 int z4 = super.next();
49
50 // Matsumoto-Kurita tempering to get a maximally equidistributed generator.
51 z4 ^= (z4 << 7) & 0x93dd1400;
52 z4 ^= (z4 << 15) & 0xfa118000;
53
54 return z4;
55 }
56 }