SUBSET
Combinatorial Routines
SUBSET
is a C++ library 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. Some routines
for continued fractions are included.
These 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),

MorseThue numbers,

pentagonal numbers,

Pythagorean triples,

RAT's, rational numbers represented as a pair of integers;

rising factorials (7*8*9...).
Licensing:
The computer code and data files made available on this web page
are distributed under
the GNU LGPL license.
Languages:
SUBSET is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.
Related Data and Programs:
BACKTRACK_BINARY_RC,
a C++ library which
carries out a backtrack search for a set of binary decisions, using
reverse communication.
CHANGE_MAKING,
a C++ library which
considers the change making problem,
in which a given sum is to be formed using coins of various denominations.
COMBO,
a C++ library which
includes many combinatorial routines.
KNAPSACK_01,
a C++ library which
uses brute force to solve small versions of the 0/1 knapsack problem;
LEGENDRE_PRODUCT_POLYNOMIAL,
a C++ library which
defines Legendre product polynomials, creating a multivariate
polynomial as the product of univariate Legendre polynomials.
MONOMIAL,
a C++ 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 C++ library which
seeks solutions of the partition problem, splitting a set of integers into
two subsets with equal sum.
POLYNOMIAL,
a C++ library which
adds, multiplies, differentiates, evaluates and prints multivariate
polynomials in a space of M dimensions.
SUBSET_SUM,
a C++ library which
seeks solutions of the subset sum problem.
TOMS515,
a C++ library 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.
UBVEC,
a C++ library which
demonstrates how unsigned binary vectors, strings of 0's and 1's,
can represent nonnegative integers or subsets or other mathematical
objects, for which various arithmetic and logical operations can
be defined.
UNICYCLE,
a C++ library which
considers permutations containing a single cycle, sometimes called
cyclic permutations.
Reference:

Milton Abramowitz, Irene Stegun,
Handbook of Mathematical Functions,
National Bureau of Standards, 1964,
ISBN: 0486612724,
LC: QA47.A34.

Walter Ball,
Mathematical Recreations and Essays,
Macmillan, 1962,
ISBN: 1417921269,
LC: QA95.B2.

Paul Bratley, Bennett Fox, Linus Schrage,
A Guide to Simulation,
Second Edition,
Springer, 1987,
ISBN: 0387964673,
LC: QA76.9.C65.B73.

Bill Buckles, Matthew Lybanon,
Algorithm 515:
Generation of a Vector from the Lexicographical Index,
ACM Transactions on Mathematical Software,
Volume 3, Number 2, June 1977, pages 180182.

Tom Christiansen, Nathan Torkington,
Perl Cookbook,
O'Reilly, 2003,
ISBN: 0596003137,
LC: QA76.73.P22.C38.

William Cody, Kenneth Hillstrom,
Chebyshev Approximations for the Natural Logarithm of the
Gamma Function,
Mathematics of Computation,
Volume 21, Number 98, April 1967, pages 198203.

John Conway, Richard Guy,
The Book of Numbers,
Springer, 1998,
ISBN: 038797993X,
LC: QA241.C6897.

Bennett Fox,
Algorithm 647:
Implementation and Relative Efficiency of Quasirandom
Sequence Generators,
ACM Transactions on Mathematical Software,
Volume 12, Number 4, December 1986, pages 362376.

Laurent Habsieger, Maxim Kazarian, Sergei Lando,
On the Second Number of Plutarch,
American Mathematical Monthly,
Volume 105, Number 5, May 1998, page 446.

John Halton,
On the efficiency of certain quasirandom sequences of points
in evaluating multidimensional integrals,
Numerische Mathematik,
Volume 2, Number 1, December 1960, pages 8490.

John Hammersley,
Monte Carlo methods for solving multivariable problems,
Proceedings of the New York Academy of Science,
Volume 86, 1960, pages 844874.

John Hart, Ward Cheney, Charles Lawson, Hans Maehly,
Charles Mesztenyi, John Rice, Henry Thacher,
Christoph Witzgall,
Computer Approximations,
Wiley, 1968,
LC: QA297.C64.

