• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // inverse_gamma_example.cpp
2 
3 // Copyright Paul A. Bristow 2010.
4 
5 // Use, modification and distribution are subject to the
6 // Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt
8 // or copy at http://www.boost.org/LICENSE_1_0.txt)
9 
10 // Example 1 of using inverse gamma functions.
11 
12 #include <boost/math/special_functions/gamma.hpp>
13 
14 using boost::math::gamma_p_inv; // Compute x given a
15 //using boost::math::gamma_q_inv;
16 //using boost::math::gamma_p_inva; // Compute a given x
17 //using boost::math::gamma_q_inva;
18 
19 #include <iostream>
20    using std::cout;    using std::endl;
21 #include <iomanip>
22    using std::setprecision;
23 #include <cmath>
24    using std::sqrt;
25 #include <limits>
26 
main()27 int main()
28 {
29   cout << "Example 1 using Inverse Gamma function. " << endl;
30 
31   #ifdef BOOST_NO_CXX11_NUMERIC_LIMITS
32   int max_digits10 = 2 + (boost::math::policies::digits<double, boost::math::policies::policy<> >() * 30103UL) / 100000UL;
33   cout << "BOOST_NO_CXX11_NUMERIC_LIMITS is defined" << endl;
34 #else
35   int max_digits10 = std::numeric_limits<double>::max_digits10;
36 #endif
37   cout << "Show all potentially significant decimal digits std::numeric_limits<double>::max_digits10 = "
38     << max_digits10 << endl;
39   cout.precision(max_digits10); //
40 
41   double x = 1.;
42   double a = 10;
43 
44   double r = boost::math::gamma_q_inv(a ,x);
45 
46   cout << " x = " << x << ", = gamma_q_inv(a,x)" << r << endl; //
47 
48   return 0;
49 }  // int main()
50 
51 /*
52 
53 Output is:
54 
55 */
56 
57 
58