Details#
-
template<std::size_t N, typename T>
std::array<std::remove_cvref_t<T>, N> ponio::detail::init_fill_array(T &&value)# fill an uninitialize array
int i = 42; const std::array<int,8> arr = ponio::detail::init_fill_array<8>( i ); // all values of `arr` are `42`
valuecan also be an invokable object that take an unsigned integer and return type stored in arrayT.const std::array<int,8> arr = ponio::detail::init_fill_array<8>([](int i){ return i*i; }); // get {0,1,4,9,16,25,36,49}
- Template Parameters:
N – size of array to fill
T – type of stored value in array
- Parameters:
value – value to fill in uninitialize array
-
template<std::size_t N, typename state_t, typename value_t, typename ArrayA_t, typename ArrayB_t>
auto ponio::detail::tpl_inner_product(ArrayA_t const &a, ArrayB_t const &b, state_t const &init, value_t const &mul_coeff)# inner product between two array from 0 to N
This function compute \(\texttt{init} + \sum_{i=0}^N \texttt{mul_coeff}a_ib_i\) without loop thanks to template.
- Template Parameters:
N – number of elements to compute
state_t – type of computed value
value_t – type of coefficents
ArrayA_t – type of first array
ArrayB_t – type of second array
- Parameters:
a – first array
b – second array
init – starting value to add other values to
mul_coeff – coefficient to multiply each multiplication of inner product
-
template<std::size_t Iexp, typename Arithmetic_t>
Arithmetic_t ponio::detail::power(Arithmetic_t value)# return
Iexpmultiplication ofvalueto make an efficient power function for integersNote
if we remove condition
Iexpcould be equal to zero, we could remove the requirement1can be converted intoArithmetic_t.- Template Parameters:
Iexp – exponent of expression
Arithmetic_t – arithmetic type (need multiplication and
1can be converted into this type)
- Parameters:
value – value to powered
- Returns:
constexpr Arithmetic_t \(\texttt{value}^{\texttt{Iexp}}=1\times\underbrace{\texttt{value}\times\cdots\times \texttt{value}}_{\texttt{Iexp}\ \text{times}}\) with \(\texttt{Iexp}\in\mathbb{N}\) (could be equal to zero)