11template<
typename E,
int N>
struct Pow;
13template<
typename E>
inline constexpr bool is_pow_v =
false;
14template<
typename E,
int N>
inline constexpr bool is_pow_v<Pow<E, N>> =
true;
21template<
typename E,
int N>
inline constexpr int pow_exponent_v<Pow<E, N>> = N;
24template<
typename E,
int N>
28 static constexpr std::size_t
arity_v = E::arity_v;
33 constexpr explicit Pow(E b) noexcept :
base{b} {}
35 [[nodiscard]]
constexpr value_type eval(std::span<value_type const> args)
const {
36 if constexpr (N == 0) {
38 }
else if constexpr (N == 1) {
39 return base.eval(args);
40 }
else if constexpr (N == 2) {
41 auto v =
base.eval(args);
43 }
else if constexpr (N == 3) {
44 auto v =
base.eval(args);
47 return std::pow(
base.eval(args), N);
51 [[nodiscard]] [[deprecated(
"use eval() instead")]]
57 template<std::
size_t Dim>
59 auto du =
base.template derivative<Dim>();
61 if constexpr (N == 0) {
63 }
else if constexpr (N == 1) {
65 }
else if constexpr (N == 2) {
73 return "(^ " +
base.to_string() +
" " + std::to_string(N) +
")";
78template<
int N,
typename E>
79 requires is_expr_node_v<E>
80[[nodiscard]]
constexpr auto pow(E e) {
81 if constexpr (N == 0) {
83 }
else if constexpr (N == 1) {
91 requires is_expr_node_v<E>
92[[nodiscard]]
constexpr auto square(E e) {
97 requires is_expr_node_v<E>
98[[nodiscard]]
constexpr auto cube(E e) {
Expression layer for composable calculus.
constexpr int pow_exponent_v
typename pow_base< E >::type pow_base_t
constexpr auto square(E e)
constexpr auto pow(L base, R exponent)
typename E::value_type value_type
constexpr auto derivative() const
constexpr Pow(E b) noexcept
static constexpr std::size_t arity_v
constexpr value_type eval(std::span< value_type const > args) const
static constexpr int exponent
constexpr value_type evaluate(std::span< value_type const > args) const
std::string to_string() const