19template<
typename E, std::
size_t Dim,
typename =
void>
23template<
typename E, std::
size_t Dim>
31template<
typename T, std::
size_t Dim>
35template<
typename T, std::
size_t Dim>
39template<
typename T, std::
size_t Dim>
43template<std::
size_t N,
typename T, std::
size_t Dim>
45 : std::bool_constant<N == Dim> {};
48template<
typename E,
int N, std::
size_t Dim>
50 std::enable_if_t<N != -1 && has_antiderivative_v<E, Dim> &&
51 std::is_same_v<E, Var<Dim, typename E::value_type>>>>
55template<
typename E, std::
size_t Dim>
57 std::enable_if_t<std::is_same_v<E, Var<Dim, typename E::value_type>>>>
61template<
typename E, std::
size_t Dim>
63 std::enable_if_t<std::is_same_v<E, Var<Dim, typename E::value_type>>>>
67template<
typename E, std::
size_t Dim>
69 std::enable_if_t<std::is_same_v<E, Var<Dim, typename E::value_type>>>>
76template<
typename L,
typename R, std::
size_t Dim>
78 : std::bool_constant<has_antiderivative_v<L, Dim> && has_antiderivative_v<R, Dim>> {};
81template<
typename L,
typename R, std::
size_t Dim>
83 : std::bool_constant<has_antiderivative_v<L, Dim> && has_antiderivative_v<R, Dim>> {};
86template<
typename L,
typename R, std::
size_t Dim>
90 (is_const_expr_v<L> || is_zero_v<L> || is_one_v<L> ||
91 (is_expr_node_v<L> && !std::is_same_v<L, Var<Dim, typename L::value_type>> &&
92 L::arity_v <= Dim)) &&
93 has_antiderivative_v<R, Dim>
94 >> : std::true_type {};
97template<
typename L,
typename R, std::
size_t Dim>
100 has_antiderivative_v<L, Dim> &&
101 (is_const_expr_v<R> || is_zero_v<R> || is_one_v<R>) &&
102 !is_const_expr_v<L> && !is_zero_v<L> && !is_one_v<L>
103 >> : std::true_type {};
106template<
typename E, std::
size_t Dim>
108 : std::bool_constant<has_antiderivative_v<E, Dim>> {};
115template<std::
size_t Dim,
typename E>
119template<std::
size_t Dim,
typename E>
121 static_assert(has_antiderivative_v<E, Dim>,
122 "No symbolic antiderivative known for this expression");
131template<std::
size_t Dim,
typename T>
140template<std::
size_t Dim,
typename T>
148template<std::
size_t Dim,
typename T>
156template<std::
size_t Dim,
typename T>
166template<std::
size_t Dim,
typename T,
int N>
170 constexpr int new_exp = N + 1;
171 auto coeff =
Const<T>{T(1) / T(new_exp)};
172 return coeff * pow<new_exp>(
x);
177template<std::
size_t Dim,
typename T>
186template<std::
size_t Dim,
typename T>
195template<std::
size_t Dim,
typename T>
204template<std::
size_t Dim,
typename L,
typename R>
207 auto F = antiderivative<Dim>(expr.
left);
208 auto G = antiderivative<Dim>(expr.
right);
214template<std::
size_t Dim,
typename L,
typename R>
217 auto F = antiderivative<Dim>(expr.
left);
218 auto G = antiderivative<Dim>(expr.
right);
224template<std::
size_t Dim,
typename T,
typename R>
227 auto F = antiderivative<Dim>(expr.right);
228 return expr.left * F;
233template<std::
size_t Dim,
typename L,
typename T>
236 auto F = antiderivative<Dim>(expr.left);
237 return F * expr.right;
242template<std::
size_t Dim,
typename E>
245 auto F = antiderivative<Dim>(expr.
child);
255template<std::
size_t Dim,
typename E,
typename T>
257 static_assert(has_antiderivative_v<E, Dim>,
258 "No symbolic antiderivative known for this expression");
260 auto F = antiderivative<Dim>(expr);
263 std::array<T, Dim + 1> args_b{};
265 T F_b = F.eval(std::span<T const>{args_b});
267 std::array<T, Dim + 1> args_a{};
269 T F_a = F.eval(std::span<T const>{args_a});
Expression layer for composable calculus.
constexpr bool has_antiderivative_v
constexpr auto antiderivative(E expr)
constexpr T definite_integral_symbolic(E expr, T a, T b)
static constexpr auto compute(Binary< Add, L, R > expr)
static constexpr auto compute(Binary< Mul, Const< T >, R > expr)
static constexpr auto compute(Binary< Mul, L, Const< T > > expr)
static constexpr auto compute(Binary< Sub, L, R > expr)
static constexpr auto compute(Const< T > c)
static constexpr auto compute(One< T >)
static constexpr auto compute(Pow< Var< Dim, T >, N >)
static constexpr auto compute(UnaryFunc< CosTag, Var< Dim, T > >)
static constexpr auto compute(UnaryFunc< ExpTag, Var< Dim, T > >)
static constexpr auto compute(UnaryFunc< SinTag, Var< Dim, T > >)
static constexpr auto compute(Unary< Neg, E > expr)
static constexpr auto compute(Var< Dim, T >)
static constexpr auto compute(Zero< T >)