31#ifndef ETL_LCM_INCLUDED
32#define ETL_LCM_INCLUDED
37#include "static_assert.h"
46 template <
intmax_t Value1,
intmax_t Value2>
49 static ETL_CONSTANT intmax_t value = (Value1 / gcd_const<Value1, Value2>::value) * Value2;
60 lcm(T a, T b) ETL_NOEXCEPT
62 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Integral type required");
71 return a * (b / gcd(a, b));
82 typename etl::enable_if<etl::is_signed<T>::value, T>::type
83 lcm(T a, T b) ETL_NOEXCEPT
85 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Integral type required");
87 typedef typename etl::make_unsigned<T>::type utype;
89 utype ua = etl::absolute_unsigned(a);
90 utype ub = etl::absolute_unsigned(b);
92 return static_cast<T
>(lcm(ua, ub));
96 #if ETL_HAS_INITIALIZER_LIST
102 template<
typename T,
typename... TRest>
105 T lcm(T first, TRest... rest) ETL_NOEXCEPT
109 for (T value : {rest...})
111 result = lcm(result, value);
129 template<
typename T,
typename... TRest>
132 T lcm(T a, T b, TRest... rest) ETL_NOEXCEPT
134 T lcm_ab = lcm(a, b);
144 return lcm(lcm_ab, rest...);
enable_if
Definition type_traits_generator.h:1254
bitset_ext
Definition absolute.h:39