Changeset 13328
 Timestamp:
 Dec 22, 2009, 7:53:59 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/source/level0/PPC/ppcnumbers.lisp
r13327 r13328 19 19 20 20 (inpackage "CCL") 21 22 ;(push (cons 'numbercase 1) *fredspecialindentalist*) do later23 24 25 21 26 22 (defppclapfunction %fixnumsignum ((number arg_z)) … … 274 270 (eq>boolean arg_z imm0 imm1 imm0) 275 271 (blr)) 276 277 278 279 280 281 282 283 284 #285 Date: Mon, 3 Feb 1997 10:04:08 0500286 To: infomcl@digitool.com, wineberg@franz.scs.carleton.ca287 From: dds@flavors.com (Duncan Smith)288 Subject: Re: More info on the random number generator289 Sender: ownerinfomcl@digitool.com290 Precedence: bulk291 292 The generator is a Linear Congruential Generator:293 294 X[n+1] = (aX[n] + c) mod m295 296 where: a = 16807 (Park&Miller recommend 48271)297 c = 0298 m = 2^31  1299 300 See: Knuth, Seminumerical Algorithms (Volume 2), Chapter 3.301 302 The period is: 2^31  2 (zero is excluded).303 304 What makes this generator so simple is that multiplication and addition mod305 2^n1 is easy. See Knuth Ch. 4.3.2 (2nd Ed. p 272).306 307 ab mod m = ...308 309 If m = 2^n1310 u = ab mod 2^n311 v = floor( ab / 2^n )312 313 ab mod m = u + v : u+v < 2^n314 ab mod m = ((u + v) mod 2^n) + 1 : u+v >= 2^n315 316 What we do is use 2b and 2^n so we can do arithemetic mod 2^32 instead of317 2^31. This reduces the whole generator to 5 instructions on the 680x0 or318 80x86, and 8 on the 60x.319 320 Duncan321 322 #323 ; Use the two fixnums in state to generate a random fixnum >= 0 and < 65536324 ; Scramble those fixnums up a bit.325 326 #+ppc32target327 (defppclapfunction %nextrandompair ((high arg_y) (low arg_z))328 (slwi imm0 high ( 16 ppc32::fixnumshift))329 (rlwimi imm0 low ( 32 ppc32::fixnumshift) 16 31)330 (lwi imm1 48271)331 (clrlwi imm0 imm0 1)332 (mullw imm0 imm1 imm0)333 (clrrwi arg_y imm0 16 )334 (srwi arg_y arg_y ( 16 ppc32::fixnumshift))335 (clrlslwi arg_z imm0 16 ppc32::fixnumshift)336 (mr temp0 vsp)337 (vpush arg_y)338 (vpush arg_z)339 (setnargs 2)340 (ba .SPvalues))341 342 343 344 345 346 347 348 349 272 350 273 ;;; n1 and n2 must be positive (esp non zero)
Note: See TracChangeset
for help on using the changeset viewer.