note description: "[ Pseudo-random number sequence, linear congruential method This class is adapted from work in "Discrete-Event System Simulation" by Jerry Banks & John S. Carson, II Prentice-Hall International Series in Industrial and Systems Engineering 1984 Example 7.12 p 266 which is from IMSL Scientific Subroutine Package [1978], written in Fortran for IBM 360/370 computers. ]" library: "Free implementation of ELKS library" status: "See notice at end of class." legal: "See notice at end of class." names: random date: "$Date: 2018-11-14 14:55:55 +0000 (Wed, 14 Nov 2018) $" revision: "$Revision: 102462 $" class interface RANDOM create make, set_seed feature -- Initialization make -- Initialize structure using a default seed. ensure seed_set: seed = Default_seed set_seed (s: INTEGER_32) -- Initialize sequence using s as the seed. require non_negative: s >= 0 ensure seed_set: seed = s feature -- Access Default_seed: INTEGER_32 -- Default value 123,457; -- may be redefined for a new generator. Modulus: INTEGER_32 -- Default value 2^31 -1 = 2,147,483,647; -- may be redefined for a new generator. Multiplier: INTEGER_32 -- Default value 7^5 = 16,807; -- may be redefined for a new generator. Increment: INTEGER_32 -- Default value 0; -- may be redefined for a new generator. seed: INTEGER_32 -- Seed for sequence. next_random (n: INTEGER_32): INTEGER_32 -- Next random number after n -- in pseudo-random order require in_range: (n < Modulus) and (n >= 0) ensure in_range: (Result < Modulus) and (Result >= 0) has (n: INTEGER_32): BOOLEAN -- Will n be part of the random number sequence? ensure then only_: Result = (n < Modulus and n >= 0) i_th (i: INTEGER_32): INTEGER_32 -- The i-th random number ensure then in_range: (Result < Modulus) and (Result >= 0) real_item: REAL_32 -- The current random number as a real between 0 and 1 double_item: REAL_64 -- The current random number as a double between 0 and 1 real_i_th (i: INTEGER_32): REAL_32 -- The i-th random number as a real between 0 and 1 require positive_argument: i > 0 double_i_th (i: INTEGER_32): REAL_64 -- The i-th random number as a double between 0 and 1 require positive_argument: i > 0 feature -- Iteration new_cursor: RANDOM -- Fresh cursor associated with current structure invariant non_negative_seed: seed >= 0 non_negative_increment: Increment >= 0 positive_multiplier: Multiplier > 0 modulus_constraint: Modulus > 1 note copyright: "Copyright (c) 1984-2018, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class RANDOM
Generated by ISE EiffelStudio