]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/tools/factorial_tables.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / tools / factorial_tables.cpp
1 // (C) Copyright John Maddock 2007.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #include <boost/limits.hpp>
7 #include <vector>
8 #include "mp_t.hpp"
9
10 void write_table(unsigned max_exponent)
11 {
12 mp_t max = ldexp(mp_t(1), (int)max_exponent);
13
14 std::vector<mp_t> factorials;
15 factorials.push_back(1);
16
17 mp_t f(1);
18 unsigned i = 1;
19
20 while(f < max)
21 {
22 factorials.push_back(f);
23 ++i;
24 f *= i;
25 }
26
27 //
28 // now write out the results to cout:
29 //
30 std::cout << std::scientific << std::setprecision(40);
31 std::cout << " static const std::array<T, " << factorials.size() << "> factorials = {\n";
32 for(unsigned j = 0; j < factorials.size(); ++j)
33 std::cout << " " << factorials[j] << "L,\n";
34 std::cout << " };\n\n";
35 }
36
37
38 int main()
39 {
40 write_table(16384/*std::numeric_limits<float>::max_exponent*/);
41 }