INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Pseudo-random number sequence, linear congruential method"
title: "EiffelBase: library of reusable components for Eiffel. ", "Based on EiffelBase library for ISE Eiffel, ", "used with permission. "
project: "EiffelBase Library"
copyright: "(c) 1986-1997 Interactive Software Engineering Inc. ", "Modifications and extensions: ", "(c) 1997 Object Tools ", "All rights reserved. Duplication and distribution prohibited", "May be used only with Visual Eiffel under terms of user ", "license "
key: random
cluster: eiffelbase
class RANDOM
inherit

COUNTABLE_SEQUENCE [INTEGER]
redefine
has
end

DOUBLE_MATH
export
{NONE}
all
end
creation

make,
set_seed
feature -- Initialization

make
-- Initialize structure using a default seed.
ensure
seed_set: seed = default_seed

set_seed (s: INTEGER)
-- Initialize sequence using `s' as the `seed'.
require
non_negative: s >= 0
ensure
seed_set: seed = s
feature -- Access

default_seed: INTEGER
-- Default value 123,457;
-- may be redefined for a new generator.

modulus: INTEGER
-- Default value 2^31 -1 = 2,147,483,647;
-- may be redefined for a new generator.

multiplier: INTEGER
-- Default value 7^5 = 16,807;
-- may be redefined for a new generator.

increment: INTEGER
-- Default value 0;
-- may be redefined for a new generator.

seed: INTEGER

next_random (n: INTEGER): INTEGER
-- 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): BOOLEAN
-- Will `n' be part of the random number sequence?
ensure
only_: Result = (n < modulus and n >= 0)

i_th (i: INTEGER): INTEGER
-- The `i'-th random number
ensure
in_range: (Result < modulus) and (Result >= 0)

real_item: REAL
-- The current random number as a real between 0 and  1

double_item: DOUBLE
-- The current random number as a double between 0 and 1

real_i_th (i: INTEGER): REAL
-- The `i'-th random number as a real between 0 and  1

double_i_th (i: INTEGER): DOUBLE
-- The `i'-th random number as a double between 0 and 1
invariant

non_negative_seed: seed >= 0
non_negative_increment: increment >= 0
positive_multiplier: multiplier > 0
modulus_constraint: modulus > 1
end -- class RANDOM

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES