]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright John Maddock 2007. |
2 | // Copyright Paul A. Bristow 2010 | |
3 | // Use, modification and distribution are subject to the | |
4 | // Boost Software License, Version 1.0. (See accompanying file | |
5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | #include <iostream> | |
8 | using std::cout; using std::endl; | |
9 | #include <cerrno> // for ::errno | |
10 | ||
11 | //[policy_eg_2 | |
12 | ||
13 | #include <boost/math/special_functions/gamma.hpp> | |
14 | using boost::math::tgamma; | |
15 | ||
16 | int main() | |
17 | { | |
18 | // using namespace boost::math::policies; // or | |
19 | using boost::math::policies::errno_on_error; | |
20 | using boost::math::policies::make_policy; | |
21 | using boost::math::policies::pole_error; | |
22 | using boost::math::policies::domain_error; | |
23 | using boost::math::policies::overflow_error; | |
24 | using boost::math::policies::evaluation_error; | |
25 | ||
26 | errno = 0; | |
27 | std::cout << "Result of tgamma(30000) is: " | |
28 | << boost::math::tgamma( | |
29 | 30000, | |
30 | make_policy( | |
31 | domain_error<errno_on_error>(), | |
32 | pole_error<errno_on_error>(), | |
33 | overflow_error<errno_on_error>(), | |
34 | evaluation_error<errno_on_error>() | |
35 | ) | |
36 | ) << std::endl; | |
37 | // Check errno was set: | |
38 | std::cout << "errno = " << errno << std::endl; | |
39 | // and again with evaluation at a pole: | |
40 | std::cout << "Result of tgamma(-10) is: " | |
41 | << boost::math::tgamma( | |
42 | -10, | |
43 | make_policy( | |
44 | domain_error<errno_on_error>(), | |
45 | pole_error<errno_on_error>(), | |
46 | overflow_error<errno_on_error>(), | |
47 | evaluation_error<errno_on_error>() | |
48 | ) | |
49 | ) << std::endl; | |
50 | // Check errno was set: | |
51 | std::cout << "errno = " << errno << std::endl; | |
52 | } | |
53 | ||
54 | //] //[/policy_eg_2] | |
55 | ||
56 | /* | |
57 | ||
58 | Output: | |
59 | ||
60 | Result of tgamma(30000) is: 1.#INF | |
61 | errno = 34 | |
62 | Result of tgamma(-10) is: 1.#QNAN | |
63 | errno = 33 | |
64 | */ | |
65 |