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
30class Variable : public LeafExpression<Variable> {
31public:
32 Variable() = default;
33 Variable(const Variable& other) = default;
34
35 explicit Variable(std::string name);
36
37 [[nodiscard]] virtual auto Equals(const Expression& other) const -> bool final;
38
41
42
47 [[nodiscard]] auto GetName() const -> std::string;
48
49 [[nodiscard]] auto Integrate(const Expression& integrationVariable) const -> std::unique_ptr<Expression> final;
50
51 auto Substitute(const Expression& var, const Expression& val) -> std::unique_ptr<Expression> override;
52
53 auto operator=(const Variable& other) -> Variable& = default;
54
55private:
56 std::string name {};
57};
58
59} // Oasis
60
61#endif // OASIS_VARIABLE_HPP
#define EXPRESSION_CATEGORY(category)
Definition Expression.hpp:237
#define EXPRESSION_TYPE(type)
Definition Expression.hpp:226
An expression.
Definition Expression.hpp:63
A leaf expression.
Definition LeafExpression.hpp:21
An algebraic variable.
Definition Variable.hpp:30
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:61
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:53