https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Functions
CompileTimeDerivativesMaterialInternal::details Namespace Reference

Functions

template<std::size_t first, std::size_t second, std::size_t... tail>
constexpr bool is_sorted ()
 Check if the given index sequence is sorted ()internal function)
 
template<std::size_t N>
constexpr std::size_t factorial ()
 Compile time evaluation of the factorial of N.
 
template<std::size_t N, std::size_t M>
constexpr std::size_t num_derivatives ()
 Number of distinct order N derivatives of a function with M variables.
 
template<std::size_t... first, std::size_t... second>
constexpr auto merge (std::index_sequence< first... >, std::index_sequence< second... >)
 Merge two index sequences into one.
 
template<std::size_t Nmax, std::size_t first, std::size_t... tail>
constexpr auto increment (std::index_sequence< first, tail... >)
 Increment the first number in an index sequence, but roll over into the next number if it reaches Nmax.
 
template<std::size_t M, std::size_t... N>
constexpr std::size_t total_derivatives (std::index_sequence< N... >)
 Compute the total number of distinct derivatives for all orders N.
 
template<std::size_t... Ns>
constexpr auto zeroes (std::index_sequence< Ns... >)
 Take an index sequence and return an index sequence of the same length with all entries replaced by zeroes.
 

Function Documentation

◆ factorial()

template<std::size_t N>
constexpr std::size_t CompileTimeDerivativesMaterialInternal::details::factorial ( )
constexpr

Compile time evaluation of the factorial of N.

Definition at line 42 of file CompileTimeDerivativesMaterialInternal.h.

43{
44 if constexpr (N == 0)
45 return 1;
46 else if constexpr (N == 1)
47 return 1;
48 else
49 return N * factorial<N - 1>();
50}

Referenced by factorial(), and num_derivatives().

◆ increment()

template<std::size_t Nmax, std::size_t first, std::size_t... tail>
constexpr auto CompileTimeDerivativesMaterialInternal::details::increment ( std::index_sequence< first, tail... >  )
constexpr

Increment the first number in an index sequence, but roll over into the next number if it reaches Nmax.

This basically increments a base-Nmax number with its digits in reverse!

Definition at line 78 of file CompileTimeDerivativesMaterialInternal.h.

79{
80 if constexpr (first + 1 == Nmax)
81 {
82 if constexpr (sizeof...(tail) == 0)
83 return std::index_sequence<>{};
84 else
85 return merge(std::index_sequence<0>{}, increment<Nmax>(std::index_sequence<tail...>{}));
86 }
87 else
88 return std::index_sequence<first + 1, tail...>{};
89}

◆ is_sorted()

template<std::size_t first, std::size_t second, std::size_t... tail>
constexpr bool CompileTimeDerivativesMaterialInternal::details::is_sorted ( )
constexpr

Check if the given index sequence is sorted ()internal function)

Definition at line 24 of file CompileTimeDerivativesMaterialInternal.h.

25{
26 if constexpr (first <= second)
27 {
28 if constexpr (sizeof...(tail) == 0)
29 return true;
30 else
31 return is_sorted<second, tail...>();
32 }
33 else
34 return false;
35}
constexpr bool is_sorted()
Check if the given index sequence is sorted ()internal function)

Referenced by is_sorted(), and CompileTimeDerivativesMaterialInternal::is_sorted().

◆ merge()

template<std::size_t... first, std::size_t... second>
constexpr auto CompileTimeDerivativesMaterialInternal::details::merge ( std::index_sequence< first... >  ,
std::index_sequence< second... >   
)
constexpr

Merge two index sequences into one.

Definition at line 67 of file CompileTimeDerivativesMaterialInternal.h.

68{
69 return std::index_sequence<first..., second...>{};
70}

Referenced by increment().

◆ num_derivatives()

template<std::size_t N, std::size_t M>
constexpr std::size_t CompileTimeDerivativesMaterialInternal::details::num_derivatives ( )
constexpr

Number of distinct order N derivatives of a function with M variables.

Definition at line 57 of file CompileTimeDerivativesMaterialInternal.h.

58{
59 return factorial<N + M - 1>() / (factorial<N>() * factorial<M - 1>());
60}

◆ total_derivatives()

template<std::size_t M, std::size_t... N>
constexpr std::size_t CompileTimeDerivativesMaterialInternal::details::total_derivatives ( std::index_sequence< N... >  )
constexpr

Compute the total number of distinct derivatives for all orders N.

Definition at line 96 of file CompileTimeDerivativesMaterialInternal.h.

97{
98 return (num_derivatives<N, M>() + ...);
99}

◆ zeroes()

template<std::size_t... Ns>
constexpr auto CompileTimeDerivativesMaterialInternal::details::zeroes ( std::index_sequence< Ns... >  )
constexpr

Take an index sequence and return an index sequence of the same length with all entries replaced by zeroes.

Definition at line 107 of file CompileTimeDerivativesMaterialInternal.h.

108{
109 return std::index_sequence<(void(Ns), 0)...>{};
110}

Referenced by CompileTimeDerivativesMaterialInternal::zeroes().