Brian Hayes,
Third Base,
American Scientist,
Volume 89, Number 6, NovemberDecember 2001, pages 490494.

Mark Herkommer,
Number Theory, A Programmer's Guide,
McGraw Hill, 1999,
ISBN: 0079130747.

Karla Hoffman, Douglas Shier,
Algorithm 564:
A Test Problem Generator for Discrete Linear L1
Approximation Problems,
ACM Transactions on Mathematical Software,
Volume 6, Number 4, December 1980, pages 615617.

Donald Knuth,
The Art of Computer Programming,
Volume 3, Sorting and Searching,
Second Edition,
Addison Wesley, 1998,
ISBN: 0201896850,
LC: QA76.6.K64.

Hang Tong Lau,
Algorithms on Graphs,
Tab Books, 1989,
ISBN: 0830634290,
LC: QA166.L38

Pierre LEcuyer,
Random Number Generation,
in Handbook of Simulation,
edited by Jerry Banks,
Wiley, 1998,
ISBN: 0471134031,
LC: T57.62.H37.

Peter Lewis, Allen Goodman, James Miller,
A PseudoRandom Number Generator for the System/360,
IBM Systems Journal,
Volume 8, 1969, pages 136143.

Charles Mifsud,
Algorithm 154,
Combination in Lexicographic Order,
Communications of the ACM,
Volume 6, Number 3, March 1963, page 103.

mil_std_1753,
Military Standard 1753,
FORTRAN, DoD Supplement To American National Standard X3.91978,
9 November 1978.

Albert Nijenhuis, Herbert Wilf,
Combinatorial Algorithms for Computers and Calculators,
Second Edition,
Academic Press, 1978,
ISBN: 0125192606,
LC: QA164.N54.

Robert Owens,
Sums of Powers of Integers,
Mathematics Magazine,
Volume 65, Number 1, February 1992, pages 3840.

Norman Richert,
Strang's Strange Figures,
American Mathematical Monthly,
Volume 99, Number 2, February 1992, pages 101107.

James Sandeson,
Testing Ecological Patterns,
American Scientist,
Volume 88, Number 4, JulyAugust 2000, pages 332339.

Ian Saunders,
Algorithm AS 205,
Enumeration of R x C Tables with Repeated Row Totals,
Applied Statistics,
Volume 33, Number 3, 1984, pages 340352.

Robert Sedgewick,
Algorithms in C,
AddisonWesley, 1990,
ISBN: 0201514257,
LC: QA76.73.C15S43.

Raymond Seroul,
Programming for Mathematicians,
Springer, 2000,
ISBN: 354066422X,
LC: QA76.6.S465.

MokKong Shen,
Algorithm 202:
Generation of Permutations in Lexicographical Order,
Communications of the ACM,
Volume 6, Number 9, September 1963, page 517.

Richard Stanley,
Hipparchus, Plutarch, Schroeder, and Hough,
American Mathematical Monthly,
Volume 104, Number 4, April 1997, pages 344350.

Dennis Stanton, Dennis White,
Constructive Combinatorics,
Springer, 1986,
ISBN: 0387963472,
LC: QA164.S79.

Ian Stewart,
A Neglected Number,
Scientific American,
Volume 274, pages 102102, June 1996.

Ian Stewart,
Math Hysteria,
Oxford, 2004,
ISBN: 0198613369,
LC: QA95.S7255.

James Sylvester,
Question 7382,
Mathematical Questions with their Solutions,
Educational Times,
Volume 41, page 21, 1884.

Hale Trotter,
Algorithm 115:
PERM,
Communications of the Association for Computing Machinery,
Volume 5, Number 8, August 1962, pages 434435.

Johannes vanderCorput,
Verteilungsfunktionen I & II,
Proceedings of the Koninklijke Nederlandsche Akademie
van Wetenschappen,
Volume 38, 1935, pages 813820, pages 10581066.

Jack vanLint, Richard Wilson,
A Course in Combinatorics,
Cambridge, 1992,
ISBN: 0521422604,
LC: QA164.L56.

