Details#

template<std::size_t N, typename T>
constexpr std::array<std::remove_cvref_t<T>, N> detail::init_fill_array(T &&value)#

fill an uninitialize array

int i = 42;
const std::array<int,8> arr = detail::init_fill_array<8>( i ); // all values of `arr` are `42`

value can also be an invokable object that take an unsigned integer and return type stored in array T.

const std::array<int,8> arr = 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>
constexpr state_t detail::tpl_inner_product(ArrayA_t const &a, ArrayB_t const &b, state_t const &init, value_t mul_coeff = value_t{1.0})#

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>
constexpr Arithmetic_t detail::power(Arithmetic_t &&value)#

return Iexp multiplication of value to make an efficient power function for integers

Note

if we remove condition Iexp could be equal to zero, we could remove the requirement 1 can be converted into Arithmetic_t.

Template Parameters:
  • Iexp – exponent of expression

  • Arithmetic_t – arithmetic type (need multiplication and 1 can 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)