OASIS
Open Algebra Software
Loading...
Searching...
No Matches
Variable.hpp
Go to the documentation of this file.
1//
2// Created by Matthew McCall on 8/15/23.
3//
4
5#ifndef OASIS_VARIABLE_HPP
6#define OASIS_VARIABLE_HPP
7
8#include <stdexcept>
9#include <string>
10
11#include "LeafExpression.hpp"
12
13namespace Oasis {
14
21class Variable : public LeafExpression<Variable> {
22public:
23 Variable() = default;
24 Variable(const Variable& other) = default;
25
26 explicit Variable(std::string name);
27
28 [[nodiscard]] virtual auto Equals(const Expression& other) const -> bool final;
29
32
33
38 [[nodiscard]] auto GetName() const -> std::string;
39
40 [[nodiscard]] auto Differentiate(const Expression& differentiationVariable) const -> std::unique_ptr<Expression> final;
41
42 [[nodiscard]] auto Integrate(const Expression& integrationVariable) const -> std::unique_ptr<Expression> final;
43
44 auto Substitute(const Expression& var, const Expression& val) -> std::unique_ptr<Expression> override;
45
46 auto operator=(const Variable& other) -> Variable& = default;
47
48private:
49 std::string name {};
50};
51
52} // Oasis
53
54#endif // OASIS_VARIABLE_HPP
#define EXPRESSION_CATEGORY(category)
Definition Expression.hpp:192
#define EXPRESSION_TYPE(type)
Definition Expression.hpp:181
An expression.
Definition Expression.hpp:56
A leaf expression.
Definition LeafExpression.hpp:21
An algebraic variable.
Definition Variable.hpp:21
auto Integrate(const Expression &integrationVariable) const -> std::unique_ptr< Expression > final
Attempts to integrate this expression using integration rules.
Definition Variable.cpp:31
auto GetName() const -> std::string
Gets the name of the variable.
Definition Variable.cpp:26
auto Substitute(const Expression &var, const Expression &val) -> std::unique_ptr< Expression > override
Definition Variable.cpp:59
auto Differentiate(const Expression &differentiationVariable) const -> std::unique_ptr< Expression > final
Tries to differentiate this function.
Definition Variable.cpp:71
virtual auto Equals(const Expression &other) const -> bool final
Compares this expression to another expression for equality.
Definition Variable.cpp:21
Variable(const Variable &other)=default
Variable()=default
Definition Add.hpp:11
@ UnExp
Definition Expression.hpp:46