GSoC : Boost.Math Bernoulli Numbers
Hi, I am Gaurav Deshmukh, CSE second year student. I am interested in the idea of adding support to Bernoulli's number to special functions in Boost.Math for GSoC-2013. I have the experience of using Boost libraries and generics in C++. I have experience to use git. I have also learned to use Boost Test upto some extent. I have tried to implement naive Akiyama–Tanigawa algorithm for second Bernoulli numbers using multi-precision boost class *'number' (cpp_dec_float_50**)*. I have attached two files. The header file *bernoulli.hpp* contains the function to calculate second bernoulli number for n<3000. *exampe.cpp *is made to test the bernoulli.hpp .
I am Gaurav Deshmukh, CSE second year student. I am interested in the idea of adding support to Bernoulli's number to special functions in Boost.Math for GSoC-2013.
Hi Gaurav. Thank you for your interest in this project.
I have tried to implement naive Akiyama–Tanigawa algorithm for second Bernoulli numbers using multi-precision boost class *'number' (cpp_dec_float_50**)*. I have attached two files. The header file *bernoulli.hpp* contains the function to calculate second bernoulli number for n<3000. *exampe.cpp *is made to test the bernoulli.hpp .
It's pretty good work, but I have a few suggestions. 1) You should reserve the known size of the vector with its known size (n) up front using the reserve() member. It has better performance than successively calling push_back() on an unreserved vector. 2) You have an implementation for cpp_dec_float. Very good. But please try to make a template solution such as: template<typename float_type> bernoulli(unsigned n) { // ... } Test it a bit for float, double, and cpp_dec_float. There is quite a bit of interest in this project. I do however, encourage you to work up your application and apply for this project. Get back to me and Paul with any questions you may have. Good luck! Sincerely, Chris.
Hi Chris, Thank you for your encouragement. I have tried to change my implementation of 'bernoulli' function according to your suggestions.
1)You should reserve the known size of the vector with its known size (n) up front using the reserve() member. It has better performance than successively calling push_back() on an unreserved vector.
I have initialized the vector size at its declaration using constructor.
std::vector
2) You have an implementation for cpp_dec_float. Very good. But please try to make a template solution.
I have made the return type generic. I tested it for float,double and cpp_dec_foat. As the precision of 'float' is least, it gives least accurate answer by Akiyama-Tanigawa algorithm. 'Double' gives accuracy upto 6 decimal points for n<16. However, 'cpp_dec_float' gives more accuracy. But, still accuracy is not 100% by Akiyama-Tanigawa algorithm. After 10 decimal points, generally there is mismatch in published values and values calculated by this algorithm. I have attached the modified files. Thank You, Gaurav Deshmukh
participants (2)
-
Christopher Kormanyos
-
Gaurav Deshmukh