commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [04/18] [math] MATH-1307
Date Mon, 28 Dec 2015 17:23:16 GMT
MATH-1307

Extends new base class.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/87497c72
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/87497c72
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/87497c72

Branch: refs/heads/master
Commit: 87497c72460c9c58f829a372d741b386fc2ac8f8
Parents: 6f4f676
Author: Gilles <erans@apache.org>
Authored: Mon Dec 28 16:47:52 2015 +0100
Committer: Gilles <erans@apache.org>
Committed: Mon Dec 28 16:47:52 2015 +0100

----------------------------------------------------------------------
 .../commons/math4/random/MersenneTwister.java       | 16 ++++++++--------
 .../commons/math4/random/MersenneTwisterTest.java   |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/87497c72/src/main/java/org/apache/commons/math4/random/MersenneTwister.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/MersenneTwister.java b/src/main/java/org/apache/commons/math4/random/MersenneTwister.java
index c84ff8c..d8caaa7 100644
--- a/src/main/java/org/apache/commons/math4/random/MersenneTwister.java
+++ b/src/main/java/org/apache/commons/math4/random/MersenneTwister.java
@@ -83,10 +83,12 @@ import org.apache.commons.math4.util.FastMath;
  * @since 2.0
 
  */
-public class MersenneTwister extends BitsStreamGenerator implements Serializable {
+public class MersenneTwister
+    extends BaseRandomGenerator
+    implements Serializable {
 
     /** Serializable version identifier. */
-    private static final long serialVersionUID = 8661194735290153518L;
+    private static final long serialVersionUID = 20151228L;
 
     /** Size of the bytes pool. */
     private static final int   N     = 624;
@@ -224,13 +226,13 @@ public class MersenneTwister extends BitsStreamGenerator implements
Serializable
      * <p>This method is the core generation algorithm. It is used by all the
      * public generation methods for the various primitive types {@link
      * #nextBoolean()}, {@link #nextBytes(byte[])}, {@link #nextDouble()},
-     * {@link #nextFloat()}, {@link #nextGaussian()}, {@link #nextInt()},
-     * {@link #next(int)} and {@link #nextLong()}.</p>
+     * {@link #nextFloat()}, {@link #nextGaussian()} and {@link #nextLong()}.
+     * </p>
      * @param bits number of random bits to produce
      * @return random bits generated
      */
     @Override
-    protected int next(int bits) {
+    public int nextInt() {
 
         int y;
 
@@ -262,8 +264,6 @@ public class MersenneTwister extends BitsStreamGenerator implements Serializable
         y ^= (y <<  15) & 0xefc60000;
         y ^=  y >>> 18;
 
-        return y >>> (32 - bits);
-
+        return y;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/87497c72/src/test/java/org/apache/commons/math4/random/MersenneTwisterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/MersenneTwisterTest.java b/src/test/java/org/apache/commons/math4/random/MersenneTwisterTest.java
index 1446003..7c55d6a 100644
--- a/src/test/java/org/apache/commons/math4/random/MersenneTwisterTest.java
+++ b/src/test/java/org/apache/commons/math4/random/MersenneTwisterTest.java
@@ -21,7 +21,7 @@ import org.apache.commons.math4.random.RandomGenerator;
 import org.junit.Assert;
 import org.junit.Test;
 
-public class MersenneTwisterTest extends RandomGeneratorAbstractTest {
+public class MersenneTwisterTest extends BaseRandomGeneratorTest {
 
     @Override
     protected RandomGenerator makeGenerator() {


Mime
View raw message