function [ r, seed ] = r8mat_uniform_01 ( m, n, seed ) %*****************************************************************************80 % %% R8MAT_UNIFORM_01 returns a unit pseudorandom R8MAT. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 21 September 2006 % % Author: % % John Burkardt % % Reference: % % Paul Bratley, Bennett Fox, Linus Schrage, % A Guide to Simulation, % Springer Verlag, pages 201-202, 1983. % % Bennett Fox, % Algorithm 647: % Implementation and Relative Efficiency of Quasirandom % Sequence Generators, % ACM Transactions on Mathematical Software, % Volume 12, Number 4, pages 362-376, 1986. % % Peter Lewis, Allen Goodman, James Miller, % A Pseudo-Random Number Generator for the System/360, % IBM Systems Journal, % Volume 8, pages 136-143, 1969. % % Parameters: % % Input, integer M, N, the number of rows and columns in the array. % % Input, integer SEED, the integer "seed" used to generate % the output random number. % % Output, real R(M,N), an array of random values between 0 and 1. % % Output, integer SEED, the updated seed. This would % normally be used as the input seed on the next call. % if ( seed == 0 ) fprintf ( 1, '\n' ); fprintf ( 1, 'R8MAT_UNIFORM_01 - Fatal error!\n' ); fprintf ( 1, ' Input SEED = 0!\n' ); error ( 'R8MAT_UNIFORM_01 - Fatal error!' ); end for j = 1 : n for i = 1 : m seed = floor ( seed ); seed = mod ( seed, 2147483647 ); if ( seed < 0 ) seed = seed + 2147483647; end k = floor ( seed / 127773 ); seed = 16807 * ( seed - k * 127773 ) - k * 2836; if ( seed < 0 ) seed = seed + 2147483647; end r(i,j) = seed * 4.656612875E-10; end end return end