From ce409efc6b4f87edc9f703ae3e81df89f619b78a Mon Sep 17 00:00:00 2001 From: Thierry Moisan Date: Sat, 16 Aug 2008 16:57:09 -0400 Subject: [PATCH] Changing the fopen function in docs for gsl_fopen --- Combination.i | 9 ++++----- Histogram.i | 11 +++++------ Histogram2D.i | 11 +++++------ Matrix.i | 15 +++++++-------- Permutation.i | 12 +++++++----- RNG.i | 7 +++---- Vector.i | 13 +++++++------ 7 files changed, 38 insertions(+), 40 deletions(-) diff --git a/Combination.i b/Combination.i index 32033c1..9c21cec 100644 --- a/Combination.i +++ b/Combination.i @@ -1,6 +1,5 @@ %module "Math::GSL::Combination" -FILE * fopen(char *, char *); int fclose(FILE *); %{ @@ -13,7 +12,7 @@ int fclose(FILE *); %perlcode %{ -@EXPORT_OK = qw/fopen fclose +@EXPORT_OK = qw/fclose gsl_combination_alloc gsl_combination_calloc gsl_combination_init_first @@ -64,11 +63,11 @@ Here is a list of all the functions in this module : =item * C - This function returns the value of the i-th element of the combination $c. If $i lies outside the allowed range of 0 to k-1 then the error handler is invoked and 0 is returned. -=item * C - This function writes the elements of the combination $c to the stream $stream, opened with the fopen function, in binary format. The function returns $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. +=item * C - This function writes the elements of the combination $c to the stream $stream, opened with the gsl_fopen function from the Math::GSL module, in binary format. The function returns $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. -=item * C - This function reads elements from the open stream $stream, opened with the fopen function into the combination $c in binary format. The combination $c must be preallocated with correct values of n and k since the function uses the size of $c to determine how many bytes to read. The function returns $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. +=item * C - This function reads elements from the open stream $stream, opened with the gsl_fopen function from the Math::GSL module, into the combination $c in binary format. The combination $c must be preallocated with correct values of n and k since the function uses the size of $c to determine how many bytes to read. The function returns $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. -=item * C - This function writes the elements of the combination $c line-by-line to the stream $stream, opened with the fopen function, using the format specifier $format, which should be suitable for a type of size_t. In ISO C99 the type modifier z represents size_t, so "%zu\n" is a suitable format. The function returns $GSL_EFAILED if there was a problem writing to the file. +=item * C - This function writes the elements of the combination $c line-by-line to the stream $stream, opened with the gsl_fopen function from the Math::GSL module, using the format specifier $format, which should be suitable for a type of size_t. In ISO C99 the type modifier z represents size_t, so "%zu\n" is a suitable format. The function returns $GSL_EFAILED if there was a problem writing to the file. =item * C -This function reads formatted data from the stream $stream into the combination $c. The combination $c must be preallocated with correct values of n and k since the function uses the size of $c to determine how many numbers to read. The function returns $GSL_EFAILED if there was a problem reading from the file. diff --git a/Histogram.i b/Histogram.i index b3381be..068dacf 100644 --- a/Histogram.i +++ b/Histogram.i @@ -4,7 +4,6 @@ %apply double *OUTPUT { double * lower, double * upper, size_t * i}; -FILE * fopen(char *, char *); int fclose(FILE *); %{ @@ -15,7 +14,7 @@ int fclose(FILE *); %perlcode %{ -@EXPORT_OK = qw/fopen fclose +@EXPORT_OK = qw/fclose gsl_histogram_alloc gsl_histogram_calloc gsl_histogram_calloc_uniform @@ -168,11 +167,11 @@ where d is the bin spacing, d = (xmax-xmin)/n. =item C - This function returns the sum of all bin values. Negative bin values are included in the sum. -=item C - This function writes the ranges and bins of the histogram $h to the stream $stream, which has been opened by the fopen function, in binary format. The return value is 0 for success and $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. +=item C - This function writes the ranges and bins of the histogram $h to the stream $stream, which has been opened by the gsl_fopen function from the Math::GSL module, in binary format. The return value is 0 for success and $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. -=item C - This function reads into the histogram $h from the open stream stream in binary format. The histogram $h must be preallocated with the correct size since the function uses the number of bins in $h to determine how many bytes to read. The return value is 0 for success and $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. +=item C - This function reads into the histogram $h from the open stream $stream, which has been opened by the gsl_fopen function from the Math::GSL module, in binary format. The histogram $h must be preallocated with the correct size since the function uses the number of bins in $h to determine how many bytes to read. The return value is 0 for success and $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. -=item C - This function writes the ranges and bins of the histogram $h line-by-line to the stream $stream (from the fopen function) using the format specifiers $range_format and $bin_format. These should be one of the %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 three columns, and the columns are separated by spaces, like this, +=item C - This function writes the ranges and bins of the histogram $h line-by-line to the stream $stream (from the gsl_fopen function from the Math::GSL module) using the format specifiers $range_format and $bin_format. These should be one of the %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 three columns, and the columns are separated by spaces, like this, =over @@ -190,7 +189,7 @@ where d is the bin spacing, d = (xmax-xmin)/n. The values of the ranges are formatted using range_format and the value of the bins are formatted using bin_format. Each line contains the lower and upper limit of the range of the bins and the value of the bin itself. Since the upper limit of one bin is the lower limit of the next there is duplication of these values between lines but this allows the histogram to be manipulated with line-oriented tools. -=item C - This function reads formatted data from the stream $stream into the histogram $h. The data is assumed to be in the three-column format used by gsl_histogram_fprintf. The histogram $h must be preallocated with the correct length since the function uses the size 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. +=item C - This function reads formatted data from the stream $stream, which has been opened by the gsl_fopen function from the Math::GSL module, into the histogram $h. The data is assumed to be in the three-column format used by gsl_histogram_fprintf. The histogram $h must be preallocated with the correct length since the function uses the size 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. =item C - This function allocates memory for a probability distribution with $n bins and returns a pointer to a newly initialized gsl_histogram_pdf struct. If insufficient memory is available a null pointer is returned and the error handler is invoked with an error code of $GSL_ENOMEM. diff --git a/Histogram2D.i b/Histogram2D.i index 0c19cb8..f6f5158 100644 --- a/Histogram2D.i +++ b/Histogram2D.i @@ -5,7 +5,6 @@ %apply double *OUTPUT { double * xlower, double * xupper, double * ylower, double * yupper, double * x, double * y}; %apply int *OUTPUT { size_t * i, size_t * j }; -FILE * fopen(char *, char *); int fclose(FILE *); %{ @@ -16,7 +15,7 @@ int fclose(FILE *); %perlcode %{ -@EXPORT_OK = qw/fopen fclose +@EXPORT_OK = qw/fclose gsl_histogram2d_alloc gsl_histogram2d_calloc gsl_histogram2d_calloc_uniform @@ -172,11 +171,11 @@ Here is a list of all the functions included in this module : =item C - This function shifts the contents of the bins of histogram $h by the constant offset, i.e. h'_1(i,j) = h_1(i,j) + $offset. -=item C - This function writes the ranges and bins of the histogram $h to the stream $stream (opened with the fopen function) in binary format. The return value is 0 for success and $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. +=item C - This function writes the ranges and bins of the histogram $h to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The return value is 0 for success and $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. -=item C - This function reads into the histogram $h from the stream $stream (opened with the fopen function) in binary format. The histogram $h must be preallocated with the correct size since the function uses the number of x and y bins in $h to determine how many bytes to read. The return value is 0 for success and $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. +=item C - This function reads into the histogram $h from the stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The histogram $h must be preallocated with the correct size since the function uses the number of x and y bins in $h to determine how many bytes to read. The return value is 0 for success and $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. -=item C - This function writes the ranges and bins of the histogram $h line-by-line to the stream $stream (opened with the fopen function) using the format specifiers $range_format and $bin_format. These should be one of the %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, +=item C - This function writes the ranges and bins of the histogram $h line-by-line to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) using the format specifiers $range_format and $bin_format. These should be one of the %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, =over @@ -222,7 +221,7 @@ Here is a list of all the functions included in this module : 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. -=item C - This function reads formatted data from the stream $stream (opened with the fopen function) into the histogram $h. The data is assumed to be in the five-column format used by gsl_histogram2d_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. +=item C - This function reads formatted data from the stream $stream (opened with the gsl_fopen function from the Math::GSL module) into the histogram $h. The data is assumed to be in the five-column format used by gsl_histogram2d_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. =item C - This function allocates memory for a two-dimensional probability distribution of size $nx-by-$ny and returns a pointer to a newly initialized gsl_histogram2d_pdf struct. If insufficient memory is available a null pointer is returned and the error handler is invoked with an error code of $GSL_ENOMEM. diff --git a/Matrix.i b/Matrix.i index 303c006..f04b552 100644 --- a/Matrix.i +++ b/Matrix.i @@ -5,7 +5,6 @@ %apply int *OUTPUT { size_t *imin, size_t *imax, size_t *jmin, size_t *jmax }; %apply double *OUTPUT { double * min_out, double * max_out }; -FILE * fopen(char *, char *); int fclose(FILE *); %{ @@ -34,7 +33,7 @@ use Carp qw/croak/; use Math::GSL qw/:all/; use Math::GSL::Errno qw/:all/; -@EXPORT_OK = qw/fopen fclose +@EXPORT_OK = qw/fclose gsl_matrix_alloc gsl_matrix_calloc gsl_matrix_alloc_from_block gsl_matrix_alloc_from_matrix gsl_vector_alloc_row_from_matrix gsl_vector_alloc_col_from_matrix gsl_matrix_free gsl_matrix_submatrix @@ -619,13 +618,13 @@ Here is a list of all the functions included in this module : =item C - Set all the elements of the matrix $m to the value $x -=item C - Read a file which has been written with gsl_matrix_fwrite from the stream $fh opened with the fopen function and stores the data inside the matrix $m +=item C - Read a file which has been written with gsl_matrix_fwrite from the stream $fh opened with the gsl_fopen function from the Math::GSL module and stores the data inside the matrix $m -=item C - Write the elements of the matrix $m in binary format to a stream $fh opened with the fopen function +=item C - Write the elements of the matrix $m in binary format to a stream $fh opened with the gsl_fopen function from the Math::GSL module -=item C - Read a file which has been written with gsl_matrix_fprintf from the stream $fh opened with the fopen function and stores the data inside the matrix $m +=item C - Read a file which has been written with gsl_matrix_fprintf from the stream $fh opened with the gsl_fopenfunction from the Math::GSL module and stores the data inside the matrix $m -=item C - Write the elements of the matrix $m in the format $format (for example "%f" is the format for double) to a stream $fh opened with the fopen function +=item C - Write the elements of the matrix $m in the format $format (for example "%f" is the format for double) to a stream $fh opened with the gsl_fopen function from the Math::GSL module =item C - Copy the elements of the matrix $src to the matrix $dest. The two matrices must have the same size. @@ -1155,11 +1154,11 @@ Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/na The next program shows how to write a matrix to a file. - my $out = fopen("test.dat", "wb"); + my $out = gsl_fopen("test.dat", "wb"); gsl_matrix_fwrite ($out, $m); fclose ($out); - my $in = fopen("test.dat", "rb"); + my $in = gsl_fopen("test.dat", "rb"); gsl_matrix_fread ($in, $a); fclose($in); diff --git a/Permutation.i b/Permutation.i index f5110d2..6c74665 100644 --- a/Permutation.i +++ b/Permutation.i @@ -2,6 +2,8 @@ %include "typemaps.i" %include "gsl_typemaps.i" +int fclose(FILE *); + %{ #include "gsl/gsl_permute.h" #include "gsl/gsl_permute_double.h" @@ -20,7 +22,7 @@ %include "gsl/gsl_permutation.h" %perlcode %{ -@EXPORT_OK = qw/fopen fclose +@EXPORT_OK = qw/fclose gsl_permutation_alloc gsl_permutation_calloc gsl_permutation_init @@ -114,13 +116,13 @@ Here is a list of all the functions included in this module : =item gsl_permutation_memcpy($dest, $src) - copy the permutation $src into the permutation $dest, the two permutations must have the same lenght and return 0 if the operation suceeded, 1 otherwise -=item gsl_permutation_fread($stream, $p) - This function reads into the permutation $p from the open stream $stream (opened with the fopen function) in binary format. The permutation $p must be preallocated with the correct length since the function uses the size of $p to determine how many bytes to read. The function returns 1 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. +=item gsl_permutation_fread($stream, $p) - This function reads into the permutation $p from the open stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The permutation $p must be preallocated with the correct length since the function uses the size of $p to determine how many bytes to read. The function returns 1 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. -=item gsl_permutation_fwrite($stream, $p) - This function writes the elements of the permutation $p to the stream $stream (opened with the fopen function) in binary format. The function returns 1 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. +=item gsl_permutation_fwrite($stream, $p) - This function writes the elements of the permutation $p to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The function returns 1 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. -=item gsl_permutation_fscanf($stream, $p) - This function reads formatted data from the stream $stream into the permutation $p. The permutation $p must be preallocated with the correct length since the function uses the size of $p to determine how many numbers to read. The function returns 1 if there was a problem reading from the file. +=item gsl_permutation_fscanf($stream, $p) - This function reads formatted data from the stream $stream (opened with the gsl_fopen function from the Math::GSL module) into the permutation $p. The permutation $p must be preallocated with the correct length since the function uses the size of $p to determine how many numbers to read. The function returns 1 if there was a problem reading from the file. -=item gsl_permutation_fprintf($stream, $p, $format) - This function writes the elements of the permutation $p line-by-line to the stream $stream (opened with the fopen function) using the format specifier $format, which should be suitable. "%zu\n" is a suitable format. The function returns 1 if there was a problem writing to the file. +=item gsl_permutation_fprintf($stream, $p, $format) - This function writes the elements of the permutation $p line-by-line to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) using the format specifier $format, which should be suitable. "%zu\n" is a suitable format. The function returns 1 if there was a problem writing to the file. =item gsl_permutation_size($p) - return the size of the permutation $p diff --git a/RNG.i b/RNG.i index 1f90ac0..c34c441 100644 --- a/RNG.i +++ b/RNG.i @@ -6,11 +6,10 @@ %include "gsl/gsl_rng.h" -FILE *fopen(char *, char *); int fclose(FILE *); %perlcode %{ -@EXPORT_OK = qw/ fopen fclose +@EXPORT_OK = qw/ fclose gsl_rng_alloc gsl_rng_set gsl_rng_get gsl_rng_free gsl_rng_memcpy gsl_rng_fwrite gsl_rng_fread gsl_rng_clone gsl_rng_max gsl_rng_min gsl_rng_name gsl_rng_size gsl_rng_state gsl_rng_print_state gsl_rng_uniform gsl_rng_uniform_pos gsl_rng_uniform_int @@ -144,9 +143,9 @@ __END__ =item gsl_rng_uniform_int($r, $n) - This function returns a random integer from 0 to $n-1 inclusive by scaling down and/or discarding samples from the generator $r. All integers in the range [0,$n-1] are produced with equal probability. For generators with a non-zero minimum value an offset is applied so that zero is returned with the correct probability. Note that this function is designed for sampling from ranges smaller than the range of the underlying generator. The parameter $n must be less than or equal to the range of the generator $r. If $n is larger than the range of the generator then the function calls the error handler with an error code of $GSL_EINVAL and returns zero. In particular, this function is not intended for generating the full range of unsigned integer values [0,2^32-1]. Instead choose a generator with the maximal integer range and zero mimimum value, such as $gsl_rng_ranlxd1, $gsl_rng_mt19937 or $gsl_rng_taus, and sample it directly using gsl_rng_get. The range of each generator can be found using the auxiliary functions described in the next section. -=item gsl_rng_fwrite($stream, $r) - This function writes the random number state of the random number generator $r to the stream $stream (opened with the fopen function) in binary format. The return value is 0 for success and $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. +=item gsl_rng_fwrite($stream, $r) - This function writes the random number state of the random number generator $r to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The return value is 0 for success and $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. -=item gsl_rng_fread($stream, $r) - This function reads the random number state into the random number generator $r from the open stream $stream (opened with the fopen function) in binary format. The random number generator $r must be preinitialized with the correct random number generator type since type information is not saved. The return value is 0 for success and $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. +=item gsl_rng_fread($stream, $r) - This function reads the random number state into the random number generator $r from the open stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The random number generator $r must be preinitialized with the correct random number generator type since type information is not saved. The return value is 0 for success and $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. =item gsl_rng_clone($r) - This function returns a pointer to a newly created generator which is an exact copy of the generator $r. diff --git a/Vector.i b/Vector.i index 20a088e..f64d0f7 100644 --- a/Vector.i +++ b/Vector.i @@ -57,7 +57,7 @@ use overload fallback => 1, ; -@EXPORT_OK = qw/fopen fclose +@EXPORT_OK = qw/ gsl_vector_alloc gsl_vector_calloc gsl_vector_alloc_from_block gsl_vector_alloc_from_vector gsl_vector_free gsl_vector_view_array gsl_vector_const_view_array gsl_vector_view_array_with_stride gsl_vector_const_view_array_with_stride gsl_vector_subvector gsl_vector_subvector_wi gsl_vector_subvector_with_stride @@ -91,7 +91,8 @@ use overload gsl_vector_complex_fprintf gsl_vector_complex_memcpy gsl_vector_complex_reverse gsl_vector_complex_swap gsl_vector_complex_swap_elements gsl_vector_complex_isnull gsl_vector_complex_ispos gsl_vector_complex_isneg /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); +@EXPORT_fopen_flocse =qw/ fopen fclose/; +%EXPORT_TAGS = ( all => [ @EXPORT_OK ], fopen_fclose => [@EXPORT_fopen_flose] ); =head1 NAME @@ -326,13 +327,13 @@ Here is a list of all the functions included in this module : =item C - set all the elements of $v to 0 except for the $i-th element which is set to 1 and return 0 if the operation succeded, 1 otherwise. -=item C - This function reads into the vector $v from the open stream $file opened with fopen in binary format. The vector $v must be preallocated with the correct length since the function uses the size of $v to determine how many bytes to read. The return value is 0 for success and 1 if there was a problem reading from the file. +=item C - This function reads into the vector $v from the open stream $file opened with gsl_fopen function from the Math::GSL module in binary format. The vector $v must be preallocated with the correct length since the function uses the size of $v to determine how many bytes to read. The return value is 0 for success and 1 if there was a problem reading from the file. -=item C - This function writes the elements of the vector $v to the stream $file opened with fopen in binary format. The return value is 0 for success and 1 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. +=item C - This function writes the elements of the vector $v to the stream $file opened with gsl_fopen function from the Math::GSL module in binary format. The return value is 0 for success and 1 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. -=item C This function reads formatted data from the stream $file opened with fopen into the vector $v. The vector $v must be preallocated with the correct length since the function uses the size of $v to determine how many numbers to read. The function returns 0 for success and 1 if there was a problem reading from the file. +=item C This function reads formatted data from the stream $file opened with gsl_fopen function from the Math::GSL module into the vector $v. The vector $v must be preallocated with the correct length since the function uses the size of $v to determine how many numbers to read. The function returns 0 for success and 1 if there was a problem reading from the file. -=item C -This function writes the elements of the vector $v line-by-line to the stream $file opened with fopen using the format specifier format, which should be one of the "%g", "%e" or "%f" formats for floating point numbers and "%d" for integers. The function returns 0 for success and 1 if there was a problem writing to the file. +=item C -This function writes the elements of the vector $v line-by-line to the stream $file opened with gsl_fopen function from the Math::GSL module using the format specifier $format, which should be one of the "%g", "%e" or "%f" formats for floating point numbers and "%d" for integers. The function returns 0 for success and 1 if there was a problem writing to the file. =item C - This function copies the elements of the vector $src into the vector $dest and return 0 if the opertaion succeded, 1 otherwise. The two vectors must have the same length. -- 2.11.4.GIT