RandomMT19937.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 21:40:13 +0200
changeset 5476 7355a4b11cb6
parent 4591 2449ca90c3a9
permissions -rw-r--r--
#FEATURE by cg class: Socket class added: #newTCPclientToHost:port:domain:domainOrder:withTimeout: changed: #newTCPclientToHost:port:domain:withTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:libbasic2' }"
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
4591
2449ca90c3a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3430
diff changeset
     3
"{ NameSpace: Smalltalk }"
2449ca90c3a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3430
diff changeset
     4
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
Object subclass:#RandomMT19937
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	instanceVariableNames:'n m matrixA upperMask lowerMask mt mti'
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	classVariableNames:''
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	poolDictionaries:''
4591
2449ca90c3a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3430
diff changeset
     9
	category:'Magnitude-Numbers-Random'
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!RandomMT19937 class methodsFor:'documentation'!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
documentation
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
"
3355
92d0293365af comment/format in: #documentation
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
    16
    Warning: this generator should not be used for cryptographic work.
92d0293365af comment/format in: #documentation
Claus Gittinger <cg@exept.de>
parents: 3348
diff changeset
    17
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    NO WARRANTY
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
3429
518a0ac18836 class: RandomMT19937
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
    20
    A Mersenne Twister based on code by Takuji Nishimura and Makoto Matsumoto.
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
3348
d8e779ae0ab1 class: RandomMT19937
Claus Gittinger <cg@exept.de>
parents: 3340
diff changeset
    22
    Before using, initialize the state by using initGen(seed) or initByArray(init_key).
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
    RandomMT19937 new nextInteger
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
    (RandomMT19937 new:5489) nextInteger
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
    (RandomMT19937 newByArray:{16r123 . 16r234 .16r345 . 16r456}) nextInteger
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
3348
d8e779ae0ab1 class: RandomMT19937
Claus Gittinger <cg@exept.de>
parents: 3340
diff changeset
    28
    If heavily used, it may be useful to embed the original C code as inline C code for a big speedup)
d8e779ae0ab1 class: RandomMT19937
Claus Gittinger <cg@exept.de>
parents: 3340
diff changeset
    29
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
    Please read:
3429
518a0ac18836 class: RandomMT19937
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
    31
        Wikipedia article on Mersenne Twister end esp. MT19937
3348
d8e779ae0ab1 class: RandomMT19937
Claus Gittinger <cg@exept.de>
parents: 3340
diff changeset
    32
        http://de.wikipedia.org/wiki/Liste_von_Zufallszahlengeneratoren
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
        MT home page http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
    [see also:]
3396
5fa94292e275 documentation link
Claus Gittinger <cg@exept.de>
parents: 3389
diff changeset
    36
        http://www0.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG.pdf
3402
0d6436f4e908 documentation link
Claus Gittinger <cg@exept.de>
parents: 3396
diff changeset
    37
        RandomGenerator - the default; uses the machine's /dev/random if available
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
        Random  - fast, but generates less quality random numbers
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
        RandomTT800 - another random generator
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
        RandomParkMiller - another random generator
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    [author:]
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
        Original algorithm by Takuji Nishimura and Makoto Matsumoto
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
        Ported to Smalltalk by Claus Gittinger.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
