vrshoot
annotate libs/assimp/boost/math/common_factor_rt.hpp @ 3:c179c72369be
rename candy->vr
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 03 Feb 2014 08:52:13 +0200 |
parents | |
children |
rev | line source |
---|---|
nuclear@0 | 1 |
nuclear@0 | 2 |
nuclear@0 | 3 #ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP |
nuclear@0 | 4 #define BOOST_MATH_COMMON_FACTOR_RT_HPP |
nuclear@0 | 5 |
nuclear@0 | 6 |
nuclear@0 | 7 namespace boost { |
nuclear@0 | 8 namespace math { |
nuclear@0 | 9 |
nuclear@0 | 10 // TODO: use binary GCD for unsigned integers .... |
nuclear@0 | 11 template < typename IntegerType > |
nuclear@0 | 12 IntegerType gcd( IntegerType a, IntegerType b ) |
nuclear@0 | 13 { |
nuclear@0 | 14 const IntegerType zero = (IntegerType)0; |
nuclear@0 | 15 while ( true ) |
nuclear@0 | 16 { |
nuclear@0 | 17 if ( a == zero ) |
nuclear@0 | 18 return b; |
nuclear@0 | 19 b %= a; |
nuclear@0 | 20 |
nuclear@0 | 21 if ( b == zero ) |
nuclear@0 | 22 return a; |
nuclear@0 | 23 a %= b; |
nuclear@0 | 24 } |
nuclear@0 | 25 } |
nuclear@0 | 26 |
nuclear@0 | 27 template < typename IntegerType > |
nuclear@0 | 28 IntegerType lcm( IntegerType a, IntegerType b ) |
nuclear@0 | 29 { |
nuclear@0 | 30 const IntegerType t = gcd (a,b); |
nuclear@0 | 31 if (!t)return t; |
nuclear@0 | 32 return a / t * b; |
nuclear@0 | 33 } |
nuclear@0 | 34 |
nuclear@0 | 35 }} |
nuclear@0 | 36 |
nuclear@0 | 37 #endif |