numeric
Public Types | Public Member Functions | Static Public Member Functions | List of all members
numeric::IntegerPartitioning Class Reference

Computer integer partitions. More...

#include <IntegerPartitioning.hpp>

Public Types

typedef std::map< size_t, std::set< IntegerPartition > > PartitionsMap
 

Public Member Functions

void compute (size_t number)
 
std::string toString () const
 
PartitionsMap getPartitionsMap () const
 

Static Public Member Functions

static std::string toString (const IntegerPartition &partition)
 
static std::string toString (const std::vector< IntegerPartition > &partitionList)
 
static size_t multiplicity (const IntegerPartition &partition, int value)
 

Detailed Description

Computer integer partitions.

Utitility class that allows to compute all integer partitions of a given integer It uses the existing algorithm of Jerome Kelleher: "Generating All Partitions: A Comparison Of Two Encodings", (Kelleher and O'Sullivan, 2009)

See also
http://jeromekelleher.net/partitions.php
IntegerPartitioning ip;
// compute all partitions: [1,1,1,1,1],[2,1,1,1], ... [5]
ip.compute(5);
IntegerPartitioning::PartitionsMap partitionsMap = ip.getPartitionsMap();

Member Typedef Documentation

◆ PartitionsMap

typedef std::map<size_t, std::set< IntegerPartition > > numeric::IntegerPartitioning::PartitionsMap

Member Function Documentation

◆ compute()

void numeric::IntegerPartitioning::compute ( size_t  number)

Compute all integer partitions up to a given size

Parameters
numberGenerating All Partitions: A Comparison Of Two Encodings Jerome Kelleher, Barry O'Sullivan

Translated from python and retrieved from http://jeromekelleher.net/partitions.php

◆ getPartitionsMap()

PartitionsMap numeric::IntegerPartitioning::getPartitionsMap ( ) const
inline

Retrieve the partitions map

Returns
partition map

◆ multiplicity()

size_t numeric::IntegerPartitioning::multiplicity ( const IntegerPartition partition,
int  value 
)
static

Compute the multiplicity of a value in a given integer partition

Returns
number of occurence of a single value in a given integer partition

◆ toString() [1/3]

std::string numeric::IntegerPartitioning::toString ( ) const

Print all generated partitions

Returns
String representation of all generated integer partition

◆ toString() [2/3]

std::string numeric::IntegerPartitioning::toString ( const IntegerPartition partition)
static

Convert an integer partition to a string

Returns
String representation of an integer partition

◆ toString() [3/3]

std::string numeric::IntegerPartitioning::toString ( const std::vector< IntegerPartition > &  partitionList)
static

Convert an integer partition to a string

Returns
String representation of an integer partition

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