fix(math): fix nested expressions
This commit is contained in:
@@ -18,7 +18,7 @@ struct unary_expression : expression_tag {
|
|||||||
|
|
||||||
constexpr auto shape() const { return expr.shape(); }
|
constexpr auto shape() const { return expr.shape(); }
|
||||||
|
|
||||||
auto eval(std::size_t index) { return Op{}(expr.coeff(index)); }
|
auto coeff(std::size_t index) const { return Op{}(expr.coeff(index)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename L, typename R, typename Op>
|
template <typename L, typename R, typename Op>
|
||||||
@@ -32,7 +32,7 @@ struct binary_expression : expression_tag {
|
|||||||
|
|
||||||
constexpr auto shape() const { return Op::shape(lhs, rhs); }
|
constexpr auto shape() const { return Op::shape(lhs, rhs); }
|
||||||
|
|
||||||
auto eval(std::size_t index) { return Op{}(index, lhs.coeff(index), as_operand(rhs)); }
|
auto coeff(std::size_t index) const { return Op{}(index, lhs.coeff(index), as_operand(rhs)); }
|
||||||
private:
|
private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static decltype(auto) as_operand(T&& value) {
|
static decltype(auto) as_operand(T&& value) {
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t i = 0; i < view().size(); ++i) {
|
for (std::size_t i = 0; i < view().size(); ++i) {
|
||||||
m_items[i] = std::forward<E>(expr).eval(i);
|
m_items[i] = std::forward<E>(expr).coeff(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user