Eric Weisstein,
CRC Concise Encyclopedia of Mathematics,
CRC Press, 2002,
Second edition,
ISBN: 1584883472,
LC: QA5.W45

Stephen Wolfram,
The Mathematica Book,
Fourth Edition,
Cambridge University Press, 1999,
ISBN: 0521643147,
LC: QA76.95.W65.

ML Wolfson, HV Wright,
ACM Algorithm 160:
Combinatorial of M Things Taken N at a Time,
Communications of the ACM,
Volume 6, Number 4, April 1963, page 161.

Daniel Zwillinger, editor,
CRC Standard Mathematical Tables and Formulae,
30th Edition,
CRC Press, 1996,
ISBN: 0849324793,
LC: QA47.M315.
Source Code:
Examples and Tests:
List of Routines:

ASM_ENUM returns the number of alternating sign matrices of a given order.

ASM_TRIANGLE returns a row of the alternating sign matrix triangle.

BELL returns the Bell numbers from 0 to N.

BELL_VALUES returns some values of the Bell numbers for testing.

BINARY_VECTOR_NEXT generates the next binary vector.

CATALAN computes the Catalan numbers, from C(0) to C(N).

CATALAN_ROW computes row N of Catalan's triangle.

CATALAN_VALUES returns some values of the Catalan numbers for testing.

CFRAC_TO_RAT converts a monic continued fraction to an ordinary fraction.

CFRAC_TO_RFRAC converts a polynomial fraction from continued to rational form.

CH_CAP capitalizes a single character.

CHANGE_GREEDY makes change for a given total using the biggest coins first.

CHANGE_NEXT computes the next set of change for a given sum.

CHINESE_CHECK checks the Chinese remainder moduluses.

CHINESE_TO_I4 converts a set of Chinese remainders to an equivalent integer.

COMB_NEXT computes combinations of K things out of N.

COMB_ROW computes row N of Pascal's triangle.

COMB_UNRANK returns the RANKth combination of N things out of M.

COMP_ENUM returns the number of compositions of the integer N into K parts.

COMP_NEXT computes the compositions of the integer N into K parts.

COMP_NEXT_GRLEX returns the next composition in grlex order.

COMP_RANDOM selects a random composition of the integer N into K parts.

COMP_RANDOM_GRLEX: random composition with degree less than or equal to NC.

COMP_RANK_GRLEX computes the graded lexicographic rank of a composition.

COMP_TO_KSUB converts a composition to a Ksubset.

COMP_UNRANK_GRLEX computes the composition of given grlex rank.

COMPNZ_NEXT computes the compositions of the integer N into K nonzero parts.

COMPNZ_RANDOM selects a random composition of the integer N into K nonzero parts.

COMPNZ_TO_KSUB converts a nonzero composition to a Ksubset.

CONGRUENCE solves a congruence of the form ( A * X = C ) mod B.

COUNT_POSE_RANDOM poses a problem for the game "The Count is Good"

DEBRUIJN constructs a de Bruijn sequence.

DEC_ADD adds two decimal quantities.

DEC_DIV divides two decimal values.

DEC_MUL multiplies two decimals.

DEC_ROUND rounds a decimal fraction to a given number of digits.

DEC_TO_R8 converts a decimal value to an R8.

DEC_TO_RAT converts a decimal to a rational representation.

DEC_TO_S converts a decimal number to a string.

DEC_WIDTH returns the "width" of a decimal number.

DECMAT_DET finds the determinant of an N by N matrix of decimal entries.

DECMAT_PRINT prints out decimal vectors and matrices.

DERANGE_BACK_CANDIDATE finds possible values for the Kth entry of a derangement.

DERANGE_BACK_NEXT returns the next derangement of N items.

DERANGE_CHECK is TRUE if a permutation is a derangement.

DERANGE_ENUM returns the number of derangements of N objects.

DERANGE_ENUM2 returns the number of derangements of 0 through N objects.

DERANGE_ENUM3 returns the number of derangements of 0 through N objects.

DERANGE_WEED_NEXT computes all of the derangements of N objects, one at a time.

