92 template<std::
size_t Dim>
93 [[nodiscard]]
constexpr auto wrt()
const {
94 auto result =
expr.template derivative<Dim>();
99 template<std::
size_t D1, std::
size_t D2>
100 [[nodiscard]]
constexpr auto wrt()
const {
101 return wrt<D1>().template wrt<D2>();
105 template<std::
size_t D1, std::
size_t D2, std::
size_t D3>
106 [[nodiscard]]
constexpr auto wrt()
const {
107 return wrt<D1>().template wrt<D2>().template wrt<D3>();
116 return gradient_impl(std::make_index_sequence<E::arity_v>{});
124 [[nodiscard]]
constexpr E
get() const noexcept {
return expr; }
127 [[nodiscard]]
constexpr value_type eval(std::span<value_type const> args)
const {
128 return expr.eval(args);
132 [[nodiscard]] [[deprecated(
"use eval() instead")]]
139 return expr.to_string();
143 static constexpr std::size_t
arity_v = E::arity_v;
146 template<std::
size_t Dim>
148 return expr.template derivative<Dim>();
152 template<std::size_t... Is>
153 [[nodiscard]]
constexpr auto gradient_impl(std::index_sequence<Is...>)
const {
154 return std::make_tuple(
expr.template derivative<Is>()...);
194 requires (is_expr_node_v<E> && !is_derivative_builder_v<E>)
constexpr bool is_derivative_builder_v
Expression layer for composable calculus.
constexpr auto derivative(E expr)
Fluent builder for computing symbolic derivatives.
constexpr auto wrt() const
Compute ∂³/∂x_D1 ∂x_D2 ∂x_D3 (convenience for third-order mixed partials)
constexpr value_type eval(std::span< value_type const > args) const
Evaluate the derivative expression.
constexpr auto gradient() const
Returns tuple<∂f/∂x₀, ∂f/∂x₁, ..., ∂f/∂x_{n-1}>
std::string to_string() const
String representation.
constexpr auto wrt() const
Compute ∂²/∂x_D1 ∂x_D2 (convenience for second-order mixed partials)
constexpr E get() const noexcept
Allow implicit conversion to the underlying derivative expression.
constexpr auto wrt() const
Compute ∂/∂x_Dim and return a new builder for chaining.
static constexpr std::size_t arity_v
Arity of the derivative expression.
constexpr value_type evaluate(std::span< value_type const > args) const
Deprecated: use eval() instead.
constexpr DerivativeBuilder(E e) noexcept
typename E::value_type value_type
constexpr auto derivative() const
Further differentiation through the member function.