OASIS
Open Algebra Software
Loading...
Searching...
No Matches
Negate.hpp
Go to the documentation of this file.
1//
2// Created by Matthew McCall on 3/29/24.
3//
4
5#ifndef OASIS_NEGATE_HPP
6#define OASIS_NEGATE_HPP
7
8#include "Multiply.hpp"
9#include "UnaryExpression.hpp"
10
11namespace Oasis {
12
13template <typename OperandT = Expression>
14class Negate final : public UnaryExpression<Negate, OperandT> {
15public:
16 Negate() = default;
17 Negate(const Negate& other)
18 : UnaryExpression<Negate, OperandT>(other)
19 {
20 }
21
22 explicit Negate(const OperandT& operand)
23 : UnaryExpression<Negate, OperandT>(operand)
24 {
25 }
26
27 [[nodiscard]] auto Differentiate(const Expression& var) const -> std::unique_ptr<Expression> override
28 {
29 const std::unique_ptr<Expression> operandDerivative = this->GetOperand().Differentiate(var);
30 return Negate<Expression> {
31 *operandDerivative
32 }
33 .Generalize(); // TODO: FIX WITH VISITOR
34 }
35
38};
39
40} // Oasis
41
42#endif // OASIS_NEGATE_HPP
#define EXPRESSION_CATEGORY(category)
Definition Expression.hpp:231
#define EXPRESSION_TYPE(type)
Definition Expression.hpp:220
An expression.
Definition Expression.hpp:63
Definition Negate.hpp:14
Negate(const OperandT &operand)
Definition Negate.hpp:22
auto Differentiate(const Expression &var) const -> std::unique_ptr< Expression > override
Tries to differentiate this function.
Definition Negate.hpp:27
Negate()=default
Negate(const Negate &other)
Definition Negate.hpp:17
Definition UnaryExpression.hpp:14
auto GetOperand() const -> const OperandT &
Definition UnaryExpression.hpp:62
Definition Add.hpp:11
@ UnExp
Definition Expression.hpp:53