mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-06 14:14:46 +08:00
* revise the meta_least_common_multiple function template, add a bool variable to check whether the A is larger than B.
* This can make less compile_time if A is smaller than B. and avoid failure in compile if we get a little A and a great B. Authored by @awoniu.
This commit is contained in:
parent
f1b899eef7
commit
8ce341caf2
@ -715,20 +715,25 @@ class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ?
|
|||||||
|
|
||||||
|
|
||||||
/** \internal Computes the least common multiple of two positive integer A and B
|
/** \internal Computes the least common multiple of two positive integer A and B
|
||||||
* at compile-time. It implements a naive algorithm testing all multiples of A.
|
* at compile-time.
|
||||||
* It thus works better if A>=B.
|
|
||||||
*/
|
*/
|
||||||
template<int A, int B, int K=1, bool Done = ((A*K)%B)==0>
|
template<int A, int B, int K=1, bool Done = ((A*K)%B)==0, bool Big=(A>=B)>
|
||||||
struct meta_least_common_multiple
|
struct meta_least_common_multiple
|
||||||
{
|
{
|
||||||
enum { ret = meta_least_common_multiple<A,B,K+1>::ret };
|
enum { ret = meta_least_common_multiple<A,B,K+1>::ret };
|
||||||
};
|
};
|
||||||
|
template<int A, int B, int K, bool Done>
|
||||||
|
struct meta_least_common_multiple<A,B,K,Done,false>
|
||||||
|
{
|
||||||
|
enum { ret = meta_least_common_multiple<B,A,K>::ret };
|
||||||
|
};
|
||||||
template<int A, int B, int K>
|
template<int A, int B, int K>
|
||||||
struct meta_least_common_multiple<A,B,K,true>
|
struct meta_least_common_multiple<A,B,K,true,true>
|
||||||
{
|
{
|
||||||
enum { ret = A*K };
|
enum { ret = A*K };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** \internal determines whether the product of two numeric types is allowed and what the return type is */
|
/** \internal determines whether the product of two numeric types is allowed and what the return type is */
|
||||||
template<typename T, typename U> struct scalar_product_traits
|
template<typename T, typename U> struct scalar_product_traits
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user