nuclear@0: nuclear@0: nuclear@0: #ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP nuclear@0: #define BOOST_MATH_COMMON_FACTOR_RT_HPP nuclear@0: nuclear@0: nuclear@0: namespace boost { nuclear@0: namespace math { nuclear@0: nuclear@0: // TODO: use binary GCD for unsigned integers .... nuclear@0: template < typename IntegerType > nuclear@0: IntegerType gcd( IntegerType a, IntegerType b ) nuclear@0: { nuclear@0: const IntegerType zero = (IntegerType)0; nuclear@0: while ( true ) nuclear@0: { nuclear@0: if ( a == zero ) nuclear@0: return b; nuclear@0: b %= a; nuclear@0: nuclear@0: if ( b == zero ) nuclear@0: return a; nuclear@0: a %= b; nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: template < typename IntegerType > nuclear@0: IntegerType lcm( IntegerType a, IntegerType b ) nuclear@0: { nuclear@0: const IntegerType t = gcd (a,b); nuclear@0: if (!t)return t; nuclear@0: return a / t * b; nuclear@0: } nuclear@0: nuclear@0: }} nuclear@0: nuclear@0: #endif