|
Macaulay2 Engine
|
Bijective integer encoding of q-subsets of {0, ..., n-1} via binomial(a_0, 1) + binomial(a_1, 2) + ... + binomial(a_{q-1}, q). More...
#include <comb.hpp>
Public Member Functions | |
| Subsets (size_t n, size_t p) | |
| ~Subsets () | |
| bool | isValid (const Subset &a) |
| size_t | encode (const Subset &a) |
| size_t | encodeBoundary (size_t index, const Subset &a) |
| void | decode (size_t val, Subset &result) |
Static Public Member Functions | |
| static void | show (std::ostream &o, const Subset &a) |
| static bool | increment (size_t n, Subset &s) |
| static bool | increment (size_t n, size_t subset_size, size_t *subset) |
| static bool | isValid (size_t nElements, size_t subsetSize, const size_t *a) |
| static bool | isValid (size_t nElements, size_t subsetSize, const int *a) |
| static int | concatenateSubsets (const Subset &s, const Subset &t, Subset &result) |
Private Member Functions | |
| size_t | binom (size_t n, size_t p) |
Private Attributes | |
| size_t ** | mTable |
| size_t | mNumElements |
| size_t | mMaxSubsetSize |
Bijective integer encoding of q-subsets of {0, ..., n-1} via binomial(a_0, 1) + binomial(a_1, 2) + ... + binomial(a_{q-1}, q).
Constructed with maximum bounds (n, p); supports encoding and decoding of q-subsets for all q <= p. The encoding does not depend on n, so the same index space scales as the underlying set grows. Throws if a result would not fit in size_t. Used wherever the engine enumerates exterior-style subsets without allocating an explicit table.