Details#

template<typename state_t>
auto ponio::detail::norm(state_t const &x)#

compute \(L_1\) norm of a container: \(\sum_i |x_i|\)

Template Parameters:

state_t – type of computed value

Parameters:

x – container

template<typename state_t, typename value_t>
auto ponio::detail::error_estimate(state_t const &un, state_t const &unp1, state_t const &unp1bis, value_t a_tol, value_t r_tol)#

compute an error

\[\sqrt{\frac{1}{N}\sum_i \left( \frac{|u^{n+1}_i - \tilde{u}^{n+1}_i|}{a_{tol}+ r_{tol} \max(|u^n_i|, |u^{n+1}_i|)}\right)^2}\]

Template Parameters:
  • state_t – type of computed value

  • value_t – type of tolerances

Parameters:
  • un – state \(u^n\)

  • unp1 – state \(u^{n+1}\)

  • unp1bis – state \(\tilde{u}^{n+1}\)

  • a_tol – absolute tolerance

  • r_tol – relative tolerance

template<std::size_t N, typename state_t, typename value_t, typename ArrayA_t, typename ArrayB_t>
void ponio::detail::tpl_inner_product(ArrayA_t const &a, ArrayB_t const &b, state_t const &init, value_t const &mul_coeff, state_t &output)#

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

  • output – output to store result

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`

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 = 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 Iexp, typename Arithmetic_t>
Arithmetic_t ponio::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)