commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [01/53] [math] MATH-1335.
Date Fri, 25 Mar 2016 15:18:46 GMT
Repository: commons-math
Updated Branches:
  refs/heads/feature-MATH-1158 [created] ae2c81ad1


http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/test/java/org/apache/commons/math4/rng/internal/source32/Well44497bTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/rng/internal/source32/Well44497bTest.java b/src/test/java/org/apache/commons/math4/rng/internal/source32/Well44497bTest.java
new file mode 100644
index 0000000..b850be5
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/rng/internal/source32/Well44497bTest.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.rng.internal.source32;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Well44497bTest {
+    @Test
+    public void testReferenceCode() {
+        final int[] base = {
+            740849862,  1202665156,  -199039369,  -259008301,  -291878969, -1164428990, -1565918811,   491009864,
+            -1883086670,  1383450241,  1244617256,   689006653, -1576746370, -1307940314,  1421489086,  1742094000,
+            -595495729,  1047766204,  1875773301, -1637793284,  1379017098,   262792705,   191880010,  -251000180,
+            -1753047622,  -972355720,    90626881,  1644693418,  1503365577,   439653419,  1806361562,  1268823869
+        };
+        final int[] init = new int[1391];
+        for (int i = 0; i < init.length; ++i) {
+            init[i] = base[i % base.length] + i;
+        }
+
+        final Well44497b rng = new Well44497b(init);
+
+        final int[] refInt = {
+            -102003638,  -1254584449,    836441550,   1949705484,    653000494,   1579400718,    699652570,   -140738233,   1164288466,    419933874,    366568847,    780567309,   1867405910,   -350557801,   -964350642,  -1323492759,
+            191502468,    398676344,   1568976991,   1005053759,    199053603,     31083944,     74697788,  -1343941248,  -1205631880,  -1637961625,    361813531,  -1706096179,   -403340909,   1666226814,  -2034962600,   1237102662,
+            -1833248535,   1584255126,   1295661745,  -1753848945,   1208145993,    930278953,   -733716134,    192752767,   1692463060,   1727273316,   2122952931,   -809025255,   -992081044,   -895539688,   -419372543,  -1835478922,
+            2089629419,   1646590742,  -1261083717,  -1005462992,   1619627287,  -1437723182,   1619689210,   1319393089,  -1816963183,   -150214444,   -513482220,   1897815796,  -1861960936,  -1766444468,   2034653890,    585657634,
+            1867016559,    696942260,  -1536237241,   -527055447,  -1554805020,  -1063992566,   1024799415,   1782080572,  -1884276362,    129028272,   1427925968,  -1154222271,  -1383146732,  -1580532830,  -1907049616,   -104299169,
+            -1780913000,  -2090815339,  -1789809502,  -1521443849,   1226625769,   1126090676,  -2117094290,   -449575109,   -218982833,   -695554478,     35923022,   1386126825,    -95031305,   -168657023,    436674049,  -1137917876,
+            -2045134053,  -1025629865,    133144659,     64226081,  -1966942130,    700813483,    344058910,   -910646033,   -212789479,    740360859,  -1269028713,   1517763679,   -664178514,   -683718472,    -71951996,     86583727,
+            -1235669348,  -1426987265,   -166598353,    214190040,  -1436967644,    233824411,    710927452,  -1939548641,   -433607408,  -1075939594,  -1549702826,  -1310827917,   -640604762,   -696863672,  -1282162126,   -546470833,
+            -1516734192,   -513809904,   -458526835,    708926727,   -476643096,  -2108375037,     -2870478,  -1460116421,    436587555,   -948939610,   1891375124,   1944216545,    959034236,  -1267038790,  -1695098736,   1853748495,
+            1594424552,   1270099319,   1139585482,   1837434635,   -709909535,   -457524230,   -887118113,   -241703912,  -1888225819,   -751575804,   1122280146,   1194255209,    949350188,    892826516,   -791212042,   -151203035,
+            -859297731,  -1979039938,    323603119,  -1022065097,  -1804294506,   -385802891,  -2127523442,   -720380255,  -1315859127,    999649487,    335041941,  -1732821688,  -1833409827,    535715225,  -1285355653,   1206723386,
+            -1141619270,    759796285,  -1599504546,  -1988521411,   1056668895,   -852564594,   1056509609,  -1831687977,    754168875,  -1301144422,    922880446,  -1502666503,   -949791898,  -1043870198,  -1136941938,  -1649670259,
+            1342769348,   1692605059,   -132279148,  -1108038310,    -14355545,  -1611387086,   1651826569,    877600127,   1356160799,   -759125205,  -1300490081,   -414938486,   -201479285,   1958709363,   1513313540,  -1396836908,
+            1352702612,   1142506253,     52969438,   -365142357,  -1619054179,  -1368514102,   1470750417,  -1420830959,   -843909462,  -1679570143,   1447444607,    234551752,  -1507452115,  -1433234579,   -680890000,   -497305145,
+            860408898,    263376761,   1537070218,   -592353956,   1587852989,   1756653749,  -2081320633,  -1547020311,    723771611,   -883819383,   1899879513,   -268417584,   1058606451,   1665941493,  -1630340612,   -614737477,
+            891313237,   1368950660,  -1166187089,    296322368,  -1908770726,  -2120378408,   1245479677,   1879710487,  -1705947124,   1018371589,  -1715010575,  -1096078094,  -1749891454,   2130888667,    318647750,    554592231,
+            -489121568,  -1809605233,  -1697905160,   -953926536,  -2013960553,   -148884919,   1822739964,  -1466301760,    141999978,   1946526064,   1323036718,    864390149,  -2141665227,   1510602225,   1468408474,   1277039721,
+            -1368096647,    180965986,   2140852057,   -688071899,    819713016,   -154385940,  -1182972611,   1257224305,   1392607672,   1364245931,  -1768434401,    323522132,   -555278604,    474186520,  -1178901665,  -2137343658,
+            1636421121,   1398987084,   1276656225,   1013316006,   -955917865,  -1537149363,   -179145358,    342862050,   1172728007,    736300054,  -1114656959,  -1831840325,  -1882353535,   -442915191,  -1206488416,  -1818534411,
+            25312311,   2100297098,  -1562767719,   1762553519,  -1853194231,  -1152612739,  -2020055792,   -809572150,    848584579,   -535789699,   1817604709,   1343773216,   -602234204,   1739930964,   -833790834,    501215449,
+            -730104057,   1217783189,   -681773267,   -611951354,    978387629,  -1516811237,    974303980,  -1389665696,   2091099075,   -727528826,   2116026151,    271935854,    613242379,  -2100429856,    190004963,  -1629612570,
+            -1362888327,    175094223,   -917873219,  -2008308245,   -401946815,    504218792,  -1966525201,      4106248,    164895454,    226502921,    655865257,   -610528718,    189428750,   1055978898,     17603028,    591024369,
+            1127922501,  -1546639293,   1994174637,   -724136988,   -673919372,  -1665002120,   -612145705,   -793102882,  -1904763558,    757565058,  -2091240021,  -2123324826,  -1518702766,   -802889839,   -223045921,  -1509216579,
+            1195556261,   2079259971,   -903969953,  -1781800655,   1834950463,   -956531922,  -1152550807,  -1116052662,   -348802884,  -1395330117,    -91758501,    -19115285,   1926930669,  -1015793599,    545904386,   1617858191,
+            716963473,   1917089719,   -980914811,   -212646927,  -1634695647,  -1857924568,  -1462257477,   1273750178,   1060328454,   -361604424,    867932749,    451213698,    405780152,   1165233215,   1877230909,   2103114395,
+            1644330815,   1252998537,   1961603970,  -1533101488,   1790456024,    -38226118,  -1306744489,    713676418,  -1535871838,   1378109935,   -338185548,   1647669762,   -477465913,    203482277,  -1949756706,   -503326093,
+           -638704909,    320186309,  -1435581459,    907446649,    -77384645,    537368928,   -335347295,  -1912061924,    547819174,   -225549827,   1089455486,    463516297,   -240127764,    -85895271,   2053179697,   -287394931,
+            921878827,   -933362608,  -1178670275,  -1200942874,   -672571265,    574422382,   1441734039,  -1814493454,    165751640,   -176907245,  -1170992192,  -2123252090,  -1435971541,   1591853830,   -885477992,   -792847559,
+            1359875286,   1038392904,  -2027255124,    687291425,   -165513490,   1391146576,  -1387080955,    794663652,   -807189965,    667820962,   -545384499,  -1371368854,   -689031878,   1504805541,   -752825823,  -1920047745,
+            -1884874017,   -350566320,   -197152911,   -181743050,   -798415949,   -915922276,   1790690149,   -363997181,   1923116185,  -1326427198,  -1621079427,  -1997440997,   1798118127,  -2053110382,   -159879848,  -1286787216,
+            1046436411,   1832030471,   -389092059,     71686169,    -76025260,   1914270607,   1854169353,    872157826,  -1774323792,   -575165717,  -1919931724,   2051498109,  -1176174934,   -883578901,  -1253047270,  -1310573900,
+            245466682,  -1784824328,  -1319912821,   1377340217,   1364313761,   -408687373,    142333378,  -1952335763,  -1703126184,    316314678,   2030555423,    488640834,  -1783293306,   2116925005,   -428337460,    -42966447,
+            -476226114,   -325172903,  -1690748475,    852791569,     26490302,     85251337,  -1374975770,   -376283969,    982639600,    595119792,    376403422,   1574509912,  -1509664496,  -1901241749,    -59019104,    358566667,
+            341667214,    184541206,   -550950854,  -1897143732,   1595753537,  -1236127928,   2014297822,  -2033179270,   -669806121,  -1927596980,   1010735700,   -581795164,   1922398838,  -1456743538,  -1633813803,    323177707,
+            2002098813,  -2099067658,    277393729,   -671911622,   -384463053,   2028267908,    367391785,   1270052637,   -172839030,   -650486693,   -831800809,  -1255138113,   -137512799,   1904317942,     -8229811,    707361898,
+            -276859812,     50417442,   1487081728,   1577776181,   1994451303,   1237303035,   -602016235,  -1905218276,  -1895725672,   1172978849,    801129953,  -1819485071,   -587985848,  -2010386741,  -1645226427,   -850866837,
+            816998708,    357665811,   1955856762,   1617902189,  -1013761306,    146782652,    904185608,   -500146809,   2085848310,   1917713975,  -1823786899,   1994184748,    789196322,   1766857258,   1770685286,     58213029,
+            -1699628994,    346827379,  -1274423227,     -5079670,   -193099487,   1020296939,  -1795904054,  -1951053094,    -43782418,   -375403393,   1026761026,   -207269610,   1364563521,   1578793454,    457809423,   -534138380,
+            -1052938788,  -1897101526,   1449976516,   2052800058,  -1145169719,   1476303269,    370625650,   -325249282,      2165984,   1631432802,   1032336355,  -1292978191,  -1810172401,    725725820,  -1162678778,    702624490,
+            1387673527,    981825943,   -556408212,  -1108487850,  -1782136935,   1582316425,  -1752682164,    307235003,   1386486299,  -1343636074,   1936875586,  -1265279891,   -345847069,    928241171,    239050350,   1859358526,
+            -664776217,   -823267892,    346651710,   -867656288,  -1907921425,   1362445801,    541145461,   -192727350,   1649366606,    244694627,   -488180018,    214008256,   2032125437,  -1678591993,   -264593820,   1309017286,
+            -652451998,   1845366657,   -703990120,   -550186406,   -630285276,   1782372955,   1650564210,  -1127904234,  -1407983860,  -1119422877,  -1565976361,  -1913545385,    549841420,  -1410323732,  -1964467146,    228296551,
+            -421026422,   1929094398,   -266906424,    264810315,  -2008122665,  -1088278148,    141242192,   1871293282,    234634067,   1724159838,   1638271051,   -837713428,   -657941661,    168093988,    708605363,  -1881612509,
+            -1810496006,   -193495322,   1889982309,  -2050702012,   -693694192,  -1249780322,    718733403,    -76349730,   -188217051,    920912090,  -1814078273,   2013358456,  -1948845521,   -198407575,  -1248904632,   1182772565,
+            1236791612,  -1297489171,  -1958468586,   1437011007,    390460941,    113068796,   1247982993,   2102889679,  -1563524844,   -128174212,   -754095070,  -1461699362,    943615640,  -1013270737,    221253920,   1514140013,
+            1596946745,    674222984,    616356702,   1811224435,  -1764322023,  -1653707581,  -1702404459,    390678142,   -209506765,  -1398278531,   -117061517,   1625861343,    659048069,  -1490678943,    846536668,    210715637,
+            1855458786,   1727745280,   1086729456,   1109111683,   -985298098,  -1813777567,   -954599702,  -1522494031,   1166103515,   -191868965,  -1048777852,   -661271058,   1161457421,   1509090409,   -919753558,   -155431193,
+            -1774302994,   -366390263,   2090138916,   -693431491,  -1693888428,   1846774454,    925855693,    474383470,    208889079,    382195164,   -283005634,  -2095134392,    579927985,   1390765326,  -1766119865,    900457129,
+            -1503703236,    974952690,   -107714111,    381338452,   1187256613,   -860560742,    524103620,   1499506130,    197755276,   -790802926,   -406920967,  -1972219791,   -665721155,   -113336203,   1037154436,  -1185441801,
+            -745541706,   -546274471,   1988928457,  -1975403782,  -1167172845,    777779004,  -1560935061,   -140258712,  -1243598232,  -1394149587,   -785002782,    311842991,  -1025469277,   -605350463,  -1251538057,    537203966,
+            597777961,  -1845767072,  -1556349193,  -1491015509,  -1935936671,   2093498487,   1908270236,   -315396187,   1356362300,  -2025658518,    630119678,    276190559,    510123398,  -1266145363,   -170152124,   -151540077,
+            -477900187,   1895894303,   1870333068,  -1169891437,    353366620,   2111175941,   1691245786,   1318765802,    -90993610,    921309517,    118241505,    367005284,   1624861072,   2010785894,    865255951,   1717799691,
+            -80757664,   -644944841,    136999836,   -341686875,  -1908076090,  -1968934200,   -346397811,   -184213520,   -511811333,  -2118173466,  -1086490399,   1795322855,   -635494328,    415716276,    851044432,   -904636831,
+            -1972230341,    -64337858,    571177016,   1248814747,  -1351030778,    457872680,   1843549954,   1718960038,    815088665,   1812961065,    360686952,  -1356586646,   1657802416,   1776192945,   -786723490,   -342254407,
+            -236653811,    771014701,    906386785,   -308057635,   1907957462,    206000440,    -42143480,    900403654,   -917549795,   -310520796,  -1713627766,   2061136240,   -377977839,    891282946,   -821163030,    328143584,
+            1503793080,    551621842,  -2086273683,  -2070526343,     91195293,  -1654389038,  -1035734266,   -336619597,  -1220221027,  -1468468844,   2105626873,   -841372573,   -122707018,  -2013073683,    494461000,  -2054807734,
+            -67946259,   1914163407,   1941835405,  -1027244745,   -768123277,    419129844,   -275750260,   -171533009,     97756174,    -17651409,  -1578102255,    995291430,  -1587462977,    692904675,    951632643,   1882101293,
+            -1546298756,   2018418068,  -1790777661,   1542305514,  -1437624383,    469587009,  -1647853474,  -1318279028,    497228822,    726733469,   1693133452,  -2091185798,   -209017732,    126386499,   1056958932,  -2105494133,
+            754067324,     96463951,     83701151,   1101658289,   1485852701,    553783806,   1898769881,  -1072031442,   1438062141,   1992540265,   1152252136,   1019391719,   -175951257,     -6691216,    989789689,    968359367,
+            -1330392786,   1704963399,   -998432914,   -948060232,  -1921688855,   -975840920,   1360273515,   -872810459,     12676907,  -1908050756,    883609616,     65641549,   -200365398,   1386653304,  -1203665071,   1878689007,
+            426262328,    315375145,   1900325181,    703658494,   -765404895,   1070155172,   1399748900,   -804264234,  -1619419026,   1347225486,    230635292,   1093717835,     14020583,  -2107039873,   -968325341,  -1679158691,
+            1959784097,   1065690797,   1090615161,   1311445364,    865835426,    870016646,    574122879,   1842697922,  -1289210431,  -1914001560,   1672467629,   -900366331,  -1524066872,    136503816,  -1910431892,  -1431958329,
+            -830367152,  -1316233970,   -801974860,   1560669382,    -81784810,    401822577,   -949103202,    943897151,   -722666726,    -96825841,  -1092898846,    230567004,    -70355840,  -1398069192,   -312953142,   1475420133,
+            -622491023,   1661205388,    -19071322,      6024591,   1473041593,   2053897978,  -1346768903,   1484764721,  -1552461890,   1287146711,   1613069307,    902497864,  -1504480063,    375292915,   -836353108,   2047602411
+        };
+
+        for (int i = 0; i < refInt.length; ++i) {
+            Assert.assertEquals(refInt[i], rng.nextInt());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/test/java/org/apache/commons/math4/rng/internal/source32/Well512aTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/rng/internal/source32/Well512aTest.java b/src/test/java/org/apache/commons/math4/rng/internal/source32/Well512aTest.java
new file mode 100644
index 0000000..a1eb7ca
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/rng/internal/source32/Well512aTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.rng.internal.source32;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Well512aTest {
+    @Test
+    public void testReferenceCode() {
+        final Well512a rng = new Well512a(new int[] {
+                740849862,  1202665156,  -199039369,  -259008301,  -291878969, -1164428990, -1565918811,   491009864,
+                -1883086670,  1383450241,  1244617256,   689006653, -1576746370, -1307940314,  1421489086,  1742094000
+            });
+
+        final int[] refInt = {
+            1634813289,   1876773016,   -973836208,  -2130023652,  -1045460084,  -1834384857,   1691032973,    609714289,
+            2033920362,    555915483,      6680992,   1958127415,   1866469645,  -1471336965,   2049178762,   -192324811,
+            -2056050066,    810879705,   1405046309,   -781317118,   1012782311,  -1045081032,    728377508,   1473511660,
+            290489070,    326666761,   2018299979,  -1876688058,   1239968501,   1464625040,   2025151042,   -101397407,
+            1387902041,    210959839,   1366359326,   -476473433,    153180037,  -1607631523,   -506743495,     17888738,
+            313865008,   -340504498,    586684079,   1243699375,    753162229,   -646761694,   -739189655,   -210120185,
+            -1856358726,   -628255542,  -1812798197,   1416288088,   1077967722,   -846846208,   1379850409,   -580183344,
+            -1858959,    210859778,    295841424,   1492774865,  -1415543680,   -344870570,  -1942779197,   1549510646,
+            -389544849,    314254218,     11784988,  -1311757368,   1719514841,   -764610517,   1296788970,   -994707050,
+            783854563,    422654144,    387639079,   1219688425,   2144352572,   -834212874,  -1036550358,    935909479,
+            -568610842,   1327498837,   -588933178,   1910065754,    -40851599,   -182063170,   1302731458,    541311559,
+            -1647345522,    805224371,  -1721196679,   1518507830,   -952689880,   -433276260,    509675254,   -777259954,
+            1277810106,    284054896,    936042202,   2036836351,   1956412426,  -1186403024,    287795400,   2135311211,
+            720485927,   1500695024,   -281656583,  -1277937322,  -1628968482,   1242814831,  -2030700974,   1473867890,
+            440813549,  -1357033971,     28384076,   1602731216,   -641465746,   -609054347,    635938444,   1472898176,
+            1476894555,   -747974186,  -1590337055,   -884242108,   -389736197,  -2066984505,   1087103272,  -1236446290,
+            31657463,   1835715432,   -468439078,  -2132633204,   -434609235,    258308151,   1851926761,  -1630139159,
+            -1344617241,   1969204215,    619463174,   -174392624,    207475487,  -1619828078,   1327980298,    -83968178,
+            445951782,  -1786230541,      6279288,   -580982231,   1550645552,   2006533941,    275746007,    455676647,
+            2019637349,   1115547704,  -1313120106,   -516213449,     73752461,  -1382448112,    398589620,   1319888048,
+            -1595572334,   1566934536,  -1735685764,  -1509545339,   1458173912,   -549395819,   -618827040,   1516624531,
+            1900757187,  -1454200688,    965524719,    488355065,  -1869294316,   -810641680,  -2059428251,   1454656431,
+            1329120541,   -232185900,   -994996943,   1855980910,   -452077812,   1565630611,    759842266,   1241435187,
+            -1390456063,   1946400597,  -2032319771,    683667881,    905911106,   1983310786,    120010546,    526018017,
+            -1946881912,    205004987,  -1307250612,   2130980818,   2052864161,    189839787,   1789478047,    406168885,
+            -1145186347,      8507675,   1277188815,   1492619042,   2009819675,  -1627411598,   -851016743,  -1828234956,
+            1962622506,   2140398255,    236935165,   -337237772,   1263419111,    516775236,   -335741025,   1391328225,
+            455979249,  -1457534664,   -657606241,    485648133,   1762116343,   1194889600,    817834937,    321150162,
+            131159182,    290277758,  -1876924740,  -1770401129,   1291602973,  -1003642974,  -1580211929,   1520422021,
+            -399171579,    -24315308,    453805396,   -659197747,   -205656847,    466526550,   1444397201,   1178091401,
+            -1157268826,   -602394028,  -1370668795,   1614896435,   1699071659,   1864753793,   1888518358,  -1721244514,
+            1812776767,    668822227,   -297283057,   2130183333,  -1169618692,    912860240,  -2028253096,   1244694278
+        };
+
+        for (int i = 0; i < refInt.length; ++i) {
+            Assert.assertEquals(refInt[i], rng.nextInt());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/test/java/org/apache/commons/math4/rng/internal/source64/MersenneTwister64Test.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/rng/internal/source64/MersenneTwister64Test.java b/src/test/java/org/apache/commons/math4/rng/internal/source64/MersenneTwister64Test.java
new file mode 100644
index 0000000..dd3ffca
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/rng/internal/source64/MersenneTwister64Test.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.rng.internal.source64;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MersenneTwister64Test {
+    @Test
+    public void testMakotoNishimura() {
+        final MersenneTwister64 rng = new MersenneTwister64(new long[] { 0x12345L, 0x23456L, 0x34567L, 0x45678L });
+
+        /*
+         * Data from
+         *   http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/mt19937-64.out.txt
+         * converted to hexadecimal.
+         */
+        final long[] refLong = {
+            0x64d79b552a559d7fL, 0x44a572665a6ee240L, 0xeb2bf6dc3d72135cL, 0xe3836981f9f82ea0L, 0x43a38212350ee392L, 
+            0xce77502bffcacf8bL, 0x5d8a82d90126f0e7L, 0xc0510c6f402c1e3cL, 0x48d895bf8b69f77bL, 0x8d9fbb371f1de07fL, 
+            0x1126b97be8c91ce2L, 0xf05e1c9dc2674be2L, 0xe4d5327a12874c1eL, 0x7c1951ea43a7500dL, 0xbba2bbfbecbc239aL, 
+            0xc5704350b17f0215L, 0x823a67c5f88337e7L, 0xd9bf140bfeb4c1a9L, 0x9fbe3cfcd1f08059L, 0xdc29309412e352b9L, 
+            0x5a0ff7908b1b3c57L, 0x46f39cb43b126c55L, 0x9648168491f3b126L, 0xdd3e72538fd39a1cL, 0xd65a3663fc9b0898L, 
+            0x421ee7823c2af2ebL, 0xcba3a4b69b6ed152L, 0x348399b7d2b8428L, 0xbdb750bf00c34a38L, 0xcf36d95eae514f52L, 
+            0x7b9231d5308d7534L, 0xb225e28cfc5aa663L, 0xa833f6d5c72448a4L, 0xdaa565f5815de899L, 0x4b051d1e4cc78eb8L, 
+            0x97fcd1b4d342e575L, 0xef6a48be001729c7L, 0x3982f1fa31afeab8L, 0xfdc570ba2fe979fbL, 0xb57697121dfdfe93L, 
+            0x96524e209b767c29L, 0x55aad0ebca994043L, 0xb22687b88856b63eL, 0xb313b667a4d999d6L, 0x7c7fa1bd6fd7deaL, 
+            0xee9f4c15c57e92aL, 0xc5fb71b8f4bf5f56L, 0xa251f93a4b335492L, 0xb9bad7f9e5b07befL, 0x62fc9ac35ccde7aaL, 
+            0x933792382b0218a3L, 0x7d497d2f7a15eaf8L, 0xb2f0624214f522a2L, 0xd9895bbb810ec3d6L, 0x22d91b683f251121L, 
+            0xc8fe9a347247affdL, 0x3462898a2ae7b001L, 0x468bc3a10a34890cL, 0x84ff6ce56552b185L, 0xed95ff232c511188L, 
+            0x4869be47a8137c83L, 0x934606951e6fcd81L, 0x1ab5e8e453bde710L, 0x6386b61b30fa1157L, 0x97f3a778e242d0cfL, 
+            0xd870d281b293af3dL, 0xc3a5f903a836fafdL, 0x88bd6a24d49cd77L, 0x4e38ddc2719162a5L, 0xf48286b4f22cad94L, 
+            0x80f6f650c337557L, 0x5e6daf6aae1ad59L, 0x7450f7229f336762L, 0xb75b43fb4c81784aL, 0xebd37a514f153148L, 
+            0xd4b3a39e0bc52c7L, 0x562f36fae610a2e1L, 0xe0e413e555bd736L, 0xd452549efe08402dL, 0xf2e2ff7be2c75e21L, 
+            0xf2385606c18aaf0dL, 0xdb609b507d8c6b8bL, 0x74ac5663c6c4f45bL, 0xd84c9a356858060L, 0x19d5b3643bc029b6L, 
+            0xdd8131e97ffc842L, 0xfa7303606bfffc05L, 0xf98c6d63ff48a16eL, 0x34df46aa2d610767L, 0x83490ef054537f7eL, 
+            0xe071f833e55ebfe6L, 0xd4b94537ed4a6aaL, 0x3cf85e4e333966fdL, 0xba15364649384016L, 0xc0e6bd623ca72405L, 
+            0xdae6e879b8eab74aL, 0xe4a41f17e70d3e0aL, 0x56e10c00dd580f70L, 0xa9a66bb41781d872L, 0x58e42dbdffe21573L, 
+            0x69450e1ce9674e6aL, 0x47fe345a350aa605L, 0xac958aa80455a5a4L, 0xbc1abca3fbeeb2f3L, 0x8f760d9228900a4L, 
+            0x9e1eb8a2dfec4387L, 0xe91bd1321f5fdc89L, 0xda11a24c514b9dc7L, 0xb1f63d976e0e639bL, 0x41c11098f6123861L, 
+            0x3d7736979f978f68L, 0x820685b38c926beL, 0xe8c3dcab075b112L, 0x5e37299d89089ba4L, 0xa1f735eb8235b32fL, 
+            0x2289d719e7b146eeL, 0x1c9c9d0284d96719L, 0x5f8b358546775be8L, 0x317e34c009a07a39L, 0xb16b073eb0ee0a19L, 
+            0x423b36fd459f2a66L, 0x5f45053666f3f84fL, 0x63e7074f03c73d92L, 0x22080cf23288e895L, 0xba4e71bf61dac16fL, 
+            0x9643b3707db2cfb5L, 0x98e2db6c665e7178L, 0xcbc57de0ef3eabb6L, 0x6239a2197582a8a8L, 0xf2ae968e55fda13dL, 
+            0x36e7ac11d1f3a617L, 0x508f0acb609bd756L, 0x6f42d435193a1ac2L, 0x2df2cab9d65e0b00L, 0x4584c1fde5f1ad55L, 
+            0x602c500bdc8317c2L, 0xc80d5b04f6337337L, 0x98abcf971892a773L, 0x5d33cf557e6c4475L, 0x5b5a78be74ccd40L, 
+            0x3ec2cce5290785f4L, 0x2eef1e9c4b36828bL, 0xdd274241a0ce8c55L, 0x3c4cb919b35c221cL, 0xc1fd68d779db9923L, 
+            0x7ff345b4eb7f3639L, 0x804d5881b2eefef3L, 0xa15f9c2826cb34dbL, 0x64822b68adefa772L, 0x761e92f8d279850dL, 
+            0xa5d049ab1061dba3L, 0x5f46fb02d10d2219L, 0xc1cdaa5f9ca79b19L, 0xdd713a74701ebe60L, 0x6b626ec963951798L, 
+            0x1d3ec8d78b96d16dL, 0xdb885d52960e7f34L, 0xe39849cf3ea178f8L, 0xc1e37acdf807130bL, 0x3645880ebf333913L, 
+            0x3af81a7bec346c22L, 0x871c563e94324804L, 0xac55fb5e2817db4cL, 0x35b04c42565ebe2L, 0x5094cafab11cbc3aL, 
+            0x94d40a57481346b5L, 0xf91a8492df723e3L, 0x126a70b84f779accL, 0x4409e9a5d5c3f133L, 0xb1655339864151efL, 
+            0x6564e506d11e9de1L, 0xd9a06f7b8860b488L, 0xd493e410b68b6c6L, 0x4e6fbf4b3b985a07L, 0x71c1b0ba9e52a2deL, 
+            0x5775784ad3cb99d9L, 0xbab84cec312107a6L, 0xd9066f5ccd59cf9eL, 0x8c656651dbb3ed84L, 0xa7448d0059484568L, 
+            0x2819237e5e8cb03aL, 0xd57eaf5239931b4bL, 0x6cd436fd5f7c1e73L, 0xf03b845f2a584931L, 0x8847b9f1f2d55b7aL, 
+            0xd49a38f8e59db8faL, 0xd5052cc47685dbfaL, 0x91e060fb399ecf2cL, 0x5748fbea12dd2869L, 0xd0cee85adb889226L, 
+            0xa35e9dfa5a64f56aL, 0x3118398bd0e3cbf0L, 0x5e650b9a3cb34308L, 0xf575ccbebf49b91cL, 0xb3f8dd73257c80e2L, 
+            0x13d7954e8294819bL, 0x90b57ccd00f1591dL, 0xa8b13ef52ca7e284L, 0xe482d24e5b239833L, 0xb0648475f2b4d63fL, 
+            0x847e8fc889e2389bL, 0xa8b501ee1fc59ba6L, 0x29702f6acba4379eL, 0xfaba9600f3d2cd0fL, 0x52ed7d9f45c6b578L, 
+            0xa02b167546d6e2d0L, 0x9a41cb166618a390L, 0x83d464d7349d9f3aL, 0x805485c9d2c70c6cL, 0x332f7ce3e077ecceL, 
+            0x1ead372c068ebb04L, 0xd6866c5b3b5eb82cL, 0x5b057c64bda94a33L, 0x11e1388f59653c66L, 0xffd2aca771c0abb8L, 
+            0x2fabdd0e8e8ba606L, 0xe974ffd57219e5e6L, 0x2b4e5c1e5f98e506L, 0xe7819b2cb44db4c0L, 0x6cbd78c408376520L, 
+            0x244285f39307f083L, 0xd152927f3a3af853L, 0x5b799885a8ba66e3L, 0x9300da64ea1a0644L, 0x67399bf8688a0cabL, 
+            0x47c301af4a94bb2L, 0x6750ecdf35c8471bL, 0x7598ae5c876d4080L, 0x269e0cf307467534L, 0x2ef4d8dcaedbc549L, 
+            0x2c6983c911c958afL, 0xb2fd7c07ae0bfa60L, 0x3220a56d67450e80L, 0x7385883420eb9f69L, 0xdb1fd2951f15b047L, 
+            0xf08b35df55977bcL, 0x42939b9f2e58127eL, 0x4d1d77e72414aa9aL, 0xfd8137f8b59bd084L, 0x167cc7f46a511504L, 
+            0x263de0c6b50290dL, 0x2a1c2feb488ffab8L, 0x1194815038360d85L, 0x36374630d0ecb4e8L, 0x609d38e22c59a974L, 
+            0xee23867f7c9b5f54L, 0x40e53a7804b0ef15L, 0x8f287f1a3be6e458L, 0xba7334b0f0af9e75L, 0x9f003e8e0e9c6c0L, 
+            0xc02dd0d35c42bc56L, 0x63dca83acd6be04aL, 0x9617b58a79fdd826L, 0x563d25e6f891bb33L, 0xe3c3d3f3f6d58588L, 
+            0x359977baa315b1b4L, 0xdf431301d9e6bc5L, 0x4074bb10d0003ca5L, 0xf440159140f2b453L, 0x3a6cc6e14820f5e2L, 
+            0x4b352bdacf3a37c4L, 0x9ef3b8df89ea4c29L, 0x8a1b2495a1414892L, 0x670b7f423f78b7c9L, 0x7513c7ccf6ee3c3aL, 
+            0x9ba96cb53c24408bL, 0x3316c3dc4ec859f0L, 0x501337e1a7f1e218L, 0x9a1544a6029c1eb5L, 0x9b43b15859c3e96fL, 
+            0x58011e22698bd4bL, 0x589b8eaea60d54a4L, 0x68ccb8c6cd7ec24dL, 0xe55beb5896455705L, 0xba6069cf90a8f1e2L, 
+            0x896a18c3eb90a6d6L, 0x870d3d80ae0b9323L, 0x48688d8b457f501bL, 0x8f1a8c1b84b3ba62L, 0xd1b7b64dc136f6b3L, 
+            0x3c6a7025428547e9L, 0x199bcc50a190fb6fL, 0xa5de0eed4bda0979L, 0x31041667821cddb5L, 0xe9df34e2678fb4e3L, 
+            0xdd7222eaee54e524L, 0xaae6488b26c7af56L, 0xe8a560dbbd2eb6b3L, 0xe37c99a7f5defceaL, 0x1572be8d78f3afacL, 
+            0xf69ffb64131633aeL, 0xa837ae34963616fbL, 0xaf0a9f03d137c170L, 0xd3e02b464018a48L, 0x11753aea03bb0ecdL, 
+            0x32d9cca610dceb34L, 0x2622bb6a6e7a11e3L, 0xdc99a44c515ec8b3L, 0xd7d720ad0a770b28L, 0xe322f742d6d051c2L, 
+            0x745f2b6e3ea9cd2bL, 0x951f21478e6b9662L, 0x227f21d8c0713385L, 0xcb729235e6876eeL, 0xd323b857d9721a53L, 
+            0xb2f5f599eb743346L, 0xefb30babe65a283L, 0x94c1190da321d470L, 0x117c63209fba9efeL, 0x738cf92baa4bc2cdL, 
+            0xc3bdd29b33277165L, 0xd78a2fab38f6dc46L, 0x35c44aafdefb91e2L, 0x321e26bf321fb60bL, 0x12db436288b37172L, 
+            0x158a2d49e51c261aL, 0xc9202ac8ba71c873L, 0xd02fa93dc97cc7b7L, 0x1f8bd11b747e901eL, 0xf7a17b2f74aa321cL, 
+            0x284d02d7552a3e90L, 0xeb86a8251533c574L, 0xb3fd774eaf4e77f8L, 0x31df2951c3ff37b1L, 0x86e38546195a69e7L, 
+            0x6737aaf165a1389aL, 0x2e2e925079feee0fL, 0xf7bd5a988596c1bbL, 0xccf835db6a10d2dfL, 0x6f42700f37c94701L, 
+            0xa6e86f7ba2779a5cL, 0xa43a4f7036d1ec2L, 0xd798bd6d52ad26daL, 0x218f6912af38b818L, 0xd48684f266f2e186L, 
+            0x8f675048b7b012e5L, 0xe5e469aac68eaf1dL, 0xe2740035697de79eL, 0xc22d6bd6d08baf1dL, 0x341774636bdc8f41L, 
+            0x7dfc6b73f7ba322bL, 0x7566343607bb525bL, 0xae94d116ccf1e74bL, 0x6ca1b59934cc2697L, 0x4c2fb1c45b749cedL, 
+            0x989999bbdd2ec893L, 0xcc4e27afa81bc8a8L, 0x6ddadf15ebf85830L, 0x38fa9cb2ce72bc16L, 0xacdaffe39db4bbdaL, 
+            0xbcc4682ebd095d93L, 0x483f539d354559adL, 0x45de92e997e2915cL, 0x7ec5c881c5344a55L, 0x9d1844fffa091545L, 
+            0xcd9b08d4dcda27baL, 0x1f7495a5f36c34ceL, 0x4f0fc9647d99afd7L, 0x5ac375ec59321cf2L, 0x5c07ce6df7e1d9a2L, 
+            0x49f211880d688b4cL, 0xf85fdd8ccad0867aL, 0x7d510164d8f197a8L, 0xc64108c5732cfa0eL, 0xb262d660d3a2c648L, 
+            0xd5d5614571dd2efaL, 0xec1a6d0dd5d5391L, 0xbf07d939d2535f02L, 0x35bce3021e51045L, 0x423ae115ec99d154L, 
+            0x22ea1d3abd893838L, 0x517fc1107eaa6a83L, 0xc5967cdf353aeac6L, 0x96ae2c3dff65ce6L, 0xab1b908b97dc911bL, 
+            0xf3d84c286f22611cL, 0x256823815030d8a2L, 0x3bd9b119887342e4L, 0x59926f3401f437d4L, 0x74edf41038d3986fL, 
+            0xe2b35bf615038253L, 0x4d09740a6b44db89L, 0xa37edaf089c0eeabL, 0x8263ba2c23e2d62dL, 0x8784aff57d390c3cL, 
+            0xfb49ab0635d66c3aL, 0xdeba73c2562bff1cL, 0xe2e6bf8cb6e29717L, 0xe70431c63d86e46L, 0x20d717e16aae6010L, 
+            0x31af57cdcf2cd36L, 0xd55fbeef1c5357feL, 0xd361d871f4e393feL, 0xb3416e718d32d214L, 0x7b351f93f909fc00L, 
+            0x16916de7b96a26bdL, 0x4fec1248b5dedb65L, 0xfae1aa9a62bfa096L, 0x92e7910a6b0084a9L, 0xd12bba8672e8aaa9L, 
+            0x316558d69efc8f6bL, 0xb0dde29eb96fee87L, 0x2125a2be5bf67eb3L, 0x5905903f46531fe4L, 0x2a9927e8175ff60fL, 
+            0x794376f2bb5d6d96L, 0xfa9f65d2b4848b12L, 0x2b92665a263a5091L, 0xabcaccfab8464c65L, 0x5b2fb2a46d1a0bdL, 
+            0xa879920d28c0d54cL, 0x50394088a8ea4953L, 0x61b0c87f0084129dL, 0x29ebcd1078d6e2b0L, 0x2440c652f6bacf89L, 
+            0xbd74d596cf4c8eb1L, 0xe4b009e5c334766bL, 0x7db26843cf72cb8L, 0x4171d5edd5468876L, 0x608d5c2c348c143cL, 
+            0xa19e0a2b81da6eb5L, 0xb65a7be9354c1390L, 0xf4f4c437cb9bb324L, 0xfc24806650c823bdL, 0x4c2331521e7f2966L, 
+            0x54f66e42eb73bafeL, 0xf06c11f3d2fe29aeL, 0x8ba8d0f28cbb0fcbL, 0xf3617850d1ae7976L, 0x96463b47cd9a7286L, 
+            0x8edc2133b35c3779L, 0xae43f70f181d9371L, 0xe7628d75c9a3c2e7L, 0x978499ba4193b333L, 0x99bb4bf79b0a46c1L, 
+            0x4c52676d7e4d0a58L, 0x2064ee3910693deeL, 0xfc43514d16633997L, 0x1bc1741ce05c4cceL, 0x6e9588d40f3396f6L, 
+            0x146fe816bb3a3708L, 0x2b3db8ee05eefa87L, 0x6ec21a91189ec0c0L, 0xa8a907b34108faf1L, 0x708b80912235684fL, 
+            0x2bc8ba70edfe680cL, 0x4d118826481266efL, 0x8f93a3a5de887175L, 0x3308e9133a950fe3L, 0x939ed8b0d7e91f87L, 
+            0x666beee64002b6b0L, 0xc8f129ec69ce7811L, 0xd57593c68ce93ea0L, 0x2d6a3e66edcc862L, 0xbe1d00d16a2271a6L, 
+            0x34fbeaf95e0c673fL, 0x9845ab59483a0e86L, 0x257d47d5abf88962L, 0x28af39f39319545bL, 0xe3fce03abd8171eeL, 
+            0xa4c5f606dccc96f1L, 0x4d414846267c4962L, 0x6ccf77f81d9dbf70L, 0x947bf43c729a71ecL, 0xfd656c39c4fa824cL, 
+            0x8f652cf2d1e04fd6L, 0x8cb11929a65b6aeeL, 0x94948f16a8064daL, 0x7434e703a4d03d5fL, 0x9361d3f63af4aa35L, 
+            0xa998c1eeec3fb422L, 0x51eb94754b5992a2L, 0x6e109c0347ef6979L, 0xe3c9738d67c582e2L, 0x9c735e3857ec57bfL, 
+            0xbe6415659e12c64bL, 0x73924584e31b9099L, 0x8f676821e60b0945L, 0x5614e3a695d5289dL, 0x7ecd448787517ebaL, 
+            0xc96db02038dbaf5bL, 0x69299ed774fa6c8L, 0xb4ace5a8ea16ac8L, 0xbf2f4f23a6c92295L, 0x90bdc4f1e931656cL, 
+            0x7cd5b0b95ac34d3aL, 0x2032bc59d3dc1710L, 0x702c1a0cd5609379L, 0x609d33abc01ff3feL, 0x8ae5d8f283b2748bL, 
+            0x2cf3778fa7eaae1dL, 0xe8a0d7b1919df9e3L, 0xe487894f6d602a0bL, 0x929858549609626aL, 0x46e540cd86bf46e7L, 
+            0xd1daf4382128d9eaL, 0xc47239c06b22ef75L, 0x8b7aad8ffea1b991L, 0xd6c1d2e315273fa0L, 0x2fda11cd74177e6bL, 
+            0x333cb0a145919fd7L, 0x5970b31a49f37b16L, 0x7890bc68793bb959L, 0x2a060f45a1719347L, 0xeb298f0264bf379dL, 
+            0xd7c4fd7921707400L, 0x374635e7713ed165L, 0xc60c008df0296d05L, 0xbf13739a8d3c7dbbL, 0xbfb945ef1cf94d1dL, 
+            0x75fe953c3a3a8315L, 0x9f83064f4150c02L, 0x6784a3b452055343L, 0x73ed26d185738f51L, 0x6c59094e8c998390L, 
+            0xeade93e19d60d4b5L, 0x8cf7cc8e62bc869dL, 0x22f85626f7f69298L, 0x6679c449ac22edc0L, 0x7017d0003e897435L, 
+            0x308fc450a6c62bf8L, 0x2578b45bc6f34cabL, 0xcbb936c9d253db39L, 0xc4e70e5bbc5e002cL, 0x29db6985be6c9459L, 
+            0x96afe876f5f6250cL, 0x829f766f138f95e6L, 0x4369632017c8fa0dL, 0xda90c817ca890a2L, 0x38d160dd675e2376L, 
+            0x20df15ad986408eaL, 0xd192623c3d9b3f41L, 0xd846f79123baf4aaL, 0x6cb058a0edfbf056L, 0x1b192f0be8dc77a7L, 
+            0x3a11b3dfcc81a441L, 0xe914410093ad7767L, 0x3126257e578bdf60L, 0xd5d5e470410cb6eaL, 0x4e1bf5d4209248aeL, 
+            0xe1e4c2924f35192eL, 0xac9944825cb7ef5eL, 0x8d2cbe6996eb3475L, 0x1bc05d2a079592d7L, 0x564a9f06755e71f3L, 
+            0x9bb767d68e9f2537L, 0xe4b045acf13978a2L, 0x4b7519cb9028ac83L, 0x9df655284198b85cL, 0xdc32ab4d421a2b61L, 
+            0x4c5d7f5323c1960cL, 0xe4273ff318f5c7b3L, 0xd73ef5ea88a3e99eL, 0xda2ffb6a863c850bL, 0x9555a4144e05ad82L, 
+            0x950104dc15092ebfL, 0x39d121a61f19dbfeL, 0xc6804e29d60d7814L, 0x7e98bec5ba17d58bL, 0x8b2c6b0e6c3b749aL, 
+            0x301a07c84aaccdbL, 0x93dee719932225a3L, 0x381611a50bac0ae1L, 0x572a8816f6e407b4L, 0x420efe85aa75232L, 
+            0xc1f53f78b9ffcf4dL, 0xbeda53bc95b96ec3L, 0x9f357114059c8eabL, 0xe38239260b584150L, 0xccbca17f4eed2ad0L, 
+            0x1528080b61f54198L, 0x5b8cdc4c40d49f30L, 0x1617db48eb6640d0L, 0x6fed27f88a516c99L, 0x37056e05b4724179L, 
+            0xec7bc122da9538d8L, 0x9fbfe01ca2c0fd57L, 0x2fc96b31dccafd9fL, 0xe26a72009daa1249L, 0xe9fb2e3998d16a25L, 
+            0x4a87dc39d24133aeL, 0xd5340e98fde806deL, 0x272b62b5dd0d7fe3L, 0xca4625581bf9dbe1L, 0x8677af77de374a90L, 
+            0x27dbec9e28f857edL, 0xb4aefc44d036612aL, 0xcf2e8ebdb0f6bb11L, 0x76023506c94e0532L, 0x864e72d4488c7a7aL, 
+            0xb81058fdac18fd3L, 0xdf93ee5b6674a0f4L, 0xdb30565511789d77L, 0xcf5fe22dc0375f30L, 0xa6e62e6e4edb4043L, 
+            0xbce383957a728669L, 0xfe4dd4e9633db2c6L, 0x24e68818b2a6d6cdL, 0x48a89c5424b4cdbL, 0x7fc7bc75bbbe5768L, 
+            0x79596343191e0ff2L, 0x5510b9cd8306839fL, 0xff2668b4eae7bb53L, 0xb4c03e6363c9e244L, 0xc9e3c0c1c015eb6fL, 
+            0x52531f5f898a744fL, 0x484005b2a805083L, 0x31673b70c6f23c53L, 0x5bffe158f323a7c2L, 0xc742bc0d0c55f125L, 
+            0xd95c32fe7e18379dL, 0xc1f2f613ee3c2e21L, 0x3217a43ff0daaa0eL, 0x3a9fa27258257e53L, 0x80b42af5a393bcf2L, 
+            0xb6967fd6a302f65eL, 0xfdc07bc592dbb125L, 0xcb83b8b9f64c3c3bL, 0x9cb572b041015355L, 0xc12dc512aedc530cL, 
+            0xc8db824276c083ceL, 0x86923b0e2903627fL, 0x1385cf2be22827cdL, 0x21b7616ced869ef1L, 0xc74d497d079901e6L, 
+            0x9e03c843bb13f658L, 0x915b89077a81ec7fL, 0x288a10b00768d244L, 0xd88eb6745a557569L, 0xb3c98071a3d13b20L, 
+            0x8f23aff44d352f03L, 0x2bf39ca10e45bdbbL, 0xf1bea47e2c68a4cL, 0xf8d5ab01c1ad6b55L, 0x679e0601953d1e31L, 
+            0xd793f3aacb3c520fL, 0x96fc350ccdb76eabL, 0x9fa0178362df447bL, 0xc11c63febf83598aL, 0x3aa88df3a1a71323L, 
+            0xab2f8338a09ca82aL, 0x32a2133050a71357L, 0xffecf97ca3ff65e1L, 0xfb6fd13318f5cb79L, 0x3acf76875acad366L, 
+            0xc577ffff529f74cfL, 0x368a90182031dd12L, 0xafbf2311ad656d52L, 0x80cd4f9f23fcafddL, 0x451717a061972d1fL, 
+            0xbbcbdae779cfbf3L, 0x133ca541293fd40dL, 0x6f241a21fc40b108L, 0x9adecbcf0c28110bL, 0xfab528d93bac6d3aL, 
+            0xf4ea3d459b0654aaL, 0x7e2e9ef35a5aafbaL, 0x28730469eded0fc7L, 0x3cbae97a12632fbeL, 0xded6960c0be007a8L, 
+            0x2a11758a7c52c43eL, 0x289de4875bda262dL, 0x6e13eea58caf3fa7L, 0x20c8ed0d5d673c1L, 0xdb4b3e7719d523b6L, 
+            0x49143c819d111fc3L, 0xe07479f9ddf45d8eL, 0x68f4654bcc07435bL, 0x513bd537af510064L, 0xcf956c3a3933ba38L, 
+            0x97e1eaa33f88eeccL, 0x18be860a2504a1c5L, 0x84408412fc0bf397L, 0xb6bdba7e154bdf7L, 0x1d8f8b446b544be6L, 
+            0x6f06b3dcdef17a03L, 0x30c6e14df59f8cefL, 0x1c97ba9910219cfL, 0x33ddcc087d1aeb5cL, 0xe31b94300cfbcbcfL, 
+            0xadeb8a98786bb28L, 0x3f69d5b0e3ec8f17L, 0x99f5a15f635296a6L, 0xce9fac7526862e86L, 0x3a88964201bd7524L, 
+            0xec94d643ea71be51L, 0xc4257084d97ab1c5L, 0xf369b10a73b4d382L, 0xac02bb473dbc5fd1L, 0x4fe73a86d95d7222L, 
+            0x858806616fe3d553L, 0x10680debcb0693e4L, 0xcaa9aac77c954093L, 0xf29c7530415d71e5L, 0xc32b319e09de9e48L, 
+            0x1c67107ed497ebc4L, 0x731da71593324021L, 0x49774770588c055aL, 0xf978dfdc28084220L, 0x58b3f2780b5a7ecL, 
+            0xe4ebf2ca21410715L, 0xd3841ed97708421fL, 0xdbc9401dc51eb4eL, 0xf47a96de499aa2e1L, 0x224da94d8542ba0cL, 
+            0xa3426a80b4dd0a4aL, 0x857caef48ef7e5b6L, 0x11356ad6ede44bf5L, 0x1a32471bd26acd7aL, 0x199396e31de7b358L, 
+            0xb7ca7950dbbb4a92L, 0x6ab23720409790a7L, 0x2abfdb93a3159d10L, 0x23913b403946c4a7L, 0xac7c9f339a822344L, 
+            0x12cffe9625cbe744L, 0x89558b98548b1946L, 0x77be65945c191139L, 0x3ba8d1fc701f4347L, 0xb143664560327f20L, 
+            0x48baccc3ef2081ffL, 0x450c379d24beb8e9L, 0x1990b609485db827L, 0x6c6a565d7129ccb4L, 0xf9724a82872bd619L, 
+            0xcfe629aa56717e20L, 0xfde48d87e844ec93L, 0xb32f79e5dc9ce4c1L, 0x7c9d88364238519fL, 0xe943aceba65150f9L, 
+            0x5301e8550cbdd076L, 0xabb8392364453b3cL, 0xdfb4b4a3cf84aa2dL, 0x269e45f7a6b48a42L, 0xd6783043ab383fcfL, 
+            0xe4ec475d296a69e5L, 0xe2e273ef65555361L, 0x6bd3084210a75af7L, 0xf2ebc493b909d8c7L, 0x4d20f3d435e9bc94L, 
+            0xa465e41c3c36d433L, 0xc1b259456f4341c0L, 0x260093703d6cf2ebL, 0xda68d9dea0aa9bdaL, 0x5662a12a210b2a47L, 
+            0x54675bd1a1b4b467L, 0x9dbd416302ec2468L, 0x3c7130a5032d823aL, 0xabfdef2d9a4fd92fL, 0xd4034e276021451fL, 
+            0x13834d3d0e43ab73L, 0xdc181442b438b2d6L, 0x1736ffb392c25e23L, 0x289b94003a946252L, 0x99705629b221ca37L, 
+            0xa7b22a5bb26775d6L, 0x2dc12f9f04435661L, 0xaadd48b556bc9e7cL, 0xf6992e8e94b68a49L, 0xd50420466c9456e3L, 
+            0xea8305ecdfb1266L, 0xfe0b1d7e4f0ef297L, 0x563de834c4e56a46L, 0xc62b8099b5b264c6L, 0xf6e76aeaf533c784L, 
+            0xd4680470b790968L, 0x288a50754707431eL, 0x8ad167ed38df547eL, 0x9052fed81a8ca4faL, 0x5975ac56f0548ef1L, 
+            0x588bf7d0130111aeL, 0x9ec02036a6688a24L, 0x8c9a454af9e09984L, 0x333ee6727bd12dcbL, 0x9847468f925dc38cL, 
+            0x446ed5203696abacL, 0x71fddf9ef5b5def6L, 0xd4d61614cc333541L, 0xd08a0694cd7f72a7L, 0x686cfe3ea1889281L, 
+            0xf039404e0dd3333fL, 0x52c620eb18b4246L, 0x4e4de47f86d84713L, 0xfe0450396b209851L, 0x99d6e893b01ed92bL, 
+            0xd94cf8705f8eba86L, 0x763451110c00291bL, 0xdf4f60b9aa45d064L, 0xf473d4bfd86ad526L, 0x41b9e3fa1a6dba94L, 
+            0xbaa7cdeb00796a4aL, 0xf668194c40626450L, 0xb894e0ae40a9c87fL, 0x5bc1eea8587d3ddbL, 0xc4c0ecb91bb50d75L, 
+            0x819fdfd17ff2917bL, 0x681484e54b6b12f7L, 0x2f510aa2f8977995L, 0x7d1582a293b8fa3dL, 0x3dad5a0f0da45470L, 
+            0x33c113aefb480520L, 0xbd524b2da7ce6c1fL, 0xe4cc051d00d8ddc0L, 0x2995950e206efa90L, 0x8b0e5dca588e3f50L, 
+            0xaabb3583f7f87082L, 0x75dbbecfa34cb4d6L, 0xf195977068849ae8L, 0x9223ca6fbb72767cL, 0xda7211029d59f04eL, 
+            0x18d9987c6566405cL, 0x57833aa39ef75a04L, 0xd1750e36481f654bL, 0xce2b66bc8796acbL, 0xc7e79aa76c96b057L, 
+            0x68f95b6b3c5cdc1dL, 0x2f5725cf5fc583aeL, 0x6b973013fd4484a6L, 0xaaeb2687f2d8bb96L, 0xad29cce061ba3934L, 
+            0xcb60dd1c437eb1d9L, 0x5cd6f46b78181bb4L, 0x1561cdc95ace24d9L, 0xbb774e6705806245L, 0xdc29c8df29b2e975L, 
+            0x6ee5ba502839dccdL, 0x670869bb64c60f69L, 0x8ca2931e927ae7L, 0x35cf6c0a27d8de77L, 0x94a3d86209af3920L, 
+            0x4095a276475df5b7L, 0x1119e4c257ccf7fbL, 0x33376166d9064fe8L, 0xd68c2399f968b905L, 0xb7bf2902f40fc101L, 
+            0x4ec18604cfd551e0L, 0xeb8e7fe1b6678e99L, 0xdcfe68fc0e042fa6L, 0xd2e58dfb1a8e3866L, 0xf4322bc57fb9a35aL, 
+            0xe0c665c8cf1fb49bL, 0x60de1f1050684297L, 0xf400c04cb00784cdL, 0xfc2a216f12016984L, 0xa808b477fd65fb4aL, 
+            0xd9b614adfcb5d0f1L, 0x50afdbc66e3efad2L, 0x82337b3f1764851cL, 0xdc98850eb93ef45eL, 0xe1c314bbc2c6af27L, 
+            0xd35614ba27e74a71L, 0xa5d592e04a31bb6fL, 0x3f143cd0bc243fbeL, 0x81641ac25408b21L, 0xd4166b32a26fc1c6L, 
+            0xccd088ee4d4a1f67L, 0x698c913d46c1ec99L, 0xf6b9086a5b986abL, 0x4a73c05ef72e3595L, 0x307aeeb350ab081L, 
+            0x43e20045bcb06b0eL, 0x3f58d1d6cd3aa0dcL, 0xd71cd7c996faba80L, 0x4431d8268eebfb71L, 0x254246df109e3dd5L, 
+            0xa7ca1449a238b06aL, 0x49b40e7b082493e7L, 0x45d80e6bd330d613L, 0xaf3d8a578b6d6232L, 0xa4b98341785262d1L, 
+            0xf4f1f424af963102L, 0xa84a986395146774L, 0x90da037fb61d5c88L, 0xb645534b2cf5b89fL, 0x3fdb3073310934b4L, 
+            0x1a0307d01f57f514L, 0x509c9b87a4a1e66cL, 0xbf320cf0888d8aa8L, 0x45a51f76c5f76892L, 0x23eb7a2b99a64402L, 
+            0x4c600e5675dd7757L, 0x4896757aa01a5c34L, 0xb808dbbda7a8a1daL, 0x762c21058ba50349L, 0x99b0a9d5deeebb37L, 
+            0xd6d98ef70a1e465dL, 0xb052f2c1163894f6L, 0xc55e73526f8bc8faL, 0xb31a0537f5b3b269L, 0xf09c1819c0c7f78aL, 
+            0xc36d4e2187e430f8L, 0xf141831a47299c7bL, 0x62f938047903ef34L, 0xf2a0dd678f92e0a5L, 0xc7fe6a53efaaa65L, 
+            0xcc539fcdcc466310L, 0x55199357cdc55491L, 0x6917fb45babb399eL, 0xb098da3c7b012b1aL, 0x54916438f426c41L, 
+            0x1a5ff3356d77d43bL, 0x74e71995e0aacf1aL, 0x6562a8da6b5e69eeL, 0xacbc2b8d1fb16ea8L, 0x400ea8e1f3f5535eL, 
+            0x2ea792dad3a4538fL, 0xf580fe481db60b5cL, 0xcb101198dd0aba9fL, 0x259acbe0461cb837L, 0x30033c3964b56a40L, 
+            0x6c15d4283eeb6fa6L, 0xdea7b626998ea3eeL, 0xdbb2e1b8c0c2abdbL, 0x3a856a6742b6edc2L, 0x777ed6b1683f48bL, 
+            0xde72fd7d6db3bb63L, 0xc8766969b599dc68L, 0xb39a5b76dce26160L, 0x97464948ce81d8a2L, 0xae20fda5af404ae6L, 
+            0xde1100c4f1ae3265L, 0x5a94d43bf60f574L, 0xc087a2116f52d0fcL, 0xfacb3be87e615d89L, 0xe184cb9fba7b0feL, 
+            0x824779bede6d84ffL, 0xa0852e96875da152L, 0x620046e8ba89baefL, 0x247c32c5f34b08ddL, 0x49294468356e7298L, 
+            0xaf6d6e0f8b5009ebL, 0x8c25bfcdb8abd77fL, 0x4f5464a1bc417e38L, 0x2df8fbe8993f8c9fL, 0x6540566281dd6d91L, 
+            0xb90690dcfb03a83L, 0xe270b7c7f8fab463L, 0x898ead41792a7f87L, 0xa1b1248822b7c292L, 0xfa2c0d61dd383eabL, 
+            0x5574c091830bd677L, 0x43640e20702986e5L, 0x622d0a1c860d0302L, 0x9528ea0051990eb9L, 0x28f057ef30af388fL, 
+            0x88320e974a2721a0L, 0x8a12cb33cdd88b60L, 0xd91a9763f991780dL, 0xdf22e332867c0e97L, 0xad95801b6c801f10L, 
+            0xb34e21d4afe2c4a0L, 0xd5465bf172494dd3L, 0x16594af34f1b5767L, 0xa675dceaee1591e6L, 0x53db891db5e1d768L, 
+            0x39a80f5d365c71afL, 0xdce01c73eac54372L, 0x1087fb03e5ce69e9L, 0x67cac3905594378L, 0x275d24c9aa1607f0L, 
+            0x9163a77a53e361b8L, 0x17d10f8254fa7f0bL, 0x49efeab6642e9e45L, 0x376e24839b1df1beL, 0xc46221cc408546fL, 
+            0x98eb5bb7001ebf5cL, 0xc6c4d56e3c9a78efL, 0x23c0723e123a899L, 0x145912ec44b57548L, 0x488a34fe824ff4c3L, 
+            0xac3bc6de9929c707L, 0x1dbac6e98813a70fL, 0xf566054941858266L, 0x18e0a3a2a8b8f2f1L, 0xcc6245a26564a399L, 
+            0x14416ca0e1a84a9aL, 0x4eaf095631a6e7bfL, 0xf2f89f104c9d0b8dL, 0x8fb278a5953e52d8L, 0x8fcee83a30a8be30L, 
+            0xb66850da1a0ceb33L, 0x5f37d31bad76f4dcL, 0xff4d956ffea8dea4L, 0x78c583b396635b3L, 0xad268fb5b1105028L, 
+            0xa480149a0dcbc5f4L, 0xb0e8d69c8b15c864L, 0x6ed49c46f19bb8eaL, 0x7f1871fdf321818dL, 0x1ec5816f5a9843eaL, 
+            0x77c8da91b5313675L, 0x4cdb66ad515e0717L, 0x2ec4712b0bfdfcd6L, 0x6c6f5767fff27330L, 0x71083b972d80c0cL, 
+            0x8d8325e82c4fdcdcL, 0xb47a658dad8e13a4L, 0x88710bf005fda027L, 0x69bd3edaf7111200L, 0xdccdd0c65c810ffL, 
+        };
+
+        for (int i = 0; i < refLong.length; ++i) {
+            Assert.assertEquals(refLong[i], rng.nextLong());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/test/java/org/apache/commons/math4/rng/internal/source64/SplitMix64Test.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/rng/internal/source64/SplitMix64Test.java b/src/test/java/org/apache/commons/math4/rng/internal/source64/SplitMix64Test.java
new file mode 100644
index 0000000..d2d980f
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/rng/internal/source64/SplitMix64Test.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.rng.internal.source64;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SplitMix64Test {
+    @Test
+    public void testReferenceCode() {
+        final long refSeed = 0x1a2b3c4d5e6f7531L;
+        final SplitMix64 rng = new SplitMix64(refSeed);
+
+        final long[] refValues = {
+            0x4141302768c9e9d0L, 0x64df48c4eab51b1aL, 0x4e723b53dbd901b3L, 0xead8394409dd6454L,
+            0x3ef60e485b412a0aL, 0xb2a23aee63aecf38L, 0x6cc3b8933c4fa332L, 0x9c9e75e031e6fccbL,
+            0x0fddffb161c9f30fL, 0x2d1d75d4e75c12a3L, 0xcdcf9d2dde66da2eL, 0x278ba7d1d142cfecL,
+            0x4ca423e66072e606L, 0x8f2c3c46ebc70bb7L, 0xc9def3b1eeae3e21L, 0x8e06670cd3e98bceL,
+            0x2326dee7dd34747fL, 0x3c8fff64392bb3c1L, 0xfc6aa1ebe7916578L, 0x3191fb6113694e70L,
+            0x3453605f6544dac6L, 0x86cf93e5cdf81801L, 0x0d764d7e59f724dfL, 0xae1dfb943ebf8659L,
+            0x012de1babb3c4104L, 0xa5a818b8fc5aa503L, 0xb124ea2b701f4993L, 0x18e0374933d8c782L,
+            0x2af8df668d68ad55L, 0x76e56f59daa06243L, 0xf58c016f0f01e30fL, 0x8eeafa41683dbbf4L,
+            0x7bf121347c06677fL, 0x4fd0c88d25db5ccbL, 0x99af3be9ebe0a272L, 0x94f2b33b74d0bdcbL,
+            0x24b5d9d7a00a3140L, 0x79d983d781a34a3cL, 0x582e4a84d595f5ecL, 0x7316fe8b0f606d20L,
+        };
+
+        for (int i = 0; i < refValues.length; ++i) {
+            Assert.assertEquals(refValues[i], rng.nextLong());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/test/java/org/apache/commons/math4/rng/internal/source64/TwoCmresTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/rng/internal/source64/TwoCmresTest.java b/src/test/java/org/apache/commons/math4/rng/internal/source64/TwoCmresTest.java
new file mode 100644
index 0000000..8505e6b
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/rng/internal/source64/TwoCmresTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.rng.internal.source64;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.commons.math4.exception.InsufficientDataException;
+import org.apache.commons.math4.exception.DimensionMismatchException;
+
+public class TwoCmresTest {
+    @Test
+    public void testAsymmetric() {
+        final int index1 = 2;
+        final int index2 = 5;
+        final int seed = -123456789;
+
+        final TwoCmres rng1 = new TwoCmres(seed, index1, index2);
+        final TwoCmres rng2 = new TwoCmres(seed, index2, index1);
+
+        // Try a few values.
+        final int n = 1000;
+        for (int i = 0; i < n; i++) {
+            Assert.assertNotEquals("i=" + i, rng1.nextLong(), rng2.nextLong());
+        }
+    }
+
+    @Test
+    public void testSubcycleGeneratorsMustBeDifferent() {
+        final int max = TwoCmres.numberOfSubcycleGenerators();
+        for (int i = 0; i < max; i++) {
+            try {
+                new TwoCmres(-97845, i, i);
+                Assert.fail("Exception expected");
+            } catch (InsufficientDataException e) {
+                // Expected.
+            }
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/test/java/org/apache/commons/math4/rng/internal/source64/XorShift1024StarTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/rng/internal/source64/XorShift1024StarTest.java b/src/test/java/org/apache/commons/math4/rng/internal/source64/XorShift1024StarTest.java
new file mode 100644
index 0000000..e9f2fa7
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/rng/internal/source64/XorShift1024StarTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.rng.internal.source64;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class XorShift1024StarTest {
+    @Test
+    public void testReferenceCode() {
+        /*
+         * Data from running the executable compiled from the author's C code:
+         *   http://xorshift.di.unimi.it/xorshift1024star.c
+         */
+        final long[] refSeed = new long[] {
+            0x012de1babb3c4104L, 0xa5a818b8fc5aa503L, 0xb124ea2b701f4993L, 0x18e0374933d8c782L,
+            0x2af8df668d68ad55L, 0x76e56f59daa06243L, 0xf58c016f0f01e30fL, 0x8eeafa41683dbbf4L,
+            0x7bf121347c06677fL, 0x4fd0c88d25db5ccbL, 0x99af3be9ebe0a272L, 0x94f2b33b74d0bdcbL,
+            0x24b5d9d7a00a3140L, 0x79d983d781a34a3cL, 0x582e4a84d595f5ecL, 0x7316fe8b0f606d20L,
+        };
+
+        final XorShift1024Star rng = new XorShift1024Star(refSeed);
+
+        final long[] refValues = {
+            0xd85e9fc0855614cdL, 0xaf4965c9c1ac6a3dL, 0x067da398791111d8L, 0x2771c41db58d7644L,
+            0xf71a471e1ac2b03eL, 0x953449ae275f7409L, 0x8aa570c72de0af5eL, 0xae59db2acdae32beL,
+            0x3d46f316b8f97301L, 0x72dc8399b7a70957L, 0xf5624d788b3b6f4eL, 0xb7a79275f6c0e7b1L,
+            0xf79354208377d498L, 0x0e5d2f2ac2b4f28fL, 0x0f8f57edc8aa802fL, 0x5e918ea72ece0c36L,
+            0xeeb8dbdb00ac7a5aL, 0xf16f88dfef0d6047L, 0x1244c29e0e0d8d2dL, 0xaa94f1cc42691eb7L,
+            0xd06425dd329e5de5L, 0x968b1c2e016f159cL, 0x6aadff7055065295L, 0x3bce2efcb0d00876L,
+            0xb28d5b69ad8fb719L, 0x1e4040c451376920L, 0x6b0801a8a00de7d7L, 0x891ba2cbe2a4675bL,
+            0x6355008481852527L, 0x7a47bcd9960126f3L, 0x07f72fcd4ebe3580L, 0x4658b29c126840ccL,
+            0xdc7b36d3037c7539L, 0x9e30aab0410122e8L, 0x7215126e0fce932aL, 0xda63f12a489fc8deL,
+            0x769997671b2a0158L, 0xfa9cd84e0ffc174dL, 0x34df1cd959dca211L, 0xccea41a33ec1f763L,
+        };
+
+        for (int i = 0; i < refValues.length; ++i) {
+            Assert.assertEquals(refValues[i], rng.nextLong());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/test/java/org/apache/commons/math4/rng/internal/util/NumberFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/rng/internal/util/NumberFactoryTest.java b/src/test/java/org/apache/commons/math4/rng/internal/util/NumberFactoryTest.java
new file mode 100644
index 0000000..ae9bc8d
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/rng/internal/util/NumberFactoryTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.rng.internal.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.commons.math4.exception.DimensionMismatchException;
+
+/**
+ * Tests for the {@link NumberFactory}.
+ */
+public class NumberFactoryTest {
+    /** sizeof(int). */
+    final int INT_SIZE = 4;
+    /** sizeof(long). */
+    final int LONG_SIZE = 8;
+
+    /** Test values. */
+    private static final long[] LONG_TEST_VALUES = new long[] {
+        0L,
+        1L,
+        -1L,
+        19337L,
+        1234567891011213L,
+        -11109876543211L,
+        Long.valueOf(Integer.MAX_VALUE),
+        Long.valueOf(Integer.MIN_VALUE),
+        Long.MAX_VALUE,
+        Long.MIN_VALUE,
+    };
+    /** Test values. */
+    private static final int[] INT_TEST_VALUES = new int[] {
+        0,
+        1,
+        -1,
+        19337,
+        1234567891,
+        -1110987656,
+        Integer.MAX_VALUE,
+        Integer.MIN_VALUE,
+    };
+
+    @Test
+    public void testMakeIntFromLong() {
+        for (long v : LONG_TEST_VALUES) {
+            final int vL = NumberFactory.extractLo(v);
+            final int vH = NumberFactory.extractHi(v);
+
+            final long actual = (((long) vH) << 32) | (vL & 0xffffffffL);
+            Assert.assertEquals(v, actual);
+        }
+    }
+
+    @Test
+    public void testLong2Long() {
+        for (long v : LONG_TEST_VALUES) {
+            final int vL = NumberFactory.extractLo(v);
+            final int vH = NumberFactory.extractHi(v);
+
+            Assert.assertEquals(v, NumberFactory.makeLong(vH, vL));
+        }
+    }
+
+    @Test
+    public void testLongFromByteArray2Long() {
+        for (long expected : LONG_TEST_VALUES) {
+            final byte[] b = NumberFactory.makeByteArray(expected);
+            Assert.assertEquals(expected, NumberFactory.makeLong(b));
+        }
+    }
+
+    @Test
+    public void testLongArrayFromByteArray2LongArray() {
+        final byte[] b = NumberFactory.makeByteArray(LONG_TEST_VALUES);
+        Assert.assertArrayEquals(LONG_TEST_VALUES,
+                                 NumberFactory.makeLongArray(b));
+    }
+
+    @Test
+    public void testIntFromByteArray2Int() {
+        for (int expected : INT_TEST_VALUES) {
+            final byte[] b = NumberFactory.makeByteArray(expected);
+            Assert.assertEquals(expected, NumberFactory.makeInt(b));
+        }
+    }
+
+    @Test
+    public void testIntArrayFromByteArray2IntArray() {
+        final byte[] b = NumberFactory.makeByteArray(INT_TEST_VALUES);
+        Assert.assertArrayEquals(INT_TEST_VALUES,
+                                 NumberFactory.makeIntArray(b));
+    }
+
+    @Test
+    public void testMakeIntPrecondition1() {
+        for (int i = 0; i <= 10; i++) {
+            try {
+                NumberFactory.makeInt(new byte[i]);
+                if (i != INT_SIZE) {
+                    Assert.fail("Exception expected");
+                }
+            } catch (DimensionMismatchException e) {
+                // Expected.
+            }
+        }
+    }
+
+    @Test
+    public void testMakeIntArrayPrecondition1() {
+        for (int i = 0; i <= 20; i++) {
+            try {
+                NumberFactory.makeIntArray(new byte[i]);
+                if (i != 0 && (i % INT_SIZE != 0)) {
+                    Assert.fail("Exception expected");
+                }
+            } catch (DimensionMismatchException e) {
+                // Expected.
+            }
+        }
+    }
+
+    @Test
+    public void testMakeLongPrecondition1() {
+        for (int i = 0; i <= 10; i++) {
+            try {
+                NumberFactory.makeLong(new byte[i]);
+                if (i != LONG_SIZE) {
+                    Assert.fail("Exception expected");
+                }
+            } catch (DimensionMismatchException e) {
+                // Expected.
+            }
+        }
+    }
+
+    @Test
+    public void testMakeLongArrayPrecondition1() {
+        for (int i = 0; i <= 20; i++) {
+            try {
+                NumberFactory.makeLongArray(new byte[i]);
+                if (i != 0 && (i % LONG_SIZE != 0)) {
+                    Assert.fail("Exception expected");
+                }
+            } catch (DimensionMismatchException e) {
+                // Expected.
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/test/java/org/apache/commons/math4/rng/internal/util/SeedFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/rng/internal/util/SeedFactoryTest.java b/src/test/java/org/apache/commons/math4/rng/internal/util/SeedFactoryTest.java
new file mode 100644
index 0000000..559f484
--- /dev/null
+++ b/src/test/java/org/apache/commons/math4/rng/internal/util/SeedFactoryTest.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.rng.internal.util;
+
+import java.util.Map;
+import java.util.HashMap;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests for {@link SeedFactory}.
+ */
+public class SeedFactoryTest {
+    @Test
+    public void testCreateLong() {
+        final Map<Long, Integer> values = new HashMap<>();
+
+        final int n = 100000;
+        for (int i = 0; i < n; i++) {
+            final long v = SeedFactory.createLong();
+
+            Integer count = values.get(v);
+            if (count == null) {
+                count = 0;
+            }
+            values.put(v, count + 1);
+        }
+
+        // Check that all seeds are different.
+        assertDifferentValues(values);
+    }
+
+    @Test
+    public void testCreateLongArray() {
+        final Map<Long, Integer> values = new HashMap<>();
+
+        final int n = 100000;
+        final long[] array = SeedFactory.createLongArray(n);
+        Assert.assertEquals(n, array.length);
+
+        for (long v : array) {
+            Integer count = values.get(v);
+            if (count == null) {
+                count = 0;
+            }
+            values.put(v, count + 1);
+        }
+
+        // Check that all seeds are different.
+        assertDifferentValues(values);
+    }
+
+    @Test
+    public void testCreateIntArray() {
+        final Map<Long, Integer> values = new HashMap<>();
+
+        for (int i = 0; i < 50000; i++) {
+            final int[] a = SeedFactory.createIntArray(2);
+            final long v = NumberFactory.makeLong(a[0], a[1]); 
+            Integer count = values.get(v);
+            if (count == null) {
+                count = 0;
+            }
+            values.put(v, count + 1);
+        }
+
+        // Check that all pairs in are different.
+        assertDifferentValues(values);
+    }
+
+    /**
+     * Asserts that all the keys in given {@code map} have their
+     * value equal to 1.
+     *
+     * @param map Map to counts.
+     */
+    private static <T> void assertDifferentValues(Map<T, Integer> map) {
+        final StringBuilder sb = new StringBuilder();
+
+        int duplicates = 0;
+        for (Map.Entry<T, Integer> entry : map.entrySet()) {
+            final int count = entry.getValue();
+            if (count <= 0) {
+                throw new IllegalStateException();
+            }
+
+            if (count > 1) {
+                duplicates += count - 1;
+                sb.append(entry.getKey() + ": " + count + "\n");
+            }
+        }
+
+        if (duplicates > 0) {
+            Assert.fail(duplicates + " duplicates\n" + sb);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/userguide/README
----------------------------------------------------------------------
diff --git a/src/userguide/README b/src/userguide/README
index 9aa0238..7ee72a0 100644
--- a/src/userguide/README
+++ b/src/userguide/README
@@ -5,4 +5,17 @@ examples of use.
 In order to run one of the applications (a class that must contain a
 "main" method), you would type (in a shell console) a command similar
 to the following:
- $ mvn -q exec:java -Dexec.mainClass=org.apache.commons.math4.userguide.sofm.ChineseRingsClassifier
+ $ mvn -q exec:java \
+   -Dexec.mainClass=org.apache.commons.math4.userguide.sofm.ChineseRingsClassifier
+
+Alternatively, a "standalone" JAR can be created with the following
+command:
+ $ mvn -Dmainclass=org.apache.commons.math4.userguide.rng.RandomStressTester \
+       -Djarbasename=RandomStressTester \
+       clean compile assembly:single
+where the value of the "mainclass" argument is the fully-qualified name
+of the class whose "main" method will be the program's entry point, and
+the "jarbasename" argument is the basename of the JAR file to be created.
+Then, the application can be run with the following command:
+ $ java -jar RandomStressTester [args]
+where "[args]" is the list of arguments passed to the "main" method.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/userguide/c/rng/stdin2testu01.c
----------------------------------------------------------------------
diff --git a/src/userguide/c/rng/stdin2testu01.c b/src/userguide/c/rng/stdin2testu01.c
new file mode 100644
index 0000000..d1a4a6a
--- /dev/null
+++ b/src/userguide/c/rng/stdin2testu01.c
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Utility for simple interfacing with the "TestU01" library:
+ *  http://simul.iro.umontreal.ca/testu01/tu01.html
+ *
+ * It reads from its standard input an infinite sequence of 32-bits
+ * integers and runs one of the test suites "SmallCrush", "Crush" or
+ * "BigCrush".
+ * "TestU01" writes its report to standard output.
+ */
+
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <testu01/unif01.h>
+#include <testu01/bbattery.h>
+#include <testu01/util.h>
+
+#define TU_S "SmallCrush"
+#define TU_C "Crush"
+#define TU_B "BigCrush"
+#define BUFFER_LENGTH 256
+
+typedef struct {
+  unsigned long buffer[BUFFER_LENGTH];
+  uint32_t index;
+} StdinReader_state;
+
+unsigned long nextInt(void *par,
+                      void *sta) {
+  StdinReader_state *state = (StdinReader_state *) sta;
+  if (state->index >= BUFFER_LENGTH) {
+    /* Refill. */
+    fread(state->buffer, sizeof(unsigned long), BUFFER_LENGTH, stdin);
+    state->index = 0;
+  }
+
+  uint32_t random = state->buffer[state->index];
+  ++state->index; /* Next request. */
+
+  return random;
+}
+
+double nextDouble(void *par,
+                  void *sta) {
+  return nextInt(par, sta) / 4294967296.0;
+}
+
+
+static void dummy(void *sta) {
+  printf("N/A");
+
+  return;
+}
+
+unif01_Gen *createStdinReader(void) {
+   unif01_Gen *gen;
+   StdinReader_state *state;
+   size_t len;
+   char name[60];
+
+   state = util_Malloc(sizeof(StdinReader_state));
+
+   gen = util_Malloc(sizeof(unif01_Gen));
+   gen->state = state;
+   gen->param = NULL;
+   gen->Write = dummy;
+   gen->GetU01 = nextDouble;
+   gen->GetBits = nextInt;
+
+   strcpy(name, "stdin");
+   len = strlen(name);
+   gen->name = util_Calloc(len + 1, sizeof (char));
+   strncpy(gen->name, name, len);
+
+   // Read binary input.
+   freopen(NULL, "rb", stdin);
+   state->index = BUFFER_LENGTH;
+
+   return gen;
+}
+
+void deleteStdinReader(unif01_Gen *gen) {
+   gen->state = util_Free(gen->state);
+   gen->name = util_Free(gen->name);
+   util_Free(gen);
+}
+
+int main(int argc,
+         char **argv) {
+  unif01_Gen *gen = createStdinReader();
+  char *spec = argv[1];
+
+  if (argc < 2) {
+    printf("[ERROR] Specify test suite: '%s', '%s' or '%s'\n", TU_S, TU_C, TU_B);
+    exit(1);
+  } else if (strcmp(spec, TU_S) == 0) {
+    bbattery_SmallCrush(gen);
+  } else if (strcmp(spec, TU_C) == 0) {
+    bbattery_Crush(gen);
+  } else if (strcmp(spec, TU_B) == 0) {
+    bbattery_BigCrush(gen);
+  } else {
+    printf("[ERROR] Unknown specification: '%s'\n", spec);
+    exit(1);
+  }
+
+  deleteStdinReader(gen);
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/userguide/java/org/apache/commons/math4/userguide/rng/GeneratorsList.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/rng/GeneratorsList.java b/src/userguide/java/org/apache/commons/math4/userguide/rng/GeneratorsList.java
new file mode 100644
index 0000000..043bce9
--- /dev/null
+++ b/src/userguide/java/org/apache/commons/math4/userguide/rng/GeneratorsList.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.userguide.rng;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.commons.math4.rng.UniformRandomProvider;
+import org.apache.commons.math4.rng.RandomSource;
+
+/**
+ * List of generators.
+ */
+public class GeneratorsList implements Iterable<UniformRandomProvider> {
+    /** List. */
+    private final List<UniformRandomProvider> list = new ArrayList<>();
+
+    /**
+     * Creates list.
+     */
+    public GeneratorsList() {
+        list.add(RandomSource.create(RandomSource.JDK));
+        list.add(RandomSource.create(RandomSource.MT));
+        list.add(RandomSource.create(RandomSource.WELL_512_A));
+        list.add(RandomSource.create(RandomSource.WELL_1024_A));
+        list.add(RandomSource.create(RandomSource.WELL_19937_A));
+        list.add(RandomSource.create(RandomSource.WELL_19937_C));
+        list.add(RandomSource.create(RandomSource.WELL_44497_A));
+        list.add(RandomSource.create(RandomSource.WELL_44497_B));
+        list.add(RandomSource.create(RandomSource.ISAAC));
+        list.add(RandomSource.create(RandomSource.MT_64));
+        list.add(RandomSource.create(RandomSource.SPLIT_MIX_64));
+        list.add(RandomSource.create(RandomSource.XOR_SHIFT_1024_S));
+        list.add(RandomSource.create(RandomSource.TWO_CMRES));
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Iterator<UniformRandomProvider> iterator() {
+        return list.iterator();
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomStressTester.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomStressTester.java b/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomStressTester.java
new file mode 100644
index 0000000..e257b53
--- /dev/null
+++ b/src/userguide/java/org/apache/commons/math4/userguide/rng/RandomStressTester.java
@@ -0,0 +1,280 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.userguide.rng;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.io.IOException;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.FileWriter;
+import java.io.DataOutputStream;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.apache.commons.math4.rng.UniformRandomProvider;
+
+/**
+ * Class that can be used for testing a generator by piping the values
+ * returned by its {@link UniformRandomProvider#nextInt()} method to a
+ * program that reads {@code int} values from its standard input and
+ * writes an analysis report to standard output.
+ *
+ * <p>
+ *  The <a href="http://www.phy.duke.edu/~rgb/General/dieharder.php">
+ *  "dieharder"</a> test suite is such a software.
+ *  <br>
+ *  Example of command line, assuming that "examples.jar" specifies this
+ *  class as the "main" class (see {@link #main(String[]) main} method):
+ *  <pre><code>
+ *   $ java -jar examples.jar \
+ *     report/dh_ \
+ *     4 \
+ *     org.apache.commons.math4.userguide.rng.GeneratorsList \
+ *     /usr/bin/dieharder -a -g 200 -Y 1 -k 2
+ *  </code></pre>
+ * </p>
+ */
+public class RandomStressTester {
+    /** Comment prefix. */
+    private static final String C = "# ";
+    /** New line. */
+    private static final String N = "\n";
+    /** Command line. */
+    private final List<String> cmdLine;
+    /** Output prefix. */
+    private final String fileOutputPrefix;
+
+    /**
+     * Creates the application.
+     *
+     * @param cmd Command line.
+     * @param outputPrefix Output prefix for file reports.
+     */
+    private RandomStressTester(List<String> cmd,
+                               String outputPrefix) {
+        final File exec = new File(cmd.get(0));
+        if (!exec.exists() ||
+            !exec.canExecute()) {
+            throw new RuntimeException("Program is not executable: " + exec);
+        }
+
+        cmdLine = new ArrayList<String>(cmd);
+        fileOutputPrefix = outputPrefix;
+
+        final File reportDir = new File(fileOutputPrefix).getParentFile();
+        if (!reportDir.exists() ||
+            !reportDir.isDirectory() ||
+            !reportDir.canWrite()) {
+            throw new RuntimeException("Invalid output directory: " + reportDir);
+        }
+    }
+
+    /**
+     * Program's entry point.
+     *
+     * @param args Application's arguments.
+     * The order is as follows:
+     * <ul>
+     *  <li>Output prefix: Filename prefix where the output of the analysis will
+     *   written to.  The appended suffix is the index of the instance within the
+     *   list of generators to be tested.</li>
+     *  <li>Number of threads to use concurrently: One thread will process one of
+     *    the generators to be tested.</li>
+     *  <li>Name of a class that implements {@code Iterable<UniformRandomProvider>}
+     *   (and defines a default constructor): Each generator of the list will be
+     *   tested by one instance of the analyzer program</li>
+     *  <li>Path to the executable: this is the analyzer software that reads 32-bits
+     *   integers from stdin.</li>
+     *  <li>All remaining arguments are passed to the executable.</li>
+     * </ul>
+     */
+    public static void main(String[] args) throws Exception {
+        final String output = args[0];
+        final int numThreads = Integer.valueOf(args[1]);
+
+        final Iterable<UniformRandomProvider> rngList = createGeneratorsList(args[2]);
+
+        final List<String> cmdLine = new ArrayList<>();
+        cmdLine.addAll(Arrays.asList(Arrays.copyOfRange(args, 3, args.length)));
+
+        final RandomStressTester app = new RandomStressTester(cmdLine, output);
+        app.run(rngList, numThreads);
+    }
+
+    /**
+     * Creates the tasks and starts the processes.
+     *
+     * @param generators List of generators to be analyzed.
+     * @param numConcurrentTasks Number of concurrent tasks.
+     * Twice as many threads will be started: one thread for the RNG and one
+     * for the analyzer.
+     */
+    private void run(Iterable<UniformRandomProvider> generators,
+                     int numConcurrentTasks)
+        throws IOException {
+        // Parallel execution.
+        final ExecutorService service = Executors.newFixedThreadPool(numConcurrentTasks);
+
+        // Placeholder (output will be "null").
+        final List<Future<?>> execOutput = new ArrayList<Future<?>>();
+
+        // Run tasks.
+        int count = 0;
+        for (UniformRandomProvider rng : generators) {
+            final File output = new File(fileOutputPrefix + (++count));
+            final Runnable r = new Task(rng, output);
+            execOutput.add(service.submit(r));
+        }
+
+        // Wait for completion (ignoring return value).
+        try {
+            for (Future<?> f : execOutput) {
+                try {
+                    f.get();
+                } catch (ExecutionException e) {
+                    System.err.println(e.getCause().getMessage());
+                }
+            }
+        } catch (InterruptedException ignored) {}
+
+        // Terminate all threads.
+        service.shutdown();
+    }
+
+    /**
+     * Creates the list of generators to be tested.
+     *
+     * @param name Name of the class that contains the generators to be
+     * analyzed.
+     * @return the list of generators.
+     */
+    private static Iterable<UniformRandomProvider> createGeneratorsList(String name)
+        throws ClassNotFoundException,
+               InstantiationException,
+               IllegalAccessException {
+        return (Iterable<UniformRandomProvider>) Class.forName(name).newInstance();
+    }
+
+    /**
+     * Pipes random numbers to the standard input of an analyzer.
+     */
+    private class Task implements Runnable {
+        /** Directory for reports of the tester processes. */
+        private final File output;
+        /** RNG to be tested. */
+        private final UniformRandomProvider rng;
+
+        /**
+         * Creates the task.
+         *
+         * @param random RNG to be tested.
+         * @param report Report file.
+         */
+        public Task(UniformRandomProvider random,
+                    File report) {
+            rng = random;
+            output = report;
+        }
+
+        /** {@inheritDoc} */
+        @Override
+            public void run() {
+            try {
+                // Write header.
+                printHeader(output, rng);
+
+                // Start test suite.
+                final ProcessBuilder builder = new ProcessBuilder(cmdLine);
+                builder.redirectOutput(ProcessBuilder.Redirect.appendTo(output));
+                final Process testingProcess = builder.start();
+                final DataOutputStream sink = new DataOutputStream(testingProcess.getOutputStream());
+
+                final long startTime = System.nanoTime();
+
+                try {
+                    while (true) {
+                        sink.writeInt(rng.nextInt());
+                    }
+                } catch (IOException e) {
+                    // Hopefully getting here when the analyzing software terminates.
+                }
+
+                final long endTime = System.nanoTime();
+
+                // Write footer.
+                printFooter(output, endTime - startTime);
+
+            } catch (IOException e) {
+                throw new RuntimeException("Failed to start task: " + e.getMessage());
+            }
+        }
+    }
+
+    /**
+     * @param output File.
+     * @param rng Generator being tested.
+     * @param cmdLine
+     */
+    private void printHeader(File output,
+                             UniformRandomProvider rng)
+        throws IOException {
+        final StringBuilder sb = new StringBuilder();
+        sb.append(C).append(N);
+        sb.append(C).append("RNG: ").append(rng.toString()).append(N);
+        sb.append(C).append(N);
+        sb.append(C).append("Java: ").append(System.getProperty("java.version")).append(N);
+        sb.append(C).append("Runtime: ").append(System.getProperty("java.runtime.version", "?")).append(N);
+        sb.append(C).append("JVM: ").append(System.getProperty("java.vm.name"))
+            .append(" ").append(System.getProperty("java.vm.version")).append(N);
+        sb.append(C).append("OS: ").append(System.getProperty("os.name"))
+            .append(" ").append(System.getProperty("os.version"))
+            .append(" ").append(System.getProperty("os.arch")).append(N);
+        sb.append(C).append(N);
+
+        sb.append(C).append("Analyzer: ");
+        for (String s : cmdLine) {
+            sb.append(s).append(" ");
+        }
+        sb.append(N);
+        sb.append(C).append(N);
+
+        final PrintWriter w = new PrintWriter(new FileWriter(output, true));
+        w.print(sb.toString());
+        w.close();
+    }
+
+    /**
+     * @param output File.
+     * @param nanoTime Duration of the run.
+     */
+    private void printFooter(File output,
+                             long nanoTime)
+        throws IOException {
+        final PrintWriter w = new PrintWriter(new FileWriter(output, true));
+        w.println(C);
+
+        final double duration = ((double) nanoTime) * 1e-9 / 60;
+        w.println(C + "Test duration: " + duration + " minutes");
+
+        w.println(C);
+        w.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/ce8c82f1/src/userguide/pom.xml
----------------------------------------------------------------------
diff --git a/src/userguide/pom.xml b/src/userguide/pom.xml
index 2f8ac91..4f3c888 100644
--- a/src/userguide/pom.xml
+++ b/src/userguide/pom.xml
@@ -45,6 +45,36 @@
 
   <build>
     <sourceDirectory>java</sourceDirectory>
+
+    <plugins>
+
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>${mainclass}</mainClass>
+            </manifest>
+          </archive>
+          <descriptorRefs>
+            <descriptorRef>jar-with-dependencies</descriptorRef>
+          </descriptorRefs>
+          <finalName>${jarbasename}</finalName>
+          <appendAssemblyId>false</appendAssemblyId>
+        </configuration>
+        <executions>
+          <execution>
+            <id>make-assembly</id> <!-- this is used for inheritance merges -->
+            <phase>package</phase> <!-- bind to the packaging phase -->
+            <goals>
+              <goal>single</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+   </plugins>
+
   </build>
   <reporting>
   </reporting>


Mime
View raw message