BVB Source Codes

mars Show common_factor_ct.hpp Source code

Return Download mars: download common_factor_ct.hpp Source code - Download mars Source code - Type:.hpp
  1. //  Boost common_factor_ct.hpp header file  ----------------------------------//
  2.  
  3. //  (C) Copyright Daryle Walker and Stephen Cleary 2001-2002.
  4. //  Distributed under the Boost Software License, Version 1.0. (See
  5. //  accompanying file LICENSE_1_0.txt or copy at
  6. //  http://www.boost.org/LICENSE_1_0.txt)
  7.  
  8. //  See http://www.boost.org for updates, documentation, and revision history.
  9.  
  10. #ifndef BOOST_MATH_COMMON_FACTOR_CT_HPP
  11. #define BOOST_MATH_COMMON_FACTOR_CT_HPP
  12.  
  13. #include <boost/math_fwd.hpp>  // self include
  14. #include <boost/config.hpp>  // for BOOST_STATIC_CONSTANT, etc.
  15. #include <boost/mpl/integral_c.hpp>
  16.  
  17. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost
  18. {
  19. namespace math
  20. {
  21.  
  22. //  Implementation details  --------------------------------------------------//
  23.  
  24. namespace detail
  25. {
  26.     // Build GCD with Euclid's recursive algorithm
  27.     template < static_gcd_type Value1, static_gcd_type Value2 >
  28.     struct static_gcd_helper_t
  29.     {
  30.     private:
  31.         BOOST_STATIC_CONSTANT( static_gcd_type, new_value1 = Value2 );
  32.         BOOST_STATIC_CONSTANT( static_gcd_type, new_value2 = Value1 % Value2 );
  33.  
  34.         #ifndef __BORLANDC__
  35.         #define BOOST_DETAIL_GCD_HELPER_VAL(Value) static_cast<static_gcd_type>(Value)
  36.         #else
  37.         typedef static_gcd_helper_t  self_type;
  38.         #define BOOST_DETAIL_GCD_HELPER_VAL(Value)  (self_type:: Value )
  39.         #endif
  40.  
  41.         typedef static_gcd_helper_t< BOOST_DETAIL_GCD_HELPER_VAL(new_value1),
  42.          BOOST_DETAIL_GCD_HELPER_VAL(new_value2) >  next_step_type;
  43.  
  44.         #undef BOOST_DETAIL_GCD_HELPER_VAL
  45.  
  46.     public:
  47.         BOOST_STATIC_CONSTANT( static_gcd_type, value = next_step_type::value );
  48.     };
  49.  
  50.     // Non-recursive case
  51.     template < static_gcd_type Value1 >
  52.     struct static_gcd_helper_t< Value1, 0UL >
  53.     {
  54.         BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 );
  55.     };
  56.  
  57.     // Build the LCM from the GCD
  58.     template < static_gcd_type Value1, static_gcd_type Value2 >
  59.     struct static_lcm_helper_t
  60.     {
  61.         typedef static_gcd_helper_t<Value1, Value2>  gcd_type;
  62.  
  63.         BOOST_STATIC_CONSTANT( static_gcd_type, value = Value1 / gcd_type::value
  64.          * Value2 );
  65.     };
  66.  
  67.     // Special case for zero-GCD values
  68.     template < >
  69.     struct static_lcm_helper_t< 0UL, 0UL >
  70.     {
  71.         BOOST_STATIC_CONSTANT( static_gcd_type, value = 0UL );
  72.     };
  73.  
  74. }  // namespace detail
  75.  
  76.  
  77. //  Compile-time greatest common divisor evaluator class declaration  --------//
  78.  
  79. template < static_gcd_type Value1, static_gcd_type Value2 >
  80. struct static_gcd : public mpl::integral_c<static_gcd_type, (detail::static_gcd_helper_t<Value1, Value2>::value) >
  81. {
  82. };  // mars_boost::math::static_gcd
  83.  
  84.  
  85. //  Compile-time least common multiple evaluator class declaration  ----------//
  86.  
  87. template < static_gcd_type Value1, static_gcd_type Value2 >
  88. struct static_lcm : public mpl::integral_c<static_gcd_type, (detail::static_lcm_helper_t<Value1, Value2>::value) >
  89. {
  90. };  // mars_boost::math::static_lcm
  91.  
  92.  
  93. }  // namespace math
  94. }  // namespace mars_boost
  95.  
  96.  
  97. #endif  // BOOST_MATH_COMMON_FACTOR_CT_HPP
  98.  
downloadcommon_factor_ct.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top