LatNet Builder Manual
2.0.1-11
Software Package for Constructing Highly Uniform Point Sets
|
Generator of all the compositions of an integer in a specific number of parts. More...
#include <CompositionMaker.h>
Public Member Functions | |
CompositionMaker (unsigned int n, unsigned int k) | |
Constructs a generator of all the compositions of n into k parts. | |
bool | goToNextComposition () |
Change the current composition to the next composition. More... | |
const std::pair< std::pair< int, int >, std::pair< int, int > > & | changeFromPreviousComposition () const |
Returns the difference between the previous compositon and the current composition. More... | |
const std::vector< unsigned int > & | currentComposition () const |
Returns the current composition held by the generator. | |
Generator of all the compositions of an integer in a specific number of parts.
This class can be used to generate iteratively all the compositions of an integer \(n\) in a specific number of parts \(k\), that is all the \( k \)-uple \((a_1, ..., a_k)\) such that \( \sum_{i=1}^k a_i = n \). Furthermore, two consecutive compositions only differ by one unitary operation: only one unit has been transfered from one \( a_i\) to another \( a_j \).
const std::pair<std::pair<int,int>, std::pair<int,int> >& CompositionMaker::changeFromPreviousComposition | ( | ) | const |
Returns the difference between the previous compositon and the current composition.
bool CompositionMaker::goToNextComposition | ( | ) |
Change the current composition to the next composition.
Returns false when the generator is depleted and true otherwise.