31#ifndef ETL_NUMERIC_INCLUDED
32#define ETL_NUMERIC_INCLUDED
57 template <
typename TIterator,
typename T>
58 ETL_CONSTEXPR14
void iota(TIterator first, TIterator last, T value)
71 ETL_CONSTEXPR14
typename etl::enable_if< !etl::is_pointer<T>::value && !etl::is_integral<T>::value && etl::is_floating_point<T>::value, T>
::type
77 return ((
abs(a) <= hi) && (
abs(b) <= hi)) ? (a + b) / T(2)
78 : (
abs(a) < lo) ? a + (b / T(2))
79 : (
abs(b) < lo) ? ((a / T(2)) + b)
80 : (a / T(2)) + (b / T(2));
88 ETL_CONSTEXPR14
typename etl::enable_if<
89 !etl::is_pointer<T>::value && etl::is_integral<T>::value && !etl::is_floating_point<T>::value && etl::is_unsigned<T>::value, T>
::type
94 return a - ((a - b) >> 1);
98 return a + ((b - a) >> 1);
106 template <
typename T>
107 ETL_CONSTEXPR14
typename etl::enable_if<
108 !etl::is_pointer<T>::value && etl::is_integral<T>::value && !etl::is_floating_point<T>::value && etl::is_signed<T>::value, T>
::type
111 typedef typename etl::make_unsigned<T>::type utype;
115 return a - T(utype(utype(a) - utype(b)) >> 1);
119 return a + T((utype(b) - utype(a)) >> 1);
127 template <
typename T>
128 ETL_CONSTEXPR14
typename etl::enable_if< etl::is_pointer<T>::value && !etl::is_integral<T>::value && !etl::is_floating_point<T>::value, T>
::type
133 return b + (etl::distance(b, a) / 2U);
137 return a + (etl::distance(a, b) / 2U);
145 template <
typename T>
148 typename etl::enable_if< !etl::is_pointer<T>::value && !etl::is_integral<T>::value && !etl::is_floating_point<T>::value
149 && etl::is_same<
typename etl::iterator_traits<T>::iterator_category, ETL_OR_STD::random_access_iterator_tag>::value,
154 return b + (etl::distance(b, a) / 2U);
158 return a + (etl::distance(a, b) / 2U);
167 template <
typename T>
169 typename etl::enable_if<
170 (!etl::is_pointer<T>::value && !etl::is_integral<T>::value && !etl::is_floating_point<T>::value
171 && (etl::is_same<
typename etl::iterator_traits<T>::iterator_category, ETL_OR_STD::forward_iterator_tag>::value
172 || etl::is_same<
typename etl::iterator_traits<T>::iterator_category, ETL_OR_STD::bidirectional_iterator_tag>::value)),
175 etl::advance(a, etl::distance(a, b) / 2U);
183 template <
typename T>
184 ETL_CONSTEXPR
typename etl::enable_if<etl::is_floating_point<T>::value, T>
::type lerp(T a, T b, T t) ETL_NOEXCEPT
186 return a + (t * (b - a));
193 template <
typename TArithmetic1,
typename TArithmetic2,
typename TArithmetic3>
194 ETL_CONSTEXPR
typename etl::enable_if<
195 !etl::is_floating_point<TArithmetic1>::value || !etl::is_floating_point<TArithmetic2>::value || !etl::is_floating_point<TArithmetic3>::value,
196 typename etl::conditional< etl::is_same<TArithmetic1, long double>::value || etl::is_same<TArithmetic2, long double>::value
197 || etl::is_same<TArithmetic3, long double>::value,
199 lerp(TArithmetic1 a, TArithmetic2 b, TArithmetic3 t) ETL_NOEXCEPT
201 typedef typename etl::conditional<etl::is_integral<TArithmetic1>::value, double, TArithmetic1>
::type typecast_a;
202 typedef typename etl::conditional<etl::is_integral<TArithmetic2>::value, double, TArithmetic2>
::type typecast_b;
203 typedef typename etl::conditional<etl::is_integral<TArithmetic3>::value, double, TArithmetic3>
::type typecast_t;
205 return typecast_a(a) + (typecast_t(t) * (typecast_b(b) - typecast_a(a)));
ETL_CONSTEXPR14 void iota(TIterator first, TIterator last, T value)
Definition numeric.h:58
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 etl::chrono::duration< TRep, TPeriod > abs(etl::chrono::duration< TRep, TPeriod > d) ETL_NOEXCEPT
Returns the absolute value of a duration.
Definition duration.h:688
ETL_CONSTEXPR etl::enable_if< etl::is_floating_point< T >::value, T >::type lerp(T a, T b, T t) ETL_NOEXCEPT
Definition numeric.h:184
ETL_CONSTEXPR14 etl::enable_if<!etl::is_pointer< T >::value &&!etl::is_integral< T >::value &&etl::is_floating_point< T >::value, T >::type midpoint(T a, T b) ETL_NOEXCEPT
Definition numeric.h:72