mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 03:39:01 +08:00
Add meta_least_common_multiple helper.
This commit is contained in:
parent
fecea26d93
commit
21b5345782
@ -326,6 +326,22 @@ class meta_sqrt
|
||||
template<int Y, int InfX, int SupX>
|
||||
class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
|
||||
|
||||
|
||||
/** \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.
|
||||
* It thus works better if A>=B.
|
||||
*/
|
||||
template<int A, int B, int K=1, bool Done = ((A*K)%B)==0>
|
||||
struct meta_least_common_multiple
|
||||
{
|
||||
enum { ret = meta_least_common_multiple<A,B,K+1>::ret };
|
||||
};
|
||||
template<int A, int B, int K>
|
||||
struct meta_least_common_multiple<A,B,K,true>
|
||||
{
|
||||
enum { ret = A*K };
|
||||
};
|
||||
|
||||
/** \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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user