22 template <std::size_t first, std::size_t second, std::size_t... tail>
26 if constexpr (first <= second)
28 if constexpr (
sizeof...(tail) == 0)
40 template <std::
size_t N>
46 else if constexpr (
N == 1)
55 template <std::
size_t N, std::
size_t M>
65 template <std::size_t... first, std::size_t... second>
67 merge(std::index_sequence<first...>, std::index_sequence<second...>)
69 return std::index_sequence<first..., second...>{};
76 template <std::size_t Nmax, std::size_t first, std::size_t... tail>
80 if constexpr (first + 1 == Nmax)
82 if constexpr (
sizeof...(tail) == 0)
83 return std::index_sequence<>{};
85 return merge(std::index_sequence<0>{}, increment<Nmax>(std::index_sequence<tail...>{}));
88 return std::index_sequence<first + 1, tail...>{};
94 template <std::size_t M, std::size_t...
N>
98 return (num_derivatives<N, M>() + ...);
105 template <std::size_t... Ns>
109 return std::index_sequence<(
void(Ns), 0)...>{};
117 template <std::size_t first, std::size_t second, std::size_t... tail>
127 template <std::
size_t first>
137 template <std::
size_t N, std::
size_t M>
138 constexpr std::size_t
143 return details::total_derivatives<M>(std::make_index_sequence<N + 1>{}) - 1;
156 template <
typename T, std::size_t... Ns>
167 template <std::
size_t N>
177 template <
typename T, std::size_t first, std::size_t... tags>
181 if constexpr (
sizeof...(tags) == 0)
182 return expression.template D<static_cast<CompileTimeDerivatives::CTTag>(first)>();
185 expression.template D<static_cast<CompileTimeDerivatives::CTTag>(first)>(),
186 std::index_sequence<tags...>{});
constexpr auto make_tuple_array(std::index_sequence< Ns... >)
Create a tuple with sizeof...(Ns) entries, containing CTArrayRefs with tags given by the Ns...
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 Nma...
constexpr std::size_t total_derivatives()
Compute the total number of distinct derivatives for all orders 1 through N.
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 z...
auto take_derivatives(const T &expression, std::index_sequence< first, tags... >)
Take all derivatives of expression listed in the index sequence.
constexpr auto merge(std::index_sequence< first... >, std::index_sequence< second... >)
Merge two index sequences into one.
constexpr bool is_sorted()
Check if the given index sequence is sorted ()internal function)
constexpr std::size_t num_derivatives()
Number of distinct order N derivatives of a function with M variables.
constexpr std::size_t total_derivatives(std::index_sequence< N... >)
Compute the total number of distinct derivatives for all orders N.
constexpr auto zeroes()
Create an index sequence containing N zeroes.
constexpr std::size_t factorial()
Compile time evaluation of the factorial of N.
class infix_ostream_iterator if void
constexpr bool is_sorted(std::index_sequence< first, second, tail... >)
Check if the given index sequence is sorted.