Changeset 13328


Ignore:
Timestamp:
Dec 22, 2009, 7:53:59 PM (10 years ago)
Author:
rme
Message:

Remove now unused code implementing old random number generator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/PPC/ppc-numbers.lisp

    r13327 r13328  
    1919
    2020(in-package "CCL")
    21 
    22 ;(push (cons 'number-case 1) *fred-special-indent-alist*) do later
    23 
    24 
    2521
    2622(defppclapfunction %fixnum-signum ((number arg_z))
     
    274270  (eq->boolean arg_z imm0 imm1 imm0)
    275271  (blr))
    276  
    277 
    278 
    279 
    280 
    281 
    282 
    283 
    284 #|
    285 Date: Mon, 3 Feb 1997 10:04:08 -0500
    286 To: info-mcl@digitool.com, wineberg@franz.scs.carleton.ca
    287 From: dds@flavors.com (Duncan Smith)
    288 Subject: Re: More info on the random number generator
    289 Sender: owner-info-mcl@digitool.com
    290 Precedence: bulk
    291 
    292 The generator is a Linear Congruential Generator:
    293 
    294    X[n+1] = (aX[n] + c) mod m
    295 
    296 where: a = 16807  (Park&Miller recommend 48271)
    297        c = 0
    298        m = 2^31 - 1
    299 
    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 mod
    305 2^n-1 is easy.  See Knuth Ch. 4.3.2 (2nd Ed. p 272).
    306 
    307     ab mod m = ...
    308 
    309 If         m = 2^n-1
    310            u = ab mod 2^n
    311            v = floor( ab / 2^n )
    312 
    313     ab mod m = u + v                   :  u+v < 2^n
    314     ab mod m = ((u + v) mod 2^n) + 1   :  u+v >= 2^n
    315 
    316 What we do is use 2b and 2^n so we can do arithemetic mod 2^32 instead of
    317 2^31.  This reduces the whole generator to 5 instructions on the 680x0 or
    318 80x86, and 8 on the 60x.
    319 
    320 -Duncan
    321 
    322 |#
    323 ; Use the two fixnums in state to generate a random fixnum >= 0 and < 65536
    324 ; Scramble those fixnums up a bit.
    325 
    326 #+ppc32-target
    327 (defppclapfunction %next-random-pair ((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   (set-nargs 2)
    340   (ba .SPvalues))
    341 
    342 
    343 
    344 
    345 
    346 
    347 
    348 
    349272
    350273;;; n1 and n2 must be positive (esp non zero)
Note: See TracChangeset for help on using the changeset viewer.