policy_ref_snip3.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // Note that this file contains quickbook mark-up as well as code
  7. // and comments, don't change any of the special comment mark-ups!
  8. double some_value = 2.;
  9. //[policy_ref_snip3
  10. #include <boost/math/special_functions/gamma.hpp>
  11. using namespace boost::math::policies;
  12. using boost::math::tgamma;
  13. // Define a new policy *not* internally promoting RealType to double:
  14. typedef policy<
  15. promote_double<false>
  16. > my_policy;
  17. // Call the function, applying the new policy:
  18. double t1 = tgamma(some_value, my_policy());
  19. // Alternatively we could use helper function make_policy,
  20. // and concisely define everything at the call site:
  21. double t2 = tgamma(some_value, make_policy(promote_double<false>()));
  22. //] //[\policy_ref_snip3]
  23. #include <iostream>
  24. using std::cout; using std::endl;
  25. int main()
  26. {
  27. cout << "tgamma(some_value, my_policy()) = " << t1
  28. << ", tgamma(some_value, make_policy(promote_double<false>()) = " << t2 << endl;
  29. }