Subject: [boost] Bernoulli Numbers Implementation With More Precision and Boost.Test
From: Gaurav Deshmukh (gauravdeshmukh42_at_[hidden])
Date: 2013-04-27 06:48:11
I have further improved the implementation of 'bernoulli' function for
Math.Bernoulli project idea of GSoC-2013.
In my previous update, I made the return type generic. But, there was lack
of precision as I had mentioned. For achieving greater accuracy, I
implemented the Akiyama-Tanigawa algorithm using 'cpp_rational' data type.
As there is no approximation in intermediate steps, it gives best accuracy.
It can be casted to the data types of 'cpp_dec_float'.
But, I think this implementation may be slower than the previous
implementations. So, there is trade-off between running time and precision.
We may implement 'bernoulli' function in two ways. If priority is running
time than the accuracy of precision, then we can use previous
implementation. If priority is the precision, then we can use this
I have attached the 3 files.
1) bernoulli.hpp : It contains the function fr calculating bernoulli number.
2) example.cpp : It contains the program to test bernoulli.hpp
3) test.cpp : This is the Boost.Test comparing the values calculated
by benoulli.hpp with some
of the published values.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk