# subset

subset, an Octave code which enumerates, generates, randomizes, ranks and unranks combinatorial objects including combinations, compositions, Gray codes, index sets, partitions, permutations, polynomials, subsets, and Young tables. Backtracking routines are included to solve some combinatorial problems. Other routines handle continued fractions, Diophantine equations, and Pythagorean triples.

Combinatorial operations include the enumeration, generation, random selection, ranking and unranking of

• COMP, compositions of an integer;
• COMPNZ, compositions of an integer with no zero parts;
• EQUIV's, partitions of a set of N objects;
• I4_PARTITION's, partitions of an integer;
• I4POLY's, integer polynomials in factorial, Newton, power sum, or Taylor form;
• I4VEC's, integer vectors;
• KSUB's, subsets of size K, from a set of N objects;
• MULTIPERM's, permutations of the N objects, some of which are indistinguishable.
• PERM's, permutations of the first N integers;
• R8POLY's, real polynomials in factorial, Newton, power sum, or Taylor form;
• subsets of a set of N objects;
• vectors whose entries range from 1 to N;
• YTB's, Young tables;

Other objects considered include

• the Bell numbers,
• Catalan numbers,
• congruence equations.
• continued fractions,
• DEC's, decimal numbers represented as a mantissa and a power of 10;
• DERANGE's, derangements (permutations that leave no element in place),
• DVEC's, decimal numbers represented as a vector of digits;
• falling factorials (20*19*18...),
• GRAY, Gray codes,
• matrix permanents (similar to determinants, but harder to compute, if you can believe that),
• Morse-Thue numbers,
• pentagonal numbers,
• primitive Pythagorean triples: relatively prime integers such that a^2 + b^2 = c^2
• RAT's, rational numbers represented as a pair of integers;
• rising factorials (7*8*9...).

### Licensing:

The information on this web page is distributed under the MIT license.

### Languages:

subset is available in a C version and a C++ version and a Fortran77 version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

### Related Data and Programs:

backtrack_binary_rc, an Octave code which carries out a backtrack search for a set of binary decisions, using reverse communication.

combination_lock, an Octave code which simulates the process of determining the secret combination of a lock.

combo, an Octave code which contains many combinatorial routines.

gray_code_display, an Octave code which computes the hamming distance tables for both the binary and gray codes, and displays 3d plots that illustrate how the gray code does a better job of providing nearby representations for nearby numbers.

monomial, an Octave code which enumerates, lists, ranks, unranks and randomizes multivariate monomials in a space of m dimensions, with total degree less than n, equal to n, or lying within a given range.

octave_combinatorics, an Octave code which considers a variety of problems in combinatorics involving counting, combinations, permutations, and so on.

polynomial, an Octave code which adds, multiplies, differentiates, evaluates and prints multivariate polynomials in a space of m dimensions.

polynomial_multiply, an Octave code which multiplies two polynomials p(x) and q(x).

set_theory, an Octave code which demonstrates MATLAB commands that implement various set theoretic operations.

subset_sum, an Octave code which seeks solutions of the subset sum problem.

toms515, an Octave code which can select subsets of size k from a set of size n. this is a version of acm toms algorithm 515, by bill buckles, matthew lybanon.

unicycle, an Octave code which considers permutations containing a single cycle, sometimes called cyclic permutations.

### Source Code:

Last revised on 22 June 2024.