]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/example/policy_ref_snip12.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!
10 // Define tgamma function with a no overflow policy
11 // into a specific namespace-scope.
14 using std::cout
; using std::endl
;
18 #include <boost/math/special_functions/gamma.hpp>
19 //using boost::math::tgamma;
20 // Need not declare using boost::math::tgamma here,
21 // because will define tgamma in myspace using macro below.
25 using namespace boost::math::policies
;
27 // Define a policy that does not throw on overflow:
28 typedef policy
<overflow_error
<errno_on_error
> > my_policy
;
30 // Define the special functions in this scope to use the policy:
31 BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(my_policy
)
34 // Now we can use myspace::tgamma etc.
35 // They will automatically use "my_policy":
37 double t
= myspace::tgamma(30.0); // Will *not* throw on overflow,
38 // despite the large value of factorial 30 = 265252859812191058636308480000000
39 // unlike default policy boost::math::tgamma;
45 cout
<< "myspace::tgamma(30.0) = " << t
<< endl
;
52 myspace::tgamma(30.0) = 8.84176e+030