Reverting commit ffae3bdbb6
as per Gilles request.
The work on revamping the random packages is perfoemd in the random-ravamp branch.
This commit is contained in:
parent
7c31eb6634
commit
df46ed5edd
|
@ -34,12 +34,10 @@ import org.apache.commons.math4.util.FastMath;
|
|||
* @see <a href="http://www.iro.umontreal.ca/~panneton/WELLRNG.html">WELL Random number generator</a>
|
||||
* @since 2.2
|
||||
*/
|
||||
public abstract class AbstractWell
|
||||
extends BaseRandomGenerator
|
||||
implements Serializable {
|
||||
public abstract class AbstractWell extends BitsStreamGenerator implements Serializable {
|
||||
|
||||
/** Serializable version identifier. */
|
||||
private static final long serialVersionUID = 20150228L;
|
||||
private static final long serialVersionUID = 20150223L;
|
||||
|
||||
/** Current index in the bytes pool. */
|
||||
protected int index;
|
||||
|
@ -135,6 +133,10 @@ public abstract class AbstractWell
|
|||
setSeed(new int[] { (int) (seed >>> 32), (int) (seed & 0xffffffffl) });
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected abstract int next(final int bits);
|
||||
|
||||
/** Calculate the number of 32-bits blocks.
|
||||
* @param k number of bits in the pool (not necessarily a multiple of 32)
|
||||
* @return the number of 32-bits blocks
|
||||
|
|
|
@ -16,18 +16,15 @@
|
|||
*/
|
||||
package org.apache.commons.math4.random;
|
||||
|
||||
/**
|
||||
* This class implements the WELL1024a pseudo-random number generator
|
||||
/** This class implements the WELL1024a pseudo-random number generator
|
||||
* from François Panneton, Pierre L'Ecuyer and Makoto Matsumoto.
|
||||
*
|
||||
* <p>
|
||||
* This generator is described in a paper by François Panneton,
|
||||
* Pierre L'Ecuyer and Makoto Matsumoto
|
||||
* <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf">
|
||||
* Improved Long-Period Generators Based on Linear Recurrences Modulo 2</a>
|
||||
* ACM Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper
|
||||
* are in <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng-errata.txt">wellrng-errata.txt</a>.
|
||||
* </p>
|
||||
* Pierre L'Ecuyer and Makoto Matsumoto <a
|
||||
* href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf">Improved
|
||||
* Long-Period Generators Based on Linear Recurrences Modulo 2</a> ACM
|
||||
* Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper
|
||||
* are in <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng-errata.txt">wellrng-errata.txt</a>.</p>
|
||||
*
|
||||
* @see <a href="http://www.iro.umontreal.ca/~panneton/WELLRNG.html">WELL Random number generator</a>
|
||||
* @since 2.2
|
||||
|
@ -84,7 +81,8 @@ public class Well1024a extends AbstractWell {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int nextInt() {
|
||||
protected int next(final int bits) {
|
||||
|
||||
final int indexRm1 = TABLE.getIndexPred(index);
|
||||
|
||||
final int v0 = v[index];
|
||||
|
@ -102,6 +100,8 @@ public class Well1024a extends AbstractWell {
|
|||
v[indexRm1] = z4;
|
||||
index = indexRm1;
|
||||
|
||||
return z4;
|
||||
return z4 >>> (32 - bits);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class Well19937a extends AbstractWell {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int nextInt() {
|
||||
protected int next(final int bits) {
|
||||
|
||||
final int indexRm1 = TABLE.getIndexPred(index);
|
||||
final int indexRm2 = TABLE.getIndexPred2(index);
|
||||
|
@ -103,6 +103,8 @@ public class Well19937a extends AbstractWell {
|
|||
v[indexRm2] &= 0x80000000;
|
||||
index = indexRm1;
|
||||
|
||||
return z4;
|
||||
return z4 >>> (32 - bits);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class Well19937c extends AbstractWell {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int nextInt() {
|
||||
protected int next(final int bits) {
|
||||
|
||||
final int indexRm1 = TABLE.getIndexPred(index);
|
||||
final int indexRm2 = TABLE.getIndexPred2(index);
|
||||
|
@ -108,6 +108,8 @@ public class Well19937c extends AbstractWell {
|
|||
z4 ^= (z4 << 7) & 0xe46e1700;
|
||||
z4 ^= (z4 << 15) & 0x9b868000;
|
||||
|
||||
return z4;
|
||||
return z4 >>> (32 - bits);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class Well44497a extends AbstractWell {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int nextInt() {
|
||||
protected int next(final int bits) {
|
||||
|
||||
final int indexRm1 = TABLE.getIndexPred(index);
|
||||
final int indexRm2 = TABLE.getIndexPred2(index);
|
||||
|
@ -105,6 +105,8 @@ public class Well44497a extends AbstractWell {
|
|||
v[indexRm2] &= 0xFFFF8000;
|
||||
index = indexRm1;
|
||||
|
||||
return z4;
|
||||
return z4 >>> (32 - bits);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class Well44497b extends AbstractWell {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int nextInt() {
|
||||
protected int next(final int bits) {
|
||||
|
||||
// compute raw value given by WELL44497a generator
|
||||
// which is NOT maximally-equidistributed
|
||||
|
@ -112,6 +112,8 @@ public class Well44497b extends AbstractWell {
|
|||
z4 ^= (z4 << 7) & 0x93dd1400;
|
||||
z4 ^= (z4 << 15) & 0xfa118000;
|
||||
|
||||
return z4;
|
||||
return z4 >>> (32 - bits);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class Well512a extends AbstractWell {
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int nextInt() {
|
||||
protected int next(final int bits) {
|
||||
|
||||
final int indexRm1 = TABLE.getIndexPred(index);
|
||||
|
||||
|
@ -101,6 +101,8 @@ public class Well512a extends AbstractWell {
|
|||
v[indexRm1] = z4;
|
||||
index = indexRm1;
|
||||
|
||||
return z4;
|
||||
return z4 >>> (32 - bits);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.random.Well1024a;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Well1024aTest extends BaseRandomGeneratorTest {
|
||||
public class Well1024aTest extends RandomGeneratorAbstractTest {
|
||||
|
||||
@Override
|
||||
protected RandomGenerator makeGenerator() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.random.Well19937a;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Well19937aTest extends BaseRandomGeneratorTest {
|
||||
public class Well19937aTest extends RandomGeneratorAbstractTest {
|
||||
|
||||
@Override
|
||||
public RandomGenerator makeGenerator() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.random.Well19937c;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Well19937cTest extends BaseRandomGeneratorTest {
|
||||
public class Well19937cTest extends RandomGeneratorAbstractTest {
|
||||
|
||||
@Override
|
||||
public RandomGenerator makeGenerator() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.random.Well44497a;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Well44497aTest extends BaseRandomGeneratorTest {
|
||||
public class Well44497aTest extends RandomGeneratorAbstractTest {
|
||||
|
||||
@Override
|
||||
public RandomGenerator makeGenerator() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.random.Well44497b;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Well44497bTest extends BaseRandomGeneratorTest {
|
||||
public class Well44497bTest extends RandomGeneratorAbstractTest {
|
||||
|
||||
@Override
|
||||
public RandomGenerator makeGenerator() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.random.Well512a;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Well512aTest extends BaseRandomGeneratorTest {
|
||||
public class Well512aTest extends RandomGeneratorAbstractTest {
|
||||
|
||||
@Override
|
||||
public RandomGenerator makeGenerator() {
|
||||
|
|
Loading…
Reference in New Issue