Path: | rdoc/combi.rdoc |
Last Update: | Sun Nov 14 14:53:48 -0800 2010 |
Contents:
These create a new combination with parameters n, k. The combination is not initialized and its elements are undefined. Use the method GSL::Combination.calloc if you want to create a combination which is initialized to the lexicographically first combination.
This creates a new combination with parameters n, k and initializes it to the lexicographically first combination.
This method initializes the combination self to the lexicographically first combination, i.e. (0,1,2,…,k-1).
This method initializes the combination self to the lexicographically last combination, i.e. (n-k,n-k+1,…,n-1).
This returns the value of the i-th element of the combination self.
Returns the n parameter of the combination self.
Returns the k parameter of the combination self.
Returns the vector of elements in the combination self.
This method checks that the combination self is valid. The k elements should contain numbers from range 0 .. n-1, each number at most once. The numbers have to be in increasing order.
Thie returns true if the combination is valid, and false otherwise.
This method advances the combination self to the next combination in lexicographic order and returns GSL::SUCCESS. If no further combinations are available it returns GSL::FAILURE and leaves self unmodified. Starting with the first combination and repeatedly applying this function will iterate through all possible combinations of a given order.
This method steps backwards from the combination self to the previous combination in lexicographic order, returning GSL::SUCCESS. If no previous combination is available it returns GSL::FAILURE and leaves self unmodified.
#!/usr/bin/env ruby require("gsl") printf("All subsets of {0,1,2,3} by size:\n") ; for i in 0...4 do c = GSL::Combination.calloc(4, i); begin printf("{"); c.fprintf(STDOUT, " %u"); printf(" }\n"); end while c.next == GSL::SUCCESS end