Please be quick to suspect this commit if the build should break on Windows/MSVC. (Again, sorry for the large commit, but I didnt want to flood the commit log with my git-style tiny commits.) git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@577 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
38 lines
615 B
C++
38 lines
615 B
C++
|
|
|
|
#ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP
|
|
#define BOOST_MATH_COMMON_FACTOR_RT_HPP
|
|
|
|
|
|
namespace boost {
|
|
namespace math {
|
|
|
|
// TODO: use binary GCD for unsigned integers ....
|
|
template < typename IntegerType >
|
|
IntegerType gcd( IntegerType a, IntegerType b )
|
|
{
|
|
const IntegerType zero = (IntegerType)0;
|
|
while ( true )
|
|
{
|
|
if ( a == zero )
|
|
return b;
|
|
b %= a;
|
|
|
|
if ( b == zero )
|
|
return a;
|
|
a %= b;
|
|
}
|
|
}
|
|
|
|
template < typename IntegerType >
|
|
IntegerType lcm( IntegerType a, IntegerType b )
|
|
{
|
|
const IntegerType t = gcd (a,b);
|
|
if (!t)return t;
|
|
return a / t * b;
|
|
}
|
|
|
|
}}
|
|
|
|
#endif
|