You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2016/01/17 11:42:04 UTC

[15/22] [math] Reverting commit 4fc5b3402c58d6a4b317bf23b896ea91d22af6fe as per Gilles request.

Reverting commit 4fc5b3402c58d6a4b317bf23b896ea91d22af6fe as per Gilles request.

The work on revamping the random packages is perfoemd in the random-ravamp branch.


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

Branch: refs/heads/master
Commit: a4456b8fd51adf73e007cb7d598bf2feb3e4f6df
Parents: 56888aa
Author: Luc Maisonobe <lu...@apache.org>
Authored: Sun Jan 17 11:35:25 2016 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Sun Jan 17 11:40:27 2016 +0100

----------------------------------------------------------------------
 .../commons/math4/random/MersenneTwister.java   | 41 +++++++-------------
 1 file changed, 13 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/a4456b8f/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 1228b4e..709c343 100644
--- a/src/main/java/org/apache/commons/math4/random/MersenneTwister.java
+++ b/src/main/java/org/apache/commons/math4/random/MersenneTwister.java
@@ -111,7 +111,7 @@ public class MersenneTwister
      */
     public MersenneTwister() {
         mt = new int[N];
-        setSeedInternal(System.currentTimeMillis() + System.identityHashCode(this));
+        setSeed(System.currentTimeMillis() + System.identityHashCode(this));
     }
 
     /** Creates a new random number generator using a single int seed.
@@ -119,7 +119,7 @@ public class MersenneTwister
      */
     public MersenneTwister(int seed) {
         mt = new int[N];
-        setSeedInternal(seed);
+        setSeed(seed);
     }
 
     /** Creates a new random number generator using an int array seed.
@@ -128,7 +128,7 @@ public class MersenneTwister
      */
     public MersenneTwister(int[] seed) {
         mt = new int[N];
-        setSeedInternal(seed);
+        setSeed(seed);
     }
 
     /** Creates a new random number generator using a single long seed.
@@ -136,25 +136,7 @@ public class MersenneTwister
      */
     public MersenneTwister(long seed) {
         mt = new int[N];
-        setSeedInternal(seed);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void setSeed(int seed) {
-        setSeedInternal(seed);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void setSeed(int[] seed) {
-        setSeedInternal(seed);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public void setSeed(long seed) {
-        setSeedInternal(seed);
+        setSeed(seed);
     }
 
     /** Reinitialize the generator as if just built with the given int seed.
@@ -162,7 +144,8 @@ public class MersenneTwister
      * generator built with the same seed.</p>
      * @param seed the initial seed (32 bits integer)
      */
-    private void setSeedInternal(int seed) {
+    @Override
+    public void setSeed(int seed) {
         // we use a long masked by 0xffffffffL as a poor man unsigned int
         long longMT = seed;
         // NB: unlike original C code, we are working with java longs, the cast below makes masking unnecessary
@@ -184,14 +167,15 @@ public class MersenneTwister
      * the seed of the generator will be the current system time plus the
      * system identity hash code of this instance
      */
-    private void setSeedInternal(int[] seed) {
+    @Override
+    public void setSeed(int[] seed) {
 
         if (seed == null) {
-            setSeedInternal(System.currentTimeMillis() + System.identityHashCode(this));
+            setSeed(System.currentTimeMillis() + System.identityHashCode(this));
             return;
         }
 
-        setSeedInternal(19650218);
+        setSeed(19650218);
         int i = 1;
         int j = 0;
 
@@ -233,8 +217,9 @@ public class MersenneTwister
      * generator built with the same seed.</p>
      * @param seed the initial seed (64 bits integer)
      */
-    private void setSeedInternal(long seed) {
-        setSeedInternal(new int[] { (int) (seed >>> 32), (int) (seed & 0xffffffffl) });
+    @Override
+    public void setSeed(long seed) {
+        setSeed(new int[] { (int) (seed >>> 32), (int) (seed & 0xffffffffl) });
     }
 
     /**