LatNet Builder Manual  2.0.1-11
Software Package for Constructing Highly Uniform Point Sets
CompositionMaker Class Reference

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.
 

Detailed Description

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 \).

Member Function Documentation

◆ changeFromPreviousComposition()

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.

Returns
A pair of pairs of ints. The first pair indicates which \(a_i\) has decreased and its former value, the second indicates which \( a_i \) has increased and its new value.

◆ goToNextComposition()

bool CompositionMaker::goToNextComposition ( )

Change the current composition to the next composition.

Returns false when the generator is depleted and true otherwise.

Returns
A boolean indicating if the generator is depleted.

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