This file is indexed.

/usr/share/axiom-20170501/src/algebra/RANDSRC.spad is in axiom-source 20170501-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
)abbrev package RANDSRC RandomNumberSource
++ Author:S.M.Watt
++ Date Created: April 87
++ Date Last Updated:Jan 92, May 1995 (MCD)
++ Description:
++ Random number generators.
++ All random numbers used in the system should originate from
++ the same generator.  This package is intended to be the source.
--
--  Possible improvements:
--  1) Start where the user left off
--  2) Be able to switch between methods in the random number source.

RandomNumberSource() : SIG == CODE where

  SIG ==> with

    randnum : () -> Integer
      ++ randnum() is a random number between 0 and size().
      ++ If r := randnum() then  0 <= r < size().

    size : () -> Integer
      ++ size() is the base of the random number generator
      ++ If r := randnum n and n <= size()  then  0 <= r < n.

    randnum : Integer -> Integer
      ++ randnum(n) is a random number between 0 and n.

    reseed : Integer -> Void
      ++ reseed(n) restarts the random number generator at n.

    seed : () -> Integer
      ++ seed() returns the current seed value.
 
  CODE ==> add

        -- This random number generator passes the spectral test
        -- with flying colours. [Knuth vol2, 2nd ed, p105]
        ranbase: Integer := 2**31-1
        x0:   Integer := 1231231231
        x1:   Integer := 3243232987
 
        randnum() ==
            t := (271828183 * x1 - 314159269 * x0) rem ranbase
            if t < 0 then t := t + ranbase
            x0:= x1
            x1:= t
 
        size() == ranbase

        reseed n ==
            x0 := n rem ranbase
            -- x1 := (n quo ranbase) rem ranbase
            x1 := n quo ranbase

        seed() == x1*ranbase + x0
 
        -- Compute an integer in 0..n-1.
        randnum n ==
            (n * randnum()) quo ranbase