35 : number_(number), termsCount_(termsCount), base_(base)
40 return {number_, termsCount_, base_};
75 return partition_ == other.partition_;
80 return partition_ != other.partition_;
85 : partition_(termsCount, 0)
88 if (number < base * termsCount || termsCount == 0 || number == 0) {
92 std::fill(partition_.begin(), partition_.end(), base);
93 partition_[0] = number - base * (termsCount - 1);
96void G4integerPartition::Iterator::NextPartition()
98 std::uint32_t accumulated = 0;
99 for (
auto partitionLast = std::next(partition_.begin()); partitionLast != partition_.end();
102 if (partition_.front() >= *partitionLast + 2) {
103 --partition_.front();
106 auto newValue = *partitionLast;
107 std::fill(std::next(partition_.begin()), partitionLast, newValue);
108 partition_.front() +=
109 accumulated - newValue * (std::distance(partition_.begin(), partitionLast) - 1);
112 accumulated += *partitionLast;
const G4FermiPartition * pointer
reference operator*() const
Iterator(const Iterator &)=default
G4bool operator==(const Iterator &other) const
G4bool operator!=(const Iterator &other) const
const G4FermiPartition & reference
pointer operator->() const
G4integerPartition(std::uint32_t number, std::uint32_t termsCount, std::uint32_t base=1)