24 LogDebug(
"ForwardSim") <<
"Creating TotemNumberMerger";
30 LogDebug(
"ForwardSim") <<
"Destruction of TotemNumberMerger";
39 unsigned long value2)
const {
41 unsigned long c(value1+value2);
42 unsigned long result(((c*(c+1))>>1)+value1);
45 LogDebug(
"ForwardSim") <<
"Merge(value1=" << value1
46 <<
", value2=" << value2 <<
")=" <<
result;
48 unsigned long invValue1, invValue2;
49 Split(result, invValue1, invValue2);
51 assert(invValue1==value1);
52 assert(invValue2==value2);
60 unsigned long value3)
const {
67 unsigned long value4)
const {
72 unsigned long &value2)
const {
73 unsigned long c(static_cast<unsigned long>(floor(
sqrt(1.+8.*static_cast<float>(source))*0.5-0.5)));
75 value1 = source-((c*(c+1))>>1);
79 LogDebug(
"ForwardSim") <<
"source=" << source <<
", c=" << c
80 <<
", value1=" << value1 <<
", value2=" << value2;
85 unsigned long &value2,
86 unsigned long &value3)
const {
89 Split(source, mix12, value3);
90 Split(mix12, value1, value2);
94 unsigned long &value2,
unsigned long &value3,
95 unsigned long &value4)
const {
96 unsigned long mix12, mix34;
98 Split(source, mix12, mix34);
99 Split(mix12, value1, value2);
100 Split(mix34, value3, value4);
unsigned long Merge(unsigned long value1, unsigned long value2) const
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
static std::string const source