test
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    compare generated numbers a gainst reference implementation
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    (see http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.out)
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
                                                                                [exBegin]
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    |l rnd|
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    rnd := (RandomMT19937 newByArray:{16r123 . 16r234 .16r345 . 16r456}).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    #(
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        1067595299  955945823  477289528 4107218783 4228976476 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        3344332714 3355579695  227628506  810200273 2591290167 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        2560260675 3242736208  646746669 1479517882 4245472273 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        1143372638 3863670494 3221021970 1773610557 1138697238 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
        1421897700 1269916527 2859934041 1764463362 3874892047 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
        3965319921   72549643 2383988930 2600218693 3237492380 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
        2792901476  725331109  605841842  271258942  715137098 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
        3297999536 1322965544 4229579109 1395091102 3735697720 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
        2101727825 3730287744 2950434330 1661921839 2895579582 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
        2370511479 1004092106 2247096681 2111242379 3237345263 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
        4082424759  219785033 2454039889 3709582971  835606218 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        2411949883 2735205030  756421180 2175209704 1873865952 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
        2762534237 4161807854 3351099340  181129879 3269891896 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
         776029799 2218161979 3001745796 1866825872 2133627728 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
          34862734 1191934573 3102311354 2916517763 1012402762 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
        2184831317 4257399449 2899497138 3818095062 3030756734 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
        1282161629  420003642 2326421477 2741455717 1278020671 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        3744179621  271777016 2626330018 2560563991 3055977700 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
        4233527566 1228397661 3595579322 1077915006 2395931898 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
        1851927286 3013683506 1999971931 3006888962 1049781534 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
        1488758959 3491776230  104418065 2448267297 3075614115 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
        3872332600  891912190 3936547759 2269180963 2633455084 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        1047636807 2604612377 2709305729 1952216715  207593580 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
        2849898034  670771757 2210471108  467711165  263046873 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
        3569667915 1042291111 3863517079 1464270005 2758321352 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        3790799816 2301278724 3106281430    7974801 2792461636 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
         555991332  621766759 1322453093  853629228  686962251 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
        1455120532  957753161 1802033300 1021534190 3486047311 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
        1902128914 3701138056 4176424663 1795608698  560858864 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
        3737752754 3141170998 1553553385 3367807274  711546358 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
        2475125503  262969859  251416325 2980076994 1806565895 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
         969527843 3529327173 2736343040 2987196734 1649016367 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        2206175811 3048174801 3662503553 3138851612 2660143804 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
        1663017612 1816683231  411916003 3887461314 2347044079 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        1015311755 1203592432 2170947766 2569420716  813872093 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
        1105387678 1431142475  220570551 4243632715 4179591855 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
        2607469131 3090613241  282341803 1734241730 1391822177 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        1001254810  827927915 1886687171 3935097347 2631788714 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
        3905163266  110554195 2447955646 3717202975 3304793075 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
        3739614479 3059127468  953919171 2590123714 1132511021 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
        3795593679 2788030429  982155079 3472349556  859942552 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
        2681007391 2299624053  647443547  233600422  608168955 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
        3689327453 1849778220 1608438222 3968158357 2692977776 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
        2851872572  246750393 3582818628 3329652309 4036366910 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
        1012970930  950780808 3959768744 2538550045  191422718 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
        2658142375 3276369011 2927737484 1234200027 1920815603 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
        3536074689 1535612501 2184142071 3276955054  428488088 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
        2378411984 4059769550 3913744741 2732139246   64369859 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
        3755670074  842839565 2819894466 2414718973 1010060670 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
        1839715346 2410311136  152774329 3485009480 4102101512 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
        2852724304  879944024 1785007662 2748284463 1354768064 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
        3267784736 2269127717 3001240761 3179796763  895723219 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
         865924942 4291570937   89355264 1471026971 4114180745 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
        3201939751 2867476999 2460866060 3603874571 2238880432 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
        3308416168 2072246611 2755653839 3773737248 1709066580 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
        4282731467 2746170170 2832568330  433439009 3175778732 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
          26248366 2551382801  183214346 3893339516 1928168445 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
        1337157619 3429096554 3275170900 1782047316 4264403756 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
        1876594403 4289659572 3223834894 1728705513 4068244734 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
        2867840287 1147798696  302879820 1730407747 1923824407 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
        1180597908 1569786639  198796327  560793173 2107345620 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
        2705990316 3448772106 3678374155  758635715  884524671 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
         486356516 1774865603 3881226226 2635213607 1181121587 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
        1508809820 3178988241 1594193633 1235154121  326117244 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
        2304031425  937054774 2687415945 3192389340 2003740439 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
        1823766188 2759543402   10067710 1533252662 4132494984 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
          82378136  420615890 3467563163  541562091 3535949864 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
        2277319197 3330822853 3215654174 4113831979 4204996991 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        2162248333 3255093522 2219088909 2978279037  255818579 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
        2859348628 3097280311 2569721123 1861951120 2907080079 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        2719467166  998319094 2521935127 2404125338  259456032 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        2086860995 1839848496 1893547357 2527997525 1489393124 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
        2860855349   76448234 2264934035  744914583 2586791259 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
        1385380501   66529922 1819103258 1899300332 2098173828 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
        1793831094  276463159  360132945 4178212058  595015228 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
         177071838 2800080290 1573557746 1548998935  378454223 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
        1460534296 1116274283 3112385063 3709761796  827999348 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
        3580042847 1913901014  614021289 4278528023 1905177404 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
          45407939 3298183234 1184848810 3644926330 3923635459 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
        1627046213 3677876759  969772772 1160524753 1522441192 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
         452369933 1527502551  832490847 1003299676 1071381111 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
        2891255476  973747308 4086897108 1847554542 3895651598 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
        2227820339 1621250941 2881344691 3583565821 3510404498 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
         849362119  862871471  797858058 2867774932 2821282612 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
        3272403146 3997979905  209178708 1805135652    6783381 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
        2823361423  792580494 4263749770  776439581 3798193823 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
        2853444094 2729507474 1071873341 1329010206 1289336450 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
        3327680758 2011491779   80157208  922428856 1158943220 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
        1667230961 2461022820 2608845159  387516115 3345351910 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
        1495629111 4098154157 3156649613 3525698599 4134908037 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
         446713264 2137537399 3617403512  813966752 1157943946 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
        3734692965 1680301658 3180398473 3509854711 2228114612 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
        1008102291  486805123  863791847 3189125290 1050308116 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
        3777341526 4291726501  844061465 1347461791 2826481581 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
         745465012 2055805750 4260209475 2386693097 2980646741 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
         447229436 2077782664 1232942813 4023002732 1399011509 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
        3140569849 2579909222 3794857471  900758066 2887199683 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
        1720257997 3367494931 2668921229  955539029 3818726432 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
        1105704962 3889207255 2277369307 2746484505 1761846513 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
        2413916784 2685127085 4240257943 1166726899 4215215715 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
        3082092067 3960461946 1663304043 2087473241 4162589986 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
        2507310778 1579665506  767234210  970676017  492207530 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
        1441679602 1314785090 3262202570 3417091742 1561989210 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
        3011406780 1146609202 3262321040 1374872171 1634688712 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
        1280458888 2230023982  419323804 3262899800   39783310 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
        1641619040 1700368658 2207946628 2571300939 2424079766 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
         780290914 2715195096 3390957695  163151474 2309534542 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
        1860018424  555755123  280320104 1604831083 2713022383 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
        1728987441 3639955502  623065489 3828630947 4275479050 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
        3516347383 2343951195 2430677756  635534992 3868699749 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
         808442435 3070644069 4282166003 2093181383 2023555632 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
        1568662086 3422372620 4134522350 3016979543 3259320234 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
        2888030729 3185253876 4258779643 1267304371 1022517473 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
         815943045  929020012 2995251018 3371283296 3608029049 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
        2018485115  122123397 2810669150 1411365618 1238391329 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
        1186786476 3155969091 2242941310 1765554882  279121160 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
        4279838515 1641578514 3796324015   13351065  103516986 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
        1609694427  551411743 2493771609 1316337047 3932650856 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
        4189700203  463397996 2937735066 1855616529 2626847990 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
          55091862 3823351211  753448970 4045045500 1274127772 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
        1124182256   92039808 2126345552  425973257  386287896 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
        2589870191 1987762798 4084826973 2172456685 3366583455 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
        3602966653 2378803535 2901764433 3716929006 3710159000 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
        2653449155 3469742630 3096444476 3932564653 2595257433 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
         318974657 3146202484  853571438  144400272 3768408841 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
         782634401 2161109003  570039522 1886241521   14249488 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
        2230804228 1604941699 3928713335 3921942509 2155806892 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
         134366254  430507376 1924011722  276713377  196481886 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
        3614810992 1610021185 1785757066  851346168 3761148643 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
        2918835642 3364422385 3012284466 3735958851 2643153892 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
        3778608231 1164289832  205853021 2876112231 3503398282 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
        3078397001 3472037921 1748894853 2740861475  316056182 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        1660426908  168885906  956005527 3984354789  566521563 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
        1001109523 1216710575 2952284757 3834433081 3842608301 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
        2467352408 3974441264 3256601745 1409353924 1329904859 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
        2307560293 3125217879 3622920184 3832785684 3882365951 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
        2308537115 2659155028 1450441945 3532257603 3186324194 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
        1225603425 1124246549  175808705 3009142319 2796710159 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
        3651990107  160762750 1902254979 1698648476 1134980669 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
         497144426 3302689335 4057485630 3603530763 4087252587 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
         427812652  286876201  823134128 1627554964 3745564327 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
        2589226092 4202024494   62878473 3275585894 3987124064 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
        2791777159 1916869511 2585861905 1375038919 1403421920 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
          60249114 3811870450 3021498009 2612993202  528933105 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
        2757361321 3341402964 2621861700  273128190 4015252178 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
        3094781002 1621621288 2337611177 1796718448 1258965619 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
        4241913140 2138560392 3022190223 4174180924  450094611 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
        3274724580  617150026 2704660665 1469700689 1341616587 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
         356715071 1188789960 2278869135 1766569160 2795896635 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
          57824704 2893496380 1235723989 1630694347 3927960522 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
         428891364 1814070806 2287999787 4125941184 3968103889 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
        3548724050 1025597707 1404281500 2002212197   92429143 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
        2313943944 2403086080 3006180634 3561981764 1671860914 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
        1768520622 1803542985  844848113 3006139921 1410888995 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
        1157749833 2125704913 1789979528 1799263423  741157179 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
        2405862309  767040434 2655241390 3663420179 2172009096 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
        2511931187 1680542666  231857466 1154981000  157168255 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
        1454112128 3505872099 1929775046 2309422350 2143329496 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
        2960716902  407610648 2938108129 2581749599  538837155 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
        2342628867  430543915  740188568 1937713272 3315215132 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
        2085587024 4030765687  766054429 3517641839  689721775 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
        1294158986 1753287754 4202601348 1974852792   33459103 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
        3568087535 3144677435 1686130825 4134943013 3005738435 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
        3599293386  426570142  754104406 3660892564 1964545167 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
         829466833  821587464 1746693036 1006492428 1595312919 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
        1256599985 1024482560 1897312280 2902903201  691790057 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
        1037515867 3176831208 1968401055 2173506824 1089055278 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
        1748401123 2941380082  968412354 1818753861 2973200866 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
        3875951774 1119354008 3988604139 1647155589 2232450826 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
        3486058011 3655784043 3759258462  847163678 1082052057 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
         989516446 2871541755 3196311070 3929963078  658187585 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
        3664944641 2175149170 2203709147 2756014689 2456473919 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
        3890267390 1293787864 2830347984 3059280931 4158802520 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
        1561677400 2586570938  783570352 1355506163   31495586 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
        3789437343 3340549429 2092501630  896419368  671715824 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
        3530450081 3603554138 1055991716 3442308219 1499434728 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
        3130288473 3639507000   17769680 2259741420  487032199 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
        4227143402 3693771256 1880482820 3924810796  381462353 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
        4017855991 2452034943 2736680833 2209866385 2128986379 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
         437874044  595759426  641721026 1636065708 3899136933 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
         629879088 3591174506  351984326 2638783544 2348444281 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
        2341604660 2123933692  143443325 1525942256  364660499 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
         599149312  939093251 1523003209  106601097  376589484 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
        1346282236 1297387043  764598052 3741218111  933457002 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
        1886424424 3219631016  525405256 3014235619  323149677 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
        2038881721 4100129043 2851715101 2984028078 1888574695 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
        2014194741 3515193880 4180573530 3461824363 2641995497 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
        3179230245 2902294983 2217320456 4040852155 1784656905 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
        3311906931   87498458 2752971818 2635474297 2831215366 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
        3682231106 2920043893 3772929704 2816374944  309949752 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
        2383758854  154870719  385111597 1191604312 1840700563 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
         872191186 2925548701 1310412747 2102066999 1504727249 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
        3574298750 1191230036 3330575266 3180292097 3539347721 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
         681369118 3305125752 3648233597  950049240 4173257693 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
        1760124957  512151405  681175196  580563018 1169662867 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
        4015033554 2687781101  699691603 2673494188 1137221356 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
         123599888  472658308 1053598179 1012713758 3481064843 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
        3759461013 3981457956 3830587662 1877191791 3650996736 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
         988064871 3515461600 4089077232 2225147448 1249609188 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
        2643151863 3896204135 2416995901 1397735321 3460025646 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    ) do:[:expected |
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
        |got|
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
        got := rnd nextInteger.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
        self assert:(got = expected)
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
                                                                                [exEnd]
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
! !
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
!RandomMT19937 class methodsFor:'instance creation'!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
new
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    ^ self basicNew 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
        initialize;
3389
25702635a819 better seeding
Claus Gittinger <cg@exept.de>
parents: 3355
diff changeset
   273
        initGenRand:(Random randomSeed bitAnd:16rFFFFFFFF)
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
new:seed
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    ^ self basicNew 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
        initialize;
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
        initGenRand:seed
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
newByArray:keyArray
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    ^ self basicNew 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
        initialize;
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
        initByArray:keyArray
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
! !
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
!RandomMT19937 methodsFor:'initialization'!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
initByArray:keyArray
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    |i j k kLen|
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    self initGenRand:19650218.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    kLen := keyArray size.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
    i := 1. j := 0.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    k := (n max: kLen).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    [k > 0] whileTrue:[
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
        |t|
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
        t := (((mt at:i+1) bitXor: (((mt at:i) bitXor: ((mt at:i) >> 30)) * 1664525))
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
                        + (keyArray at:j+1) + j). 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
        mt at:i+1 put:(t bitAnd:16rFFFFFFFF).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
        i := i+1. j := j+1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
        (i >= n) ifTrue:[ mt at:1 put:(mt at:n). i := 1. ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
        (j >= kLen) ifTrue:[ j := 0].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
        k := k - 1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
    ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
    k := n-1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    [k > 0] whileTrue:[
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
        |t|
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
        t := ((mt at:i+1) bitXor:(((mt at:i) bitXor: ((mt at:i) >> 30)) * 1566083941)) - i.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
        mt at:i+1 put:(t bitAnd:16rFFFFFFFF).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
        i := i+1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
        (i >= n) ifTrue:[ mt at:1 put:(mt at:n). i := 1. ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
        k := k - 1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
    ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    mt at:1 put:16r80000000. "/ MSB is 1; assuring non-zero initial array 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
initGenRand:seedUsed
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    |s|
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    s := seedUsed.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    mt at:1 put:(s bitAnd:16rFFFFFFFF). 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
    mti := 1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
    [mti < n] whileTrue:[
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
        |t|
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
3430
9f50ed777fd0 class: RandomMT19937
Claus Gittinger <cg@exept.de>
parents: 3429
diff changeset
   335
        t := (1812433253 * ((mt at:(mti)) bitXor:((mt at:(mti)) >> 30))) + mti.
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
        mt at:(mti+1) put:(t bitAnd:16rFFFFFFFF).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
        mti := mti + 1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
    ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
    "
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
     self new nextInteger
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
    "
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
initialize
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
    n := 624.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    m := 397.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    matrixA := 16r9908b0df.      "/ constant vector a
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    upperMask := 16r80000000.   "/ most significant w-r bits 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    lowerMask := 16r7fffffff.   "/ least significant r bits 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
    mt := Array new:n.          "/ the array for the state vector 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    mti := n + 1.               "/ mti==N+1 means mt[N] is not initialized */
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
! !
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
!RandomMT19937 methodsFor:'random numbers'!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
nextBoolean
3417
2568713fddf8 comments
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
   360
    "generates a boolean random"
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
    ^ self nextInteger > 16r7FFFFFFF
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
nextInteger
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    "generates the next integer in 0..FFFFFFFF"
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
    | y mag01 |
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
    mag01 := { 0 . matrixA }.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
    "/ mag01[x] = x * MATRIX_A  for x=0,1 */
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    (mti >= n) ifTrue:[ "/ generate N words at one time
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
        |kk|
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
        (mti == (n+1)) ifTrue:[     "/ if init_genrand() has not been called,
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
            self initGenRand:5489.      "/ a default initial seed is used
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
        ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
        kk := 0.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
        [kk < (n-m)] whileTrue:[
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
            y := ((mt at:kk+1) bitAnd:upperMask)
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
                    bitOr:((mt at:(kk+1+1)) bitAnd:lowerMask).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
            mt at:(kk+1) put:(((mt at:(kk+m+1)) bitXor:(y>>1)) bitXor: (mag01 at:(y bitAnd:1)+1)).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
            kk := kk + 1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
        ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
        [kk < (n-1)] whileTrue:[
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
            y := ((mt at:(kk+1)) bitAnd:upperMask)
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
                    bitOr:((mt at:(kk+1+1)) bitAnd:lowerMask).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
            mt at:(kk+1) put:(((mt at:(kk+(m-n)+1)) bitXor:(y>>1)) bitXor:(mag01 at:(y bitAnd:1)+1)).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
            kk := kk + 1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
        ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
        y := ((mt at:(n-1+1)) bitAnd:upperMask) bitOr:((mt at:1) bitAnd:lowerMask).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
        mt at:n-1+1 put:(((mt at:m) bitXor:(y>>1)) bitXor: (mag01 at:(y bitAnd:1)+1)).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
        mti := 0.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    ].
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
    y := mt at:(mti+1). mti := mti + 1.
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
    "/ Tempering 
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
    y := y bitXor:(y >> 11).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
    y := y bitXor:((y << 7) bitAnd: 16r9d2c5680).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
    y := y bitXor:((y << 15) bitAnd: 16refc60000).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
    y := y bitXor:(y >> 18).
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
    ^ y
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
! !
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
!RandomMT19937 class methodsFor:'documentation'!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
version
4591
2449ca90c3a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3430
diff changeset
   414
    ^ '$Header$'
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
!
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
version_CVS
4591
2449ca90c3a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 3430
diff changeset
   418
    ^ '$Header$'
3340
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
! !
8d3e3b5152c5 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420