|
1 | | -// Copyright (c) 2024 Matthias Krippner |
| 1 | +// Copyright (c) 2024-2025 Matthias Krippner |
2 | 2 | // |
3 | 3 | // This software is released under the MIT License. |
4 | 4 | // https://opensource.org/licenses/MIT |
|
9 | 9 | namespace AutoDiff::Basic { |
10 | 10 |
|
11 | 11 | template <typename X, typename Y> |
12 | | -class Difference : public BinaryOperation<Difference<X, Y>, X, Y> { |
| 12 | +class Difference : public Expression<Difference<X, Y>>, |
| 13 | + public BinaryOperation<X, Y> { |
13 | 14 | public: |
14 | | - using Base = BinaryOperation<Difference<X, Y>, X, Y>; |
15 | | - using Base::Base; |
| 15 | + using Op = BinaryOperation<X, Y>; |
| 16 | + using Op::Op; |
16 | 17 |
|
17 | 18 | [[nodiscard]] auto _valueImpl() -> decltype(auto) |
18 | 19 | { |
19 | | - return Base::xValue() - Base::yValue(); |
| 20 | + return Op::xValue() - Op::yValue(); |
20 | 21 | } |
21 | 22 |
|
22 | 23 | [[nodiscard]] auto _pushForwardImpl() -> decltype(auto) |
23 | 24 | { |
24 | | - if constexpr (!Base::hasOperandX) { |
25 | | - return -Base::yPushForward(); |
26 | | - } else if constexpr (!Base::hasOperandY) { |
27 | | - return Base::xPushForward(); |
| 25 | + if constexpr (!Op::hasOperandX) { |
| 26 | + return -Op::yPushForward(); |
| 27 | + } else if constexpr (!Op::hasOperandY) { |
| 28 | + return Op::xPushForward(); |
28 | 29 | } else { |
29 | | - return Base::xPushForward() - Base::yPushForward(); |
| 30 | + return Op::xPushForward() - Op::yPushForward(); |
30 | 31 | } |
31 | 32 | } |
32 | 33 |
|
33 | 34 | template <typename Derivative> |
34 | 35 | void _pullBackImpl(Derivative const& derivative) |
35 | 36 | { |
36 | | - if constexpr (Base::hasOperandX) { |
37 | | - Base::xPullBack(derivative); |
| 37 | + if constexpr (Op::hasOperandX) { |
| 38 | + Op::xPullBack(derivative); |
38 | 39 | } |
39 | | - if constexpr (Base::hasOperandY) { |
40 | | - Base::yPullBack(-derivative); |
| 40 | + if constexpr (Op::hasOperandY) { |
| 41 | + Op::yPullBack(-derivative); |
41 | 42 | } |
42 | 43 | } |
43 | 44 | }; |
|
0 commit comments