SUNphi  1.0
Combinatorial.hpp File Reference

Header file for the definition of combinatorial routines. More...

#include <cstdint>
#include <numeric>
#include <containers/Vector.hpp>
#include <debug/Crash.hpp>
#include <ios/Logger.hpp>

Go to the source code of this file.

Classes

class  SUNphi::Combinatorial< Int >
 Implements a looper over all combinations of a given kind. More...
 

Functions

template<typename Int , typename Fun >
Int SUNphi::loopOnAllCombinations (const Vector< Int > &nMaxPerSlot, const int nObj, const Fun &fun, BACK_FORW BackForw=FORW)
 
template<typename I , typename F >
SUNphi::loopOnAllSubmultiplesOf (const I &i, const F &fun, const BACK_FORW &backForw=FORW)
 
template<typename Fun , typename INpart , typename INToPart >
auto SUNphi::loopOnAllAdditivePartitioningOf (const INpart &nOfPart, const INToPart &nToPart, const Fun &fun)
 

Detailed Description

Header file for the definition of combinatorial routines.

For the time being we limits ourselves to the combinatorial system

Definition in file Combinatorial.hpp.

Function Documentation

template<typename Fun , typename INpart , typename INToPart >
auto SUNphi::loopOnAllAdditivePartitioningOf ( const INpart &  nOfPart,
const INToPart &  nToPart,
const Fun &  fun 
)

Loop on all additive partitioning of n

Example:

loopOnAllAdditivePartitioningOf(2,7,foo); /// foo(0,7);foo(1,6);...
Parameters
nOfPartNumber of partitions
nToPartNumber to partition
funFunction invocated

Definition at line 451 of file Combinatorial.hpp.

template<typename Int , typename Fun >
Int SUNphi::loopOnAllCombinations ( const Vector< Int > &  nMaxPerSlot,
const int  nObj,
const Fun &  fun,
BACK_FORW  BackForw = FORW 
)

Loop on all combinations

Run the provided function, passing the combo at each iteration, and returning the total number of combinations. If BackForw is true, loop forward, otherwise loop backward

Count

Combination generator

Parameters
nMaxPerSlotMaximal number of objects per slot
nObjNumber of objects
funFunction to be called
BackForwLoop direction

Definition at line 329 of file Combinatorial.hpp.

template<typename I , typename F >
I SUNphi::loopOnAllSubmultiplesOf ( const I &  i,
const F &  fun,
const BACK_FORW backForw = FORW 
)

Loop on all submultiple of the passed number

Run the provided function, passing the submultiple at each iteration, and returning the total number of submultiple

List all factors

Independent factors and maximal number they can be taken

Independent factors

Maximal number of times a factor can be taken

Number of factors

Number of independent factors

Number of submultiples

Multiple

Parameters
iNumber on which to run the loop
funFunction to run at each iteration
backForwLoop direction

Definition at line 370 of file Combinatorial.hpp.