vrshoot
diff libs/assimp/boost/math/common_factor_rt.hpp @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/boost/math/common_factor_rt.hpp Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,37 @@ 1.4 + 1.5 + 1.6 +#ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP 1.7 +#define BOOST_MATH_COMMON_FACTOR_RT_HPP 1.8 + 1.9 + 1.10 +namespace boost { 1.11 +namespace math { 1.12 + 1.13 +// TODO: use binary GCD for unsigned integers .... 1.14 +template < typename IntegerType > 1.15 +IntegerType gcd( IntegerType a, IntegerType b ) 1.16 +{ 1.17 + const IntegerType zero = (IntegerType)0; 1.18 + while ( true ) 1.19 + { 1.20 + if ( a == zero ) 1.21 + return b; 1.22 + b %= a; 1.23 + 1.24 + if ( b == zero ) 1.25 + return a; 1.26 + a %= b; 1.27 + } 1.28 +} 1.29 + 1.30 +template < typename IntegerType > 1.31 +IntegerType lcm( IntegerType a, IntegerType b ) 1.32 +{ 1.33 + const IntegerType t = gcd (a,b); 1.34 + if (!t)return t; 1.35 + return a / t * b; 1.36 +} 1.37 + 1.38 +}} 1.39 + 1.40 +#endif