function r8mat_uniform_write ( ndim, n, seed, r, file_out_name ) %% R8MAT_UNIFORM_WRITE writes a pseudorandom R8MAT to a file. % % Discussion: % % The initial lines of the file are comments, which begin with a % '#' character. % % Thereafter, each line of the file contains the NDIM-dimensional % components of the next entry in the dataset. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 21 September 2006 % % Author: % % John Burkardt % % Parameters: % % Input, integer NDIM, the spatial dimension. % % Input, integer N, the number of elements in the subsequence. % % Input, integer SEED, the seed for the random number generator. % % Input, real R(NDIM,N), the points. % % Input, string FILE_OUT_NAME, the name of the output file. % file_out_unit = fopen ( file_out_name, 'w' ); if ( file_out_unit < 0 ) fprintf ( 1, '\n' ); fprintf ( 1, 'R8MAT_UNIFORM_WRITE - Fatal error!\n' ); fprintf ( 1, ' Could not open the output file:\n' ); fprintf ( 1, ' "%s".\n', file_out_name ); error ( 'UNIFORM_WRITE - Fatal error!' ); end today = timestring; fprintf ( file_out_unit, '# %s\n', file_out_name ); fprintf ( file_out_unit, '# created by R8MAT_UNIFORM_WRITE.M\n' ); fprintf ( file_out_unit, '#\n' ); fprintf ( file_out_unit, '# File generated on %s\n', timestring ); fprintf ( file_out_unit, '#\n' ); fprintf ( file_out_unit, '# NDIM = %d\n', ndim ); fprintf ( file_out_unit, '# N = %d\n', n ); fprintf ( file_out_unit, '# SEED = %d\n', seed ); fprintf ( file_out_unit, '# EPSILON (unit roundoff ) = %e\n', ... r8_epsilon ( ) ); fprintf ( file_out_unit, '#\n' ); for j = 1 : n for i = 1 : ndim fprintf ( file_out_unit, ' %10f', r(i,j) ); end fprintf ( file_out_unit, '\n' ); end fclose ( file_out_unit ); return end