]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/example/policy_eg_1.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)
8 using std::cout
; using std::endl
;
9 #include <cerrno> // for ::errno
13 #include <boost/math/special_functions/gamma.hpp>
14 using boost::math::tgamma
;
16 // Define the policy to use:
17 using namespace boost::math::policies
; // may be convenient, or
19 using boost::math::policies::policy
;
20 // Types of error whose action can be altered by policies:.
21 using boost::math::policies::evaluation_error
;
22 using boost::math::policies::domain_error
;
23 using boost::math::policies::overflow_error
;
24 using boost::math::policies::domain_error
;
25 using boost::math::policies::pole_error
;
26 // Actions on error (in enum error_policy_type):
27 using boost::math::policies::errno_on_error
;
28 using boost::math::policies::ignore_error
;
29 using boost::math::policies::throw_on_error
;
30 using boost::math::policies::user_error
;
33 domain_error
<errno_on_error
>,
34 pole_error
<errno_on_error
>,
35 overflow_error
<errno_on_error
>,
36 evaluation_error
<errno_on_error
>
39 // Now use the policy when calling tgamma:
41 // http://msdn.microsoft.com/en-us/library/t3ayayh1.aspx
42 // Microsoft errno declared in STDLIB.H as "extern int errno;"
47 cout
<< "Result of tgamma(30000) is: "
48 << tgamma(30000, c_policy()) << endl
; // Too big parameter
49 cout
<< "errno = " << errno
<< endl
; // errno 34 Numerical result out of range.
50 cout
<< "Result of tgamma(-10) is: "
51 << boost::math::tgamma(-10, c_policy()) << endl
; // Negative parameter.
52 cout
<< "errno = " << errno
<< endl
; // error 33 Numerical argument out of domain.
61 Finished generating code
62 policy_eg_1.vcxproj -> J:\Cpp\MathToolkit\test\Math_test\Release\policy_eg_1.exe
63 Result of tgamma(30000) is: 1.#INF
65 Result of tgamma(-10) is: 1.#QNAN