Class SysDraw

java.lang.Object
svm.env.SysDraw

public abstract class SysDraw extends Object

Random drawing procedures

Link to GitHub: Source File.

Author:
Simula Standard, S-Port: The Environment Interface, Øystein Myhre Andersen
  • Field Details

    • TWO_POW_31

      private static final int TWO_POW_31
      Utility constant: 2**31
      See Also:
    • TWO_POW_31M1D

      private static final double TWO_POW_31M1D
      Utility constant: 2**31 - 1
      See Also:
    • MULTIPLIER

      private static final int MULTIPLIER
      Utility constant: 5**(2*6+1)
      See Also:
  • Constructor Details

    • SysDraw

      public SysDraw()
      Default Constructor
  • Method Details

    • drawrp

      public static void drawrp()

      Procedure basicDRAW.

      Visible sysroutine("DRAWRP") DRAWRP; -- cannot change STATUS
      import name(integer) u; export long real val  end;
      
      Runtime Stack
         ..., u'oaddr, u'ofst →
         ..., val
      

      param u: The pseudo random number (seed) by name. Returns the next pseudorandom, uniformly distributed value between 0.0 and 1.0 which is pushed onto the Runtime stack.

      The routine will replace the value of the specified integer variable U by a new value according to an implementation defined algorithm, which satisfy the condition stated in the Simula standard 9.9.1

      For positive values of U a linear congruential sequence:

      U(i+1) = remainder ((U(i) * 5**(2*p+1)) // 2**n)
      
      is used with n=31 and p=6: 5**(2*6+1) = 1220703125.
      
      The returned real number is computed as U(i+1) / (2**n-1)
      

      If U is negative a socalled "antithetic drawing" should be obtained by computing U' and val' from -U in the same manner as for positive U.

      The new values will then be

      U' = remainder (( -U(i) * 5**(2*p+1)) // 2**n )
      U(i+1) = - U'
      return val' = 1.0 - U' / (2**n-1)
      

      In this case the new value of U will also be negative, while the returned real still lies in the interval <0,1>.

      If the initial U is zero, U is replaced by System.currentTimeMillis() Then U is forced to be an odd number by: U = U | 1

      See: Donald E. Knuth, The Art of Computer Programming, Volume 2, Seminumerical Algorithms, Section 3.2.1.