The library provides functions for reading and writing two dimensional histograms to a file as binary data or formatted text.
GSL_EFAILED
if there was a problem writing to the file. Since
the data is written in the native binary format it may not be portable
between different architectures.
GSL_EFAILED
if there was a problem
reading from the file. The data is assumed to have been written in the
native binary format on the same architecture.
%g
, %e
or %f
formats for floating point
numbers. The function returns 0 for success and GSL_EFAILED
if
there was a problem writing to the file. The histogram output is
formatted in five columns, and the columns are separated by spaces,
like this,
xrange[0] xrange[1] yrange[0] yrange[1] bin(0,0) xrange[0] xrange[1] yrange[1] yrange[2] bin(0,1) xrange[0] xrange[1] yrange[2] yrange[3] bin(0,2) .... xrange[0] xrange[1] yrange[ny-1] yrange[ny] bin(0,ny-1) xrange[1] xrange[2] yrange[0] yrange[1] bin(1,0) xrange[1] xrange[2] yrange[1] yrange[2] bin(1,1) xrange[1] xrange[2] yrange[1] yrange[2] bin(1,2) .... xrange[1] xrange[2] yrange[ny-1] yrange[ny] bin(1,ny-1) .... xrange[nx-1] xrange[nx] yrange[0] yrange[1] bin(nx-1,0) xrange[nx-1] xrange[nx] yrange[1] yrange[2] bin(nx-1,1) xrange[nx-1] xrange[nx] yrange[1] yrange[2] bin(nx-1,2) .... xrange[nx-1] xrange[nx] yrange[ny-1] yrange[ny] bin(nx-1,ny-1)
Each line contains the lower and upper limits of the bin and the contents of the bin. Since the upper limits of the each bin are the lower limits of the neighboring bins there is duplication of these values but this allows the histogram to be manipulated with line-oriented tools.
gsl_histogram_fprintf
. The histogram h must be
preallocated with the correct lengths since the function uses the sizes
of h to determine how many numbers to read. The function returns 0
for success and GSL_EFAILED
if there was a problem reading from
the file.