function r = randSSL(p,q)

% Multiplicative congruential uniform random number generator.
% This function uses the "bad" generator parameters that IBM
% used in its Scientific Subroutine Library in the 1960's. 
% There is a strong correlation between three consecutive values.
%  
% r = randSSL
% generates a single random number.
%
% r = randSSL(m,n)
% generates an m-by-n random matrix.
% 
% clear randSSL
% reinitializes the generator.
%  
% Seeds are set by editing this file.
%
%  See also RANDEX, RANDMC.

persistent a c m x

if isempty(x)
   a = 2^16+3;
   c = 0;
   m = 2^31;
   x = 123456789;
end

if nargin < 1, p = 1; end

if nargin < 2, q = p; end

r = zeros(p,q); %Preallocate memory
for k = 1:p*q
   x = rem(a*x + c, m);
   r(k) = x/m;
end