25 LogDebug(
"ForwardSim") <<
"Creating TotemNumberMerger";
31 LogDebug(
"ForwardSim") <<
"Destruction of TotemNumberMerger";
40 unsigned long value2)
const {
42 unsigned long c(value1+value2);
43 unsigned long result(((c*(c+1))>>1)+value1);
46 LogDebug(
"ForwardSim") <<
"Merge(value1=" << value1
47 <<
", value2=" << value2 <<
")=" <<
result;
49 unsigned long invValue1, invValue2;
50 Split(result, invValue1, invValue2);
52 assert(invValue1==value1);
53 assert(invValue2==value2);
61 unsigned long value3)
const {
68 unsigned long value4)
const {
73 unsigned long &value2)
const {
74 unsigned long c(static_cast<unsigned long>(floor(
sqrt(1.+8.*static_cast<float>(source))*0.5-0.5)));
76 value1 = source-((c*(c+1))>>1);
80 LogDebug(
"ForwardSim") <<
"source=" << source <<
", c=" << c
81 <<
", value1=" << value1 <<
", value2=" << value2;
86 unsigned long &value2,
87 unsigned long &value3)
const {
90 Split(source, mix12, value3);
91 Split(mix12, value1, value2);
95 unsigned long &value2,
unsigned long &value3,
96 unsigned long &value4)
const {
97 unsigned long mix12, mix34;
99 Split(source, mix12, mix34);
100 Split(mix12, value1, value2);
101 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