HyperHDG
Public Member Functions | Static Public Member Functions | Static Private Member Functions | List of all members
TPCC::Combinations< n, k > Struct Template Reference

#include <combinations.h>

Public Member Functions

constexpr Combination< n, k > operator[] (unsigned int)
 A boolean array of length n with a true for each selected value. More...
 

Static Public Member Functions

static constexpr unsigned int size ()
 The number of such combinations. More...
 
static std::array< unsigned int, k > value (unsigned int index)
 The array of numbers (of length k) in the combination with given index. More...
 
static std::array< unsigned int, n - k > dual (unsigned int index)
 The array of numbers (of length n-k) of numbers not in the combination of the given index. More...
 
template<typename T >
static constexpr unsigned int index (const Combination< n, k, T > &combi)
 The index of a combination within the lexicographic enumeration. More...
 

Static Private Member Functions

template<unsigned int size, typename... I>
static constexpr std::array< unsigned int, k > compute_value (unsigned int index, I... args)
 The function template computing the combination in lexicographic ordering recursively. More...
 

Detailed Description

template<int n, int k>
struct TPCC::Combinations< n, k >

The combinations of k elements out of n as a container.

This class template does not contain any data, but it implements an enumeration of combinations, such that any combination as an array of k numbers from 0 to n-1 can be obtained from its index and vice versa.

Member Function Documentation

◆ compute_value()

template<int n, int k>
template<unsigned int sz, typename... I>
constexpr std::array< unsigned int, k > TPCC::Combinations< n, k >::compute_value ( unsigned int  index,
I...  args 
)
staticconstexprprivate

The function template computing the combination in lexicographic ordering recursively.

Here is the call graph for this function:

◆ dual()

template<int n, int k>
std::array< unsigned int, n - k > TPCC::Combinations< n, k >::dual ( unsigned int  index)
static

The array of numbers (of length n-k) of numbers not in the combination of the given index.

Todo:
This is currently implemented by computing value() and then building the complement. It it is to be used often, the implementation should be more efficient.
Here is the call graph for this function:

◆ index()

template<int n, int k>
template<typename T >
constexpr unsigned int TPCC::Combinations< n, k >::index ( const Combination< n, k, T > &  combi)
inlinestaticconstexpr

The index of a combination within the lexicographic enumeration.

Here is the call graph for this function:

◆ operator[]()

template<int n, int k>
constexpr Combination< n, k > TPCC::Combinations< n, k >::operator[] ( unsigned int  index)
constexpr

A boolean array of length n with a true for each selected value.

◆ size()

template<int n, int k>
constexpr unsigned int TPCC::Combinations< n, k >::size
staticconstexpr

The number of such combinations.

Here is the call graph for this function:

◆ value()

template<int n, int k>
std::array< unsigned int, k > TPCC::Combinations< n, k >::value ( unsigned int  index)
static

The array of numbers (of length k) in the combination with given index.


The documentation for this struct was generated from the following file: