2#include "../exact_rational.hpp"
11class exact_bernoulli_sequence {
13 explicit exact_bernoulli_sequence(std::size_t maximum_order)
15 if (maximum_order >= row_.max_size())
throw std::length_error(
"Bernoulli order exceeds storage capacity");
16 row_.reserve(maximum_order + 1);
20 auto const m = row_.size();
21 row_.push_back(exact_rational{1} / exact_rational{m + 1});
22 for (std::size_t j = m; j > 0; --j)
23 row_[j - 1] = exact_rational{j} * (row_[j - 1] - row_[j]);
24 return m == 1 ? -row_[0] : row_[0];
28 std::vector<exact_rational> row_;
31inline exact_rational exact_bernoulli(std::size_t n)
33 exact_bernoulli_sequence sequence(n);
35 for (std::size_t i = 0; i <= n; ++i)
36 value = sequence.next();
locale_t value
Definition data_table.cpp:49