# subset

subset, a Fortran77 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 handled continued fractions, and Diophantine equations.

These include the enumeration, generation, random selection, ranking and unranking of

• COMP, compositions of an integer N into K parts;
• COMPNZ, compositions of an integer N into K parts, 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;
• KSUB's, 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,
• BVEC's, binary numbers represented as a vector of 0's and 1's;
• 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 codes,
• matrix permanents (similar to determinants, but harder to compute, if you can believe that),
• Morse-Thue numbers,
• pentagonal numbers,
• Pythagorean triples,
• RAT's, rational numbers represented as a pair of integers;
• rising factorials (7*8*9...).

### 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, a Fortran77 code which carries out a backtrack search for a set of binary decisions, using reverse communication.

change_making, a Fortran77 library which considers the change making problem, in which a given sum is to be formed using coins of various denominations.

combination_lock, a Fortran77 program which simulates the process of determining the secret combination of a lock.

combo, a Fortran77 library which contains a variety of combinatorial routines.

knapsack_01, a Fortran77 library which uses brute force to solve small versions of the 0/1 knapsack problem;

legendre_product_polynomial, a Fortran77 library which defines Legendre product polynomials, creating a multivariate polynomial as the product of univariate Legendre polynomials.

monomial, a Fortran77 library 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.

partition_problem, a Fortran77 library which seeks solutions of the partition problem, splitting a set of integers into two subsets with equal sum.

polynomial, a Fortran77 library which adds, multiplies, differentiates, evaluates and prints multivariate polynomials in a space of M dimensions.

### Source Code:

Last revised on 15 December 2023.