DIGIT_TO_CH returns the character representation of a decimal digit.

DIGRAPH_ARC_EULER returns an Euler circuit in a digraph.

DIGRAPH_ARC_PRINT prints out a digraph from an edge list.

DIOPHANTINE solves a Diophantine equation A * X + B * Y = C.

DIOPHANTINE_SOLUTION_MINIMIZE seeks a minimal solution of a Diophantine equation.

DVEC_ADD adds two (signed) decimal vectors.

DVEC_COMPLEMENTX computes the ten's complement of a decimal vector.

DVEC_MUL computes the product of two decimal vectors.

DVEC_PRINT prints a decimal integer vector, with an optional title.

DVEC_SUB subtracts two decimal vectors.

DVEC_TO_I4 makes an integer from a (signed) decimal vector.

EQUIV_NEXT computes the partitions of a set one at a time.

EQUIV_NEXT2 computes, one at a time, the partitions of a set.

EQUIV_PRINT prints a partition of a set.

EQUIV_PRINT2 prints a partition of a set.

EQUIV_RANDOM selects a random partition of a set.

EULER returns the Nth row of Euler's triangle.

FROBENIUS_NUMBER_ORDER2 returns the Frobenius number for order 2.

FROBENIUS_NUMBER_ORDER2_VALUES returns values of the order 2 Frobenius number.

GAMMA_LOG_VALUES returns some values of the Log Gamma function for testing.

GET_SEED returns a random seed for the random number generator.

GRAY_NEXT generates the next Gray code by switching one item at a time.

GRAY_RANK ranks a Gray code.

GRAY_RANK2 ranks a Gray code.

GRAY_UNRANK unranks a Gray code.

GRAY_UNRANK2 unranks a Gray code.

I4_BCLR returns a copy of an I4 in which the POSth bit is set to 0.

I4_BSET returns a copy of an I4 in which the POSth bit is set to 1.

I4_BTEST returns TRUE if the POSth bit of an I4 is 1.

I4_CHOOSE computes the binomial coefficient C(N,K).

I4_FACTOR factors an I4 into prime factors.

I4_FACTORIAL computes the factorial of N.

I4_FALL computes the falling factorial function [X]_N.

I4_GCD finds the greatest common divisor of I and J.

I4_HUGE returns a "huge" integer value, usually the largest legal signed int.

I4_LOG_10 returns the whole part of the logarithm base 10 of an integer.

I4_MAX returns the maximum of two I4's.

I4_MIN returns the smaller of two I4's.

I4_MODP returns the nonnegative remainder of I4 division.

I4_MOEBIUS returns the value of MU(N), the Moebius function of N.

I4_PARTITION_CONJ computes the conjugate of a partition.

I4_PARTITION_COUNT computes the number of partitions of an integer.

I4_PARTITION_COUNT2 computes the number of partitions of an integer.

I4_PARTITION_COUNT_VALUES returns some values of the int partition count.

I4_PARTITION_NEXT generates the partitions of an integer, one at a time.

I4_PARTITION_NEXT2 computes the partitions of an integer one at a time.

I4_PARTITION_PRINT prints a partition of an integer.

I4_PARTITION_RANDOM selects a random partition of the int N.

I4_PARTITIONS_NEXT: next partition into S parts.

I4_POWER returns the value of I^J.

I4_RISE computes the rising factorial function [X]^N.

I4_SIGN returns the sign of an I4.

I4_SQRT finds the integer square root of N by solving N = Q^2 + R.

I4_SQRT_CF: continued fraction representation of a square root of an integer.

I4_SWAP switches two I4's.

I4_TO_BVEC makes a (signed) binary vector from an I4.

I4_TO_CHINESE converts an I4 to its Chinese remainder form.

I4_TO_DVEC makes a signed decimal vector from an I4.

I4_TO_I4POLY converts an I4 to an integer polynomial in a given base.

I4_TO_VAN_DER_CORPUT computes an element of a van der Corput sequence.

I4_UNIFORM_AB returns a scaled pseudorandom I4.

I4MAT_01_ROWCOLSUM creates a 0/1 I4MAT with given row and column sums.

