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;
57 ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, T>
::type lcm(T a, T b) ETL_NOEXCEPT
59 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Integral type required");
68 return a * (b / gcd(a, b));
77 ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_signed<T>::value, T>::type lcm(T a, T b) ETL_NOEXCEPT
79 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Integral type required");
81 typedef typename etl::make_unsigned<T>::type utype;
83 utype ua = etl::absolute_unsigned(a);
84 utype ub = etl::absolute_unsigned(b);
86 return static_cast<T
>(lcm(ua, ub));
90 #if ETL_HAS_INITIALIZER_LIST
96 template <
typename T,
typename... TRest>
97 ETL_NODISCARD ETL_CONSTEXPR14 T lcm(T first, TRest... rest) ETL_NOEXCEPT
101 for (T value : {rest...})
103 result = lcm(result, value);
121 template <
typename T,
typename... TRest>
122 ETL_NODISCARD ETL_CONSTEXPR14 T lcm(T a, T b, TRest... rest) ETL_NOEXCEPT
124 T lcm_ab = lcm(a, b);
134 return lcm(lcm_ab, rest...);
bitset_ext
Definition absolute.h:40