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 Differentiate(const Expression& differentiationVariable) const -> std::unique_ptr<Expression> final;
50
51 [[nodiscard]] auto Integrate(const Expression& integrationVariable) const -> std::unique_ptr<Expression> final;
52
53 auto Substitute(const Expression& var, const Expression& val) -> std::unique_ptr<Expression> override;
54
55 auto operator=(const Variable& other) -> Variable& = default;
56
57private:
58 std::string name {};
59};
60
61} // Oasis
62
63#endif // OASIS_VARIABLE_HPP
#define EXPRESSION_CATEGORY(category)
Definition Expression.hpp:230
#define EXPRESSION_TYPE(type)
Definition Expression.hpp:219
An expression.
Definition Expression.hpp:62
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: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:52