NAME
Math::GSL::Combination - Combinations
SYNOPSIS
use Math::GSL qw/:all/;use Math::GSL::Combination qw/:all/;my $c = Math::GSL::Combination->new(6,3);print join (" ", $c->as_list) . "\n";$c->next;print join (" ", $c->as_list) . "\n";my $fd = gsl_fopen('combination.dat', 'w');gsl_combination_fwrite($fd, $c->raw);gsl_fclose($fd);
DESCRIPTION
Here is a list of all the functions in this module :
- •
-
"gsl_combination_alloc($n, $k)"This function allocates memory for a new combination with parameters
$n,$k. The combination is not initialized and its elements are undefined. Use the function gsl_combination_calloc if you want to create a combination which is initialized to the lexicographically first combination.
- •
-
"gsl_combination_calloc($n, $k)"This function allocates memory for a new combination with parameters
$n,$kand initializes it to the lexicographically first combination.
- •
-
gsl_combination_init_first($c)This function initializes the combination
$cto the lexicographically first combination, i.e. (0,1,2,...,k-1).
- •
-
gsl_combination_init_last($c)This function initializes the combination
$cto the lexicographically last combination, i.e. (n-k,n-k+1,...,n-1).
- •
-
gsl_combination_free($c)This function frees all the memory used by the combination
$c.
- •
-
"gsl_combination_memcpy($dest, $src)"This function copies the elements of the combination
$srcinto the combination$dest. The two combinations must have the same size.
- •
-
"gsl_combination_get($c, $i)"This function returns the value of the i-th element of the combination
$c. If$ilies outside the allowed range of 0 to k-1 then the error handler is invoked and 0 is returned.
- •
-
"gsl_combination_fwrite($stream, $c)"This function writes the elements of the combination
$cto the stream$stream, opened with the gsl_fopen function from the Math::GSL module, in binary format. The function returns$GSL_EFAILEDif 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_combination_fread($stream, $c)"This function reads elements from the open stream
$stream, opened with the gsl_fopen function from the Math::GSL module, into the combination$cin binary format. The combination$cmust be preallocated with correct values of n and k since the function uses the size of$cto determine how many bytes to read. The function returns$GSL_EFAILEDif 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.
- •
-
"gsl_combination_fprintf($stream, $c, $format)"This function writes the elements of the combination
$cline-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_EFAILEDif there was a problem writing to the file.
- •
-
"gsl_combination_fscanf($stream, $c)"This function reads formatted data from the stream
$streaminto the combination$c. The combination$cmust be preallocated with correct values of n and k since the function uses the size of$cto determine how many numbers to read. The function returns$GSL_EFAILEDif there was a problem reading from the file.
- •
-
gsl_combination_n($c)This function returns the range (n) of the combination
$c.
- •
-
gsl_combination_k($c)This function returns the number of elements (k) in the combination
$c.
- •
-
gsl_combination_data($c)This function returns a pointer to the array of elements in the combination
$c.
- •
-
gsl_combination_valid($c)This function checks that the combination
$cis valid. The k elements should lie in the range 0 to n-1, with each value occurring once at most and in increasing order.
- •
-
gsl_combination_next($c)This function advances the combination
$cto the next combination in lexicographic order and returns$GSL_SUCCESS. If no further combinations are available it returns$GSL_FAILUREand leaves$cunmodified. Starting with the first combination and repeatedly applying this function will iterate through all possible combinations of a given order.
- •
-
gsl_combination_prev($c)This function steps backwards from the combination
$cto the previous combination in lexicographic order, returning$GSL_SUCCESS. If no previous combination is available it returns$GSL_FAILUREand leaves$cunmodified.
MORE INFO
For more information on the functions, we refer you to the GSL official documentation: <http://www.gnu.org/software/gsl/manual/html_node/>
AUTHORS
Jonathan "Duke" Leto <[email protected]> and Thierry Moisan <[email protected]>
COPYRIGHT AND LICENSE
Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.