I4MAT_01_ROWCOLSUM2 creates a 0/1 I4MAT with given row and column sums.

I4MAT_PERM permutes the rows and columns of a square I4MAT.

I4MAT_PERM2 permutes the rows and columns of a rectangular I4MAT.

I4MAT_PRINT prints an I4MAT.

I4MAT_PRINT_SOME prints some of an I4MAT.

I4MAT_U1_INVERSE inverts a unit upper triangular I4MAT.

I4POLY performs operations on I4POLY's in power or factorial form.

I4POLY_ADD adds two I4POLY's.

I4POLY_CYCLO computes a cyclotomic I4POLY.

I4POLY_DEGREE returns the degree of an I4POLY.

I4POLY_DIF differentiates an I4POLY.

I4POLY_DIV computes the quotient and remainder of two I4POLY's.

I4POLY_MUL computes the product of two I4POLY's.

I4POLY_PRINT prints out an I4POLY.

I4POLY_TO_I4 evaluates an I4POLY.

I4VEC_ASCENDS determines if an I4VEC is (weakly) ascending.

I4VEC_BACKTRACK supervises a backtrack search for an I4VEC.

I4VEC_DESCENDS determines if an I4VEC is decreasing.

I4VEC_FRAC searches for the Kth smallest entry in an I4VEC.

I4VEC_HEAP_D reorders an I4VEC into a descending heap.

I4VEC_INDEX returns the location of the first occurrence of a given value.

I4VEC_INDICATOR sets an I4VEC to the indicator vector.

I4VEC_INDICATOR_NEW sets an I4VEC to the indicator vector.

I4VEC_MAX returns the value of the maximum element in an I4VEC.

I4VEC_MAXLOC_LAST returns the index of the last maximal I4VEC entry.

I4VEC_MIN returns the value of the minimum element in an I4VEC.

I4VEC_PAIRWISE_PRIME checks whether an I4VEC is pairwise prime.

I4VEC_PRODUCT multiplies the entries of an I4VEC.

I4VEC_REVERSE reverses the elements of an integer vector.

I4VEC_SORT_BUBBLE_A ascending sorts an integer array using bubble sort.

I4VEC_SORT_HEAP_A ascending sorts an I4VEC using heap sort.

I4VEC_SORT_HEAP_INDEX_A does an indexed heap ascending sort of an integer vector.

I4VEC_SORT_HEAP_INDEX_D does an indexed heap descending sort of an I4VEC.

I4VEC_SUM sums the entries of an I4VEC.

I4VEC_UNIFORM returns a scaled pseudorandom I4VEC.

I4VEC0_PRINT prints an integer vector (0based indices).

I4VEC1_PRINT prints an integer vector (onebased indices).

INDEX_BOX2_NEXT_2D produces index vectors on the surface of a box in 2D.

INDEX_BOX2_NEXT_3D produces index vectors on the surface of a box in 3D.

INDEX_BOX_NEXT_2D produces index vectors on the surface of a box in 2D.

INDEX_BOX_NEXT_3D produces index vectors on the surface of a box in 3D.

INDEX_NEXT0 generates all index vectors within given upper limits.

INDEX_NEXT1 generates all index vectors within given upper limits.

INDEX_NEXT2 generates all index vectors within given lower and upper limits.

INDEX_RANK0 ranks an index vector within given upper limits.

INDEX_RANK1 ranks an index vector within given upper limits.

INDEX_RANK2 ranks an index vector within given lower and upper limits.

INDEX_UNRANK0 unranks an index vector within given upper limits.

INDEX_UNRANK1 unranks an index vector within given upper limits.

INDEX_UNRANK2 unranks an index vector within given lower and upper limits.

INS_PERM computes a permutation from its inversion sequence.

INVERSE_MOD_N computes the inverse of B mod N.

INVOLUTE_ENUM enumerates the involutions of N objects.

JFRAC_TO_RFRAC converts a Jfraction into a rational polynomial fraction.

JOSEPHUS returns the position X of the Kth man to be executed.

KSUB_NEXT generates the subsets of size K from a set of size N.

KSUB_NEXT2 generates the subsets of size K from a set of size N.

KSUB_NEXT3 generates the subsets of size K from a set of size N.

KSUB_NEXT4 generates the subsets of size K from a set of size N.

KSUB_RANDOM selects a random subset of size K from a set of size N.

KSUB_RANDOM2 selects a random subset of size K from a set of size N.

KSUB_RANDOM3 selects a random subset of size K from a set of size N.

KSUB_RANDOM4 selects a random subset of size K from a set of size N.

KSUB_RANDOM5 selects a random subset of size K from a set of size N.

KSUB_RANK computes the rank of a subset of an N set.

KSUB_TO_COMP converts a Ksubset to a composition.

KSUB_TO_COMPNZ converts a Ksubset to a nonzero composition.

KSUB_UNRANK returns the subset of a given rank.

L4VEC_NEXT generates the next logical vector.

MATRIX_PRODUCT_OPT determines the optimal cost of a matrix product.

MOEBIUS_MATRIX finds the Moebius matrix from a covering relation.

MONOMIAL_COUNT counts the number of monomials up to a given degree.

MONOMIAL_COUNTS counts the number of monomials up to a given degree.

MORSE_THUE generates a Morse_Thue number.

MULTINOMIAL_COEF1 computes a multinomial coefficient.

MULTINOMIAL_COEF2 computes a multinomial coefficient.

MULTIPERM_ENUM enumerates multipermutations.

MULTIPERM_NEXT returns the next multipermutation.

NETWORK_FLOW_MAX finds the maximal flow and a minimal cut in a network.

NIM_SUM computes the Nim sum of two integers.

PADOVAN returns the first N values of the Padovan sequence.

PELL_BASIC returns the fundamental solution for Pell's basic equation.

PELL_NEXT returns the next solution of Pell's equation.

PENT_ENUM computes the Nth pentagonal number.

PERM_ASCEND computes the longest ascending subsequence of permutation.

PERM_BREAK_COUNT counts the number of "breaks" in a permutation.

PERM_CANON_TO_CYCLE converts a permutation from canonical to cycle form.

PERM_CHECK checks that a vector represents a permutation.

PERM_CYCLE analyzes a permutation.

PERM_CYCLE_TO_CANON converts a permutation from cycle to canonical form.

PERM_CYCLE_TO_INDEX converts a permutation from cycle to standard index form.

PERM_DISTANCE computes the Ulam metric distance of two permutations.

PERM_FIXED_ENUM enumerates the permutations of N objects with M fixed.

PERM_FREE reports the unused items in a partial permutation.

PERM_INDEX_TO_CYCLE converts a permutation from standard index to cycle form.

PERM_INS computes the inversion sequence of a permutation.

PERM_INVERSE inverts a permutation "in place".

PERM_INVERSE2 inverts a permutation "in place".

PERM_INVERSE3 produces the inverse of a given permutation.

PERM_LEX_NEXT generates permutations in lexical order, one at a time.

PERM_MUL "multiplies" two permutations.

PERM_NEXT computes all of the permutations of N objects, one at a time.

PERM_NEXT2 generates all the permutations of N objects.

PERM_NEXT3 computes all of the permutations of N objects, one at a time.

PERM_PRINT prints a permutation.

PERM_RANDOM selects a random permutation of N objects.

PERM_RANDOM2 selects a random permutation of N objects.

PERM_RANDOM3 selects a random permutation of N elements.

PERM_RANK computes the rank of a given permutation.

PERM_SIGN returns the sign of a permutation.

PERM_TO_EQUIV computes the partition induced by a permutation.

PERM_TO_YTB converts a permutation to a Young tableau.

PERM_UNRANK "unranks" a permutation.

PERRIN returns the first N values of the Perrin sequence.

PORD_CHECK checks a matrix representing a partial ordering.

POWER_MOD computes mod ( A^N, M ).

POWER_SERIES1 computes a power series for a function G(Z) = (1+F(Z))^ALPHA.

POWER_SERIES2 computes the power series for a function G(Z) = EXP(F(Z))  1.

POWER_SERIES3 computes the power series for a function H(Z) = G(F(Z)).

POWER_SERIES4 computes the power series for a function H(Z) = G ( 1/F(Z) ).

PRIME returns any of the first PRIME_MAX prime numbers.

PYTHAG_TRIPLE_NEXT computes the next Pythagorean triple.

R4_ABS returns the absolute value of an R4.

R4_NINT returns the nearest integer to an R4.

R8_ABS returns the absolute value of an R8.

R8_AGM finds the arithmeticgeometric mean of two R8's.

R8_CHOOSE computes the combinatorial coefficient C(N,K).

R8_EPSILON returns the R8 round off unit.

R8_FACTORIAL computes the factorial of N.

R8_FALL computes the falling factorial function [X]_N.

R8_GAMMA_LOG calculates the natural logarithm of GAMMA ( X ) for positive X.

R8_HUGE returns a "huge" R8.

R8_NINT returns the integer that is nearest to a double value.

R8_PI returns the value of PI.

R8_RISE computes the rising factorial function [X]^N.

R8_SWAP switches two R8's.

R8_TO_CFRAC converts a double value to a continued fraction.

R8_TO_DEC converts a double quantity to a decimal representation.

R8_TO_RAT converts a real value to a rational value.

R8_UNIFORM returns a random real in a given range.

R8_UNIFORM_01 returns a double precision pseudorandom number.

R8MAT_DET finds the determinant of a real N by N matrix.

R8MAT_PERM permutes the rows and columns of a square R8MAT.

R8MAT_PERM2 permutes rows and columns of a rectangular R8MAT, in place.

R8MAT_PERMANENT computes the permanent of an R8MAT.

R8MAT_PRINT prints an R8MAT, with an optional title.

R8MAT_PRINT_SOME prints some of an R8MAT.

R8MAT_TRANSPOSE_PRINT prints an R8MAT, transposed.

R8MAT_TRANSPOSE_PRINT_SOME prints some of an R8MAT, transposed.

R8POLY performs operations on R8POLY's in power or factorial form.

R8POLY_ADD adds two R8POLY's.

R8POLY_DEGREE returns the degree of an R8POLY.

R8POLY_DIF differentiates an R8POLY.

R8POLY_DIV computes the quotient and remainder of two R8POLY's.

R8POLY_F2P converts a double polynomial from factorial form to power sum form.

R8POLY_FVAL evaluates a double polynomial in factorial form.

R8POLY_MUL computes the product of two double polynomials A and B.

R8POLY_N2P converts a double polynomial from Newton form to power sum form.

R8POLY_NVAL evaluates a double polynomial in Newton form.

R8POLY_NX replaces one of the base points in a polynomial in Newton form.

R8POLY_P2F converts a double polynomial from power sum form to factorial form.

R8POLY_P2N converts a polynomial from power sum form to Newton form.

R8POLY_P2T converts a real polynomial from power sum form to Taylor form.

R8POLY_POWER computes a positive integer power of a polynomial.

R8POLY_PRINT prints out a polynomial.

R8POLY_PVAL evaluates a real polynomial in power sum form.

R8POLY_T2P converts a real polynomial from Taylor form to power sum form

R8VEC_BACKTRACK supervises a backtrack search for a real vector.

R8VEC_FRAC searches for the Kth smallest entry in an R8VEC.

R8VEC_INDICATOR sets an R8VEC to the indicator vector.

R8VEC_MIRROR_NEXT steps through all sign variations of an R8VEC.

R8VEC_PRINT prints an R8VEC

R8VEC_UNIFORM returns a scaled pseudorandom R8VEC.

R8VEC_UNIFORM_01 returns a unit pseudorandom R8VEC.

RAND_INITIALIZE initializes the RAND random number generator.

RANDOM_INITIALIZE initializes the RANDOM random number generator.

RAT_ADD adds two rational values.

RAT_DIV divides one rational value by another.

RAT_FAREY computes the Nth row of the Farey fraction table.

RAT_FAREY2 computes the next row of the Farey fraction table.

RAT_MUL multiplies two fractions.

RAT_NORMALIZE normalizes a rational number.

RAT_SUM_FORMULA computes the formulas for sums of powers of integers.

RAT_TO_CFRAC converts a rational value to a continued fraction.

RAT_TO_DEC converts a rational to a decimal representation.

RAT_TO_R8 converts rational values to R8's.

RAT_WIDTH returns the "width" of a rational number.

RATMAT_DET finds the determinant of an N by N matrix of rational entries.

RATMAT_PRINT prints out a rational matrix.

REGRO_NEXT computes restricted growth functions one at a time.

RFRAC_TO_CFRAC converts a rational polynomial fraction to a continued fraction.

RFRAC_TO_JFRAC converts a rational polynomial fraction to a J fraction.

S_LEN_TRIM returns the length of a string to the last nonblank.

SCHROEDER generates the Schroeder numbers.

SORT_HEAP_EXTERNAL externally sorts a list of items into ascending order.

SUBCOMP_NEXT computes the next subcomposition of N into K parts.

SUBCOMPNZ_NEXT computes the next subcomposition of N into K nonzero parts.

SUBCOMPNZ2_NEXT computes the next subcomposition of N into K nonzero parts.

SUBSET_BY_SIZE_NEXT returns all subsets of an N set, in order of size.

SUBSET_GRAY_NEXT generates all subsets of a set of order N, one at a time.

SUBSET_GRAY_RANK ranks a subset of an N set, using the Gray code ordering.

SUBSET_GRAY_UNRANK produces a subset of an N set of the given Gray code rank.

SUBSET_LEX_NEXT generates the subsets of a set of N elements, one at a time.

SUBSET_RANDOM selects a random subset of an Nset.

SUBTRIANGLE_NEXT computes the next subtriangle of a triangle.

THUE_BINARY_NEXT returns the next element in a binary Thue sequence.

THUE_TERNARY_NEXT returns the next element in a ternary Thue sequence.

TIMESTAMP prints the current YMDHMS date as a time stamp.

TRIANG renumbers elements in accordance with a partial ordering.

TUPLE_NEXT computes the next element of a tuple space.

TUPLE_NEXT_FAST computes the next element of a tuple space, "fast".

TUPLE_NEXT_GE computes the next "nondecreasing" element of a tuple space.

TUPLE_NEXT2 computes the next element of an integer tuple space.

UBVEC_ADD adds two unsigned binary vectors.

UBVEC_TO_UI4 makes an unsigned integer from an unsigned binary vector.

UI4_TO_UBVEC makes a unsigned binary vector from an integer.

VEC_COLEX_NEXT generates vectors in colex order.

VEC_COLEX_NEXT2 generates vectors in colex order.

VEC_COLEX_NEXT3 generates vectors in colex order.

VEC_GRAY_NEXT computes the elements of a product space.

VEC_GRAY_RANK computes the rank of a product space element.

VEC_GRAY_UNRANK computes the product space element of a given rank.

VEC_LEX_NEXT generates vectors in lex order.

VEC_RANDOM selects a random Nvector of integers modulo a given base.

VECTOR_CONSTRAINED_NEXT returns the "next" constrained vector.

VECTOR_CONSTRAINED_NEXT2 returns the "next" constrained vector.

VECTOR_CONSTRAINED_NEXT3 returns the "next" constrained vector.

VECTOR_CONSTRAINED_NEXT4 returns the "next" constrained vector.

VECTOR_CONSTRAINED_NEXT5 returns the "next" constrained vector.

VECTOR_CONSTRAINED_NEXT6 returns the "next" constrained vector.

VECTOR_CONSTRAINED_NEXT7 returns the "next" constrained vector.

VECTOR_NEXT returns the "next" integer vector between two ranges.

YTB_ENUM enumerates the Young tableau of size N.

YTB_NEXT computes the next Young tableau for a given shape.

YTB_PRINT prints a Young tableau.

YTB_RANDOM selects a random Young tableau of a given shape.
You can go up one level to
the C++ source codes.
Last revised on 11 December 2013.