]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/example/policy_eg_5.cpp
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)
7 // Note that this file contains quickbook mark-up as well as code
8 // and comments, don't change any of the special comment mark-ups!
11 using std::cout
; using std::endl
;
12 #include <cerrno> // for ::errno
16 #include <boost/math/special_functions.hpp>
17 // using boost::math::tgamma; // Would create an ambiguity between
18 // 'double boost::math::tgamma<int>(T)' and
19 // 'double 'anonymous-namespace'::tgamma<int>(RT)'.
24 using namespace boost::math::policies
;
27 domain_error
<errno_on_error
>,
28 pole_error
<errno_on_error
>,
29 overflow_error
<errno_on_error
>,
30 evaluation_error
<errno_on_error
>
33 BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(c_policy
)
36 So that when we call `mymath::tgamma(z)`, we really end up calling
37 `boost::math::tgamma(z, anonymous-namespace::c_policy())`.
40 } // close unnamed namespace
45 cout
<< "Result of tgamma(30000) is: "
46 << mymath::tgamma(30000) << endl
;
47 // tgamma in unnamed namespace in this translation unit (file) only.
48 cout
<< "errno = " << errno
<< endl
;
49 cout
<< "Result of tgamma(-10) is: "
50 << mymath::tgamma(-10) << endl
;
51 cout
<< "errno = " << errno
<< endl
;
52 // Default tgamma policy would throw an exception, and abort.
60 Result of tgamma(30000) is: 1.#INF
62 Result of tgamma(-10) is: 1.#QNAN