diff --git a/.gitignore b/.gitignore index 5c87389d..01ec883f 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,8 @@ latex # *.iml # *.ipr + +build # CMake cmake-build-*/ @@ -100,7 +102,8 @@ fabric.properties .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* diff --git a/HowToUseOASIS.txt b/HowToUseOASIS.txt new file mode 100644 index 00000000..f629e8ed --- /dev/null +++ b/HowToUseOASIS.txt @@ -0,0 +1,38 @@ +Calculate Derivative: + +To calculate the derivative of an expression using OASIS, use the following input + +dd(EXPRESSION_YOU_WANT_TO_DIFFERENTIATE, VARIABLE_WITH_RESPECT_TO_DIFFERENTIATE) + +examples: + +dd(2x, x) -> 2 +dd(4a^2, a) -> 8a +dd(2x^y, x) -> 0 + +Calculate Integral: + +To calculate the Integral of an expression using OASIS, use the following input + +in(EXPRESSION_YOU_WANT_TO_INTEGRATE, VARIABLE_WITH_RESPECT_TO_INTEGRATE) + +examples: +in(2x, x) -> x^2 + C +in(4a^2, a) -> (4/3)a^3 + C +in(2x^y, x) -> SHOULD BE (2x^(y+1))/(y+1), as of right now returns incorrect result + +Build Logarithm: + +To build a logarithmic expression, use the following input + +log(EXPRESSION_TO_USE_AS_BASE, EXPRESSION_TO_USE_AS_ARGUMENT) + +examples: + +log(2, 3) -> 1.585 +log(10, x) -> log10(x) +log(x, y) -> logx(y) + + + + diff --git a/bindings/js/src/bindings.cpp b/bindings/js/src/bindings.cpp index 93cd2c4e..f46db24d 100644 --- a/bindings/js/src/bindings.cpp +++ b/bindings/js/src/bindings.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 3/10/25. -// +/** + * Created by Matthew McCall on 3/10/25. + */ #include #include "Oasis/Expression.hpp" diff --git a/cli/main.cpp b/cli/main.cpp index 8a5dd399..1ccd4072 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 2/19/25. -// +/** + * Created by Matthew McCall on 2/19/25. + */ #include #include @@ -20,7 +20,9 @@ auto operator|(const std::string& str, FnT fn) -> boost::callable_traits::return return fn(str); } -// https://en.cppreference.com/w/cpp/string/byte/isspace#Notes +/** + * https://en.cppreference.com/w/cpp/string/byte/isspace#Notes + */ bool safe_isspace(const unsigned char ch) { return std::isspace(ch); } auto trim_whitespace(const std::string& str) -> std::string @@ -33,7 +35,9 @@ auto trim_whitespace(const std::string& str) -> std::string | std::ranges::to(); } -// Calling Oasis::FromInFix passed as template fails because defaulted parameters aren't represented in the type, so a wrapper is needed +/** + * Calling Oasis::FromInFix passed as template fails because defaulted parameters aren't represented in the type, so a wrapper is needed + */ auto Parse(const std::string& in) -> Oasis::FromInFixResult { return Oasis::FromInFix(in); }; int main(int argc, char** argv) @@ -54,7 +58,9 @@ int main(int argc, char** argv) if (input == "exit") break; - // Calling Oasis::FromInFix passed as template fails because defaulted parameters aren't represented in the type, so a wrapper is needed + /** + * Calling Oasis::FromInFix passed as template fails because defaulted parameters aren't represented in the type, so a wrapper is needed + */ auto result = (input | Oasis::PreProcessInFix | Parse) .transform([](const std::unique_ptr& expr) -> std::unique_ptr { return expr->Simplify(); diff --git a/include/Oasis/Add.hpp b/include/Oasis/Add.hpp index b61e6d7f..a1f10afd 100644 --- a/include/Oasis/Add.hpp +++ b/include/Oasis/Add.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 7/2/23. -// +/** + * Created by Matthew McCall on 7/2/23. + */ #ifndef OASIS_ADD_HPP #define OASIS_ADD_HPP diff --git a/include/Oasis/BinaryExpression.hpp b/include/Oasis/BinaryExpression.hpp index 30af5a1b..3d65d8f5 100644 --- a/include/Oasis/BinaryExpression.hpp +++ b/include/Oasis/BinaryExpression.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 7/2/23. -// +/** + * Created by Matthew McCall on 7/2/23. + */ #ifndef OASIS_BINARYEXPRESSION_HPP #define OASIS_BINARYEXPRESSION_HPP diff --git a/include/Oasis/BoundedBinaryExpression.hpp b/include/Oasis/BoundedBinaryExpression.hpp index 8b8c4391..f714d82c 100644 --- a/include/Oasis/BoundedBinaryExpression.hpp +++ b/include/Oasis/BoundedBinaryExpression.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 5/2/24. -// +/** + * Created by Matthew McCall on 5/2/24. + */ #ifndef OASIS_BOUNDEDBINARYEXPRESSION_HPP #define OASIS_BOUNDEDBINARYEXPRESSION_HPP diff --git a/include/Oasis/BoundedExpression.hpp b/include/Oasis/BoundedExpression.hpp index 32511802..a61d9810 100644 --- a/include/Oasis/BoundedExpression.hpp +++ b/include/Oasis/BoundedExpression.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/30/24. -// +/** + * Created by Matthew McCall on 4/30/24. + */ #ifndef OAISIS_BOUNDEDEXPRESSION_HPP #define OAISIS_BOUNDEDEXPRESSION_HPP diff --git a/include/Oasis/BoundedUnaryExpression.hpp b/include/Oasis/BoundedUnaryExpression.hpp index 77021d03..6b72df55 100644 --- a/include/Oasis/BoundedUnaryExpression.hpp +++ b/include/Oasis/BoundedUnaryExpression.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/30/24. -// +/** + * Created by Matthew McCall on 4/30/24. + */ #ifndef OASIS_BOUNDEDUNARYEXPRESSION_HPP #define OASIS_BOUNDEDUNARYEXPRESSION_HPP @@ -46,7 +46,9 @@ class BoundedUnaryExpression : public BoundedExpression std::unique_ptr final { - // TODO: Actually implement + /** + * TODO: Actually implement + */ return std::make_unique(*static_cast(this)); } @@ -58,13 +60,14 @@ class BoundedUnaryExpression : public BoundedExpression bool final { - // TODO: Reimplement now that Specialize is gone - // if (const auto otherExpression = DerivedSpecialized::Specialize(other); otherExpression != nullptr) { - // return HasOperand() == otherExpression->HasOperand() - // && this->HasLowerBound() == otherExpression->HasLowerBound() - // && this->HasUpperBound() == otherExpression->HasUpperBound(); - // } - + /** + * TODO: Reimplement now that Specialize is gone + * if (const auto otherExpression = DerivedSpecialized::Specialize(other); otherExpression != nullptr) { + * return HasOperand() == otherExpression->HasOperand() + * && this->HasLowerBound() == otherExpression->HasLowerBound() + * && this->HasUpperBound() == otherExpression->HasUpperBound(); + * } + */ return false; } diff --git a/include/Oasis/Concepts.hpp b/include/Oasis/Concepts.hpp index 94500df4..ceff7569 100644 --- a/include/Oasis/Concepts.hpp +++ b/include/Oasis/Concepts.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 10/20/24. -// +/** + * Created by Matthew McCall on 10/20/24. + */ #ifndef OASIS_CONCEPTS_HPP #define OASIS_CONCEPTS_HPP diff --git a/include/Oasis/DefiniteIntegral.hpp b/include/Oasis/DefiniteIntegral.hpp index 85ec93f7..182df976 100644 --- a/include/Oasis/DefiniteIntegral.hpp +++ b/include/Oasis/DefiniteIntegral.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/30/24. -// +/** + * Created by Matthew McCall on 4/30/24. + */ #ifndef DEFINITEINTEGRAL_HPP #define DEFINITEINTEGRAL_HPP diff --git a/include/Oasis/Derivative.hpp b/include/Oasis/Derivative.hpp index bab38b2c..2e3bd9b3 100644 --- a/include/Oasis/Derivative.hpp +++ b/include/Oasis/Derivative.hpp @@ -1,6 +1,6 @@ -// -// Created by bachia on 4/12/2024. -// +/** + * Created by bachia on 4/12/2024. + */ #ifndef OASIS_DERIVATIVE_HPP #define OASIS_DERIVATIVE_HPP diff --git a/include/Oasis/Divide.hpp b/include/Oasis/Divide.hpp index 19a412ab..5307de66 100644 --- a/include/Oasis/Divide.hpp +++ b/include/Oasis/Divide.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/10/23. -// +/** + * Created by Matthew McCall on 8/10/23. + */ #ifndef OASIS_DIVIDE_HPP #define OASIS_DIVIDE_HPP diff --git a/include/Oasis/EulerNumber.hpp b/include/Oasis/EulerNumber.hpp index f019b012..0bd1d813 100644 --- a/include/Oasis/EulerNumber.hpp +++ b/include/Oasis/EulerNumber.hpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 6/25/24. -// +/** + * Created by Andrew Nazareth on 6/25/24. + */ #ifndef OASIS_EULERNUMBER_HPP #define OASIS_EULERNUMBER_HPP diff --git a/include/Oasis/Exponent.hpp b/include/Oasis/Exponent.hpp index bf9a3d1c..9a4b7005 100644 --- a/include/Oasis/Exponent.hpp +++ b/include/Oasis/Exponent.hpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 9/19/23. -// +/** + * Created by Andrew Nazareth on 9/19/23. + */ #ifndef OASIS_EXPONENT_HPP #define OASIS_EXPONENT_HPP diff --git a/include/Oasis/Imaginary.hpp b/include/Oasis/Imaginary.hpp index 4d7f5fe4..60251600 100644 --- a/include/Oasis/Imaginary.hpp +++ b/include/Oasis/Imaginary.hpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 10/10/23. -// +/** + * Created by Andrew Nazareth on 10/10/23. + */ #ifndef OASIS_IMAGINARY_HPP #define OASIS_IMAGINARY_HPP diff --git a/include/Oasis/Integral.hpp b/include/Oasis/Integral.hpp index 5241648a..9207bfca 100644 --- a/include/Oasis/Integral.hpp +++ b/include/Oasis/Integral.hpp @@ -1,6 +1,6 @@ -// -// Created by Levy Lin on 2/09/2024. -// +/** + * Created by Levy Lin on 2/09/2024. + */ #ifndef OASIS_INTEGRATE_HPP #define OASIS_INTEGRATE_HPP diff --git a/include/Oasis/LeafExpression.hpp b/include/Oasis/LeafExpression.hpp index 21728c15..200f9fab 100644 --- a/include/Oasis/LeafExpression.hpp +++ b/include/Oasis/LeafExpression.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 7/2/23. -// +/** + * Created by Matthew McCall on 7/2/23. + */ #ifndef OASIS_LEAFEXPRESSION_HPP #define OASIS_LEAFEXPRESSION_HPP diff --git a/include/Oasis/Linear.hpp b/include/Oasis/Linear.hpp index 9d19b704..e50693f6 100644 --- a/include/Oasis/Linear.hpp +++ b/include/Oasis/Linear.hpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 2/16/24. -// +/** + * Created by Andrew Nazareth on 2/16/24. + */ #ifndef OASIS_LINEAR_HPP #define OASIS_LINEAR_HPP diff --git a/include/Oasis/Log.hpp b/include/Oasis/Log.hpp index 7c1a1f7d..db406ec5 100644 --- a/include/Oasis/Log.hpp +++ b/include/Oasis/Log.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 10/6/23. -// +/** + * Created by Matthew McCall on 10/6/23. + */ #ifndef OASIS_LOG_HPP #define OASIS_LOG_HPP diff --git a/include/Oasis/Magnitude.hpp b/include/Oasis/Magnitude.hpp index df542a7d..d98de288 100644 --- a/include/Oasis/Magnitude.hpp +++ b/include/Oasis/Magnitude.hpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 6/28/24. -// +/** + * Created by Andrew Nazareth on 6/28/24. + */ #ifndef OASIS_MAGNITUDE_HPP #define OASIS_MAGNITUDE_HPP @@ -78,8 +78,9 @@ class Magnitude final : public UnaryExpression { [[nodiscard]] auto Differentiate(const Expression& var) const -> std::unique_ptr override { - // TODO: Implement - + /** + * TODO: Implement + */ const std::unique_ptr operandDerivative = this->GetOperand().Differentiate(var); return Magnitude { *operandDerivative @@ -89,7 +90,9 @@ class Magnitude final : public UnaryExpression { [[nodiscard]] auto Integrate(const Expression& integrationVar) const -> std::unique_ptr override { - // TODO: Implement + /** + * TODO: Implement + */ const std::unique_ptr operandDerivative = this->GetOperand().Integrate(integrationVar); return Magnitude { *operandDerivative diff --git a/include/Oasis/MatchCast.hpp b/include/Oasis/MatchCast.hpp index b59e78b5..02cf4278 100644 --- a/include/Oasis/MatchCast.hpp +++ b/include/Oasis/MatchCast.hpp @@ -1,18 +1,19 @@ -// -// Created by Matthew McCall on 10/22/24. -// +/** + * Created by Matthew McCall on 10/22/24. + */ -// Hear ye, valiant coder! Within this hallowed script of Oasis' MatchCast, -// lies an unfathomable confluence of templated magic, scarcely understood only by even the -// most exalted compilers and the divine overseers. This arcane construct, -// when tampered with, may envelop thee in utter confusion, leaving thee solitary in thy pursuits. -// Of course, this sagely advice surely does not emanate from a mere language model. Rather, -// it is the timeless counsel of battle-hardened developers who have faced such arcane complexity. -// Should regret cloud thy mind and thou desires to undo thine alterations, perform the following -// sacred rite to restore the code to its pristine state: -// -// git checkout -- -// +/** + * Hear ye, valiant coder! Within this hallowed script of Oasis' MatchCast, + * lies an unfathomable confluence of templated magic, scarcely understood only by even the + * most exalted compilers and the divine overseers. This arcane construct, + * when tampered with, may envelop thee in utter confusion, leaving thee solitary in thy pursuits. + * Of course, this sagely advice surely does not emanate from a mere language model. Rather, + * it is the timeless counsel of battle-hardened developers who have faced such arcane complexity. + * Should regret cloud thy mind and thou desires to undo thine alterations, perform the following + * sacred rite to restore the code to its pristine state: + * + * git checkout -- + */ #ifndef OASIS_MATCHCAST_HPP #define OASIS_MATCHCAST_HPP diff --git a/include/Oasis/Matrix.hpp b/include/Oasis/Matrix.hpp index ff931ea2..86eca4ee 100644 --- a/include/Oasis/Matrix.hpp +++ b/include/Oasis/Matrix.hpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 5/24/24. -// +/** + * Created by Andrew Nazareth on 5/24/24. + */ #ifndef OASIS_MATRIX_HPP #define OASIS_MATRIX_HPP diff --git a/include/Oasis/Multiply.hpp b/include/Oasis/Multiply.hpp index 14546868..5b8f85a1 100644 --- a/include/Oasis/Multiply.hpp +++ b/include/Oasis/Multiply.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/10/23. -// +/** + * Created by Matthew McCall on 8/10/23. + */ #ifndef OASIS_MULTIPLY_HPP #define OASIS_MULTIPLY_HPP diff --git a/include/Oasis/Negate.hpp b/include/Oasis/Negate.hpp index e9c715ae..aaf63703 100644 --- a/include/Oasis/Negate.hpp +++ b/include/Oasis/Negate.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 3/29/24. -// +/** + * Created by Matthew McCall on 3/29/24. + */ #ifndef OASIS_NEGATE_HPP #define OASIS_NEGATE_HPP diff --git a/include/Oasis/Pi.hpp b/include/Oasis/Pi.hpp index 3003b221..4031a69d 100644 --- a/include/Oasis/Pi.hpp +++ b/include/Oasis/Pi.hpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 6/25/24. -// +/** + * Created by Andrew Nazareth on 6/25/24. + */ #ifndef OASIS_PI_HPP #define OASIS_PI_HPP diff --git a/include/Oasis/Real.hpp b/include/Oasis/Real.hpp index be8e3e36..ea7a181a 100644 --- a/include/Oasis/Real.hpp +++ b/include/Oasis/Real.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 7/2/23. -// +/** + * Created by Matthew McCall on 7/2/23. + */ #ifndef OASIS_REAL_HPP #define OASIS_REAL_HPP diff --git a/include/Oasis/RecursiveCast.hpp b/include/Oasis/RecursiveCast.hpp index da8dd3f0..92eded3c 100644 --- a/include/Oasis/RecursiveCast.hpp +++ b/include/Oasis/RecursiveCast.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 10/14/24. -// +/** + * Created by Matthew McCall on 10/14/24. + */ #ifndef OASIS_RECURSIVECAST_HPP #define OASIS_RECURSIVECAST_HPP diff --git a/include/Oasis/Subtract.hpp b/include/Oasis/Subtract.hpp index c869dc51..54d31c57 100644 --- a/include/Oasis/Subtract.hpp +++ b/include/Oasis/Subtract.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/10/23. -// +/** + * Created by Matthew McCall on 8/10/23. + */ #ifndef OASIS_SUBTRACT_HPP #define OASIS_SUBTRACT_HPP diff --git a/include/Oasis/Summation.hpp b/include/Oasis/Summation.hpp index 6778bbb8..aa1019b2 100644 --- a/include/Oasis/Summation.hpp +++ b/include/Oasis/Summation.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 5/2/24. -// +/** + * Created by Matthew McCall on 5/2/24. + */ #ifndef OASIS_SUMMATION_HPP #define OASIS_SUMMATION_HPP diff --git a/include/Oasis/UnaryExpression.hpp b/include/Oasis/UnaryExpression.hpp index 5f5395ca..b66fc0ff 100644 --- a/include/Oasis/UnaryExpression.hpp +++ b/include/Oasis/UnaryExpression.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 3/29/24. -// +/** + * Created by Matthew McCall on 3/29/24. + */ #ifndef UNARYEXPRESSION_HPP #define UNARYEXPRESSION_HPP @@ -43,7 +43,9 @@ class UnaryExpression : public Expression { return false; } - // generalize + /** + * generalize + */ const auto otherGeneralized = other.Generalize(); const auto& otherUnaryGeneralized = dynamic_cast(*otherGeneralized); diff --git a/include/Oasis/Undefined.hpp b/include/Oasis/Undefined.hpp index 91993db4..ec7e3c33 100644 --- a/include/Oasis/Undefined.hpp +++ b/include/Oasis/Undefined.hpp @@ -1,6 +1,6 @@ -// -// Created by Blake Kessler on 10/13/23. -// +/** + * Created by Blake Kessler on 10/13/23. + */ #ifndef OASIS_UNDEFINED_HPP #define OASIS_UNDEFINED_HPP diff --git a/include/Oasis/Variable.hpp b/include/Oasis/Variable.hpp index 580268ae..c54ee386 100644 --- a/include/Oasis/Variable.hpp +++ b/include/Oasis/Variable.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/15/23. -// +/** + * Created by Matthew McCall on 8/15/23. + */ #ifndef OASIS_VARIABLE_HPP #define OASIS_VARIABLE_HPP diff --git a/include/Oasis/Visit.hpp b/include/Oasis/Visit.hpp index 12fa687d..a2b3bdb8 100644 --- a/include/Oasis/Visit.hpp +++ b/include/Oasis/Visit.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/28/24. -// +/** + * Created by Matthew McCall on 4/28/24. + */ #ifndef OASIS_SERIALIZATION_HPP #define OASIS_SERIALIZATION_HPP diff --git a/io/src/FromString.cpp b/io/src/FromString.cpp index b880f99d..e4800d5d 100644 --- a/io/src/FromString.cpp +++ b/io/src/FromString.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/21/24. -// +/** + * Created by Matthew McCall on 4/21/24. + */ #include #include #include @@ -256,7 +256,9 @@ auto PreProcessInFix(const std::string& str) -> std::string auto FromInFix(const std::string& str, ParseImaginaryOption option) -> std::expected, std::string> { - // Based off Dijkstra's Shunting Yard + /** + * Based off Dijkstra's Shunting Yard + */ std::stack> st; std::stack> ops; @@ -265,13 +267,17 @@ auto FromInFix(const std::string& str, ParseImaginaryOption option) -> std::expe std::stringstream ss { str }; while (ss >> token) { - // Operand + /** + * Operand + */ if (auto newNumber = is_number(token); newNumber) { st.push(std::make_unique(newNumber.value())); } else if (auto newFunc = is_function(token); newFunc) { ops.emplace(newFunc.value()); } - // Operator + /** + * Operator + */ else if (auto newOp = is_operator(token); newOp) { while (!ops.empty() && prec(ops.top()) >= prec(newOp.value())) { auto processOpResult = processOp(ops, st); @@ -283,9 +289,13 @@ auto FromInFix(const std::string& str, ParseImaginaryOption option) -> std::expe } else if (token == "(") { ops.emplace(OpenParens()); } - // ',' + /** + * ',' + */ else if (token == ",") { - // function_active = true; + /** + * function_active = true; + */ while (!ops.empty() && !std::holds_alternative(ops.top())) { auto processOpResult = processOp(ops, st); if (!processOpResult) @@ -293,7 +303,9 @@ auto FromInFix(const std::string& str, ParseImaginaryOption option) -> std::expe st.emplace(std::move(processOpResult.value())); } } - // ')' + /** + * ')' + */ else if (token == ")") { while (!ops.empty() && !std::holds_alternative(ops.top())) { auto processOpResult = processOp(ops, st); @@ -320,7 +332,9 @@ auto FromInFix(const std::string& str, ParseImaginaryOption option) -> std::expe } } - // Process remaining ops + /** + * Process remaining ops + */ while (!ops.empty()) { auto processOpResult = processOp(ops, st); if (!processOpResult) diff --git a/io/src/InFixSerializer.cpp b/io/src/InFixSerializer.cpp index 181fb6a4..b1673be0 100644 --- a/io/src/InFixSerializer.cpp +++ b/io/src/InFixSerializer.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/28/24. -// +/** + * Created by Matthew McCall on 4/28/24. + */ #include diff --git a/io/src/MathMLSerializer.cpp b/io/src/MathMLSerializer.cpp index 5e030707..8a94ffaf 100644 --- a/io/src/MathMLSerializer.cpp +++ b/io/src/MathMLSerializer.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/28/24. -// +/** + * Created by Matthew McCall on 4/28/24. + */ #include @@ -114,13 +114,17 @@ auto MathMLSerializer::TypedVisit(const Add<>& add) -> RetT const auto opElement = op->Accept(*this).value(); mrow->InsertEndChild(opElement); - // add + mo + /** + * add + mo + */ tinyxml2::XMLElement* mo = doc.NewElement("mo"); mo->SetText("+"); mrow->InsertEndChild(mo); } - // remove last mo + /** + * remove last mo + */ mrow->DeleteChild(mrow->LastChild()); return mrow; } @@ -128,7 +132,9 @@ auto MathMLSerializer::TypedVisit(const Add<>& add) -> RetT auto MathMLSerializer::TypedVisit(const Subtract<>& subtract) -> RetT { return GetOpsAsMathMLPair(subtract).transform([this, subtract](const auto& ops) { - // mrow + /** + * mrow + */ tinyxml2::XMLElement* const mrow = doc.NewElement("mrow"); auto [minuendElement, subtrahendElement] = ops; @@ -144,7 +150,9 @@ auto MathMLSerializer::TypedVisit(const Subtract<>& subtract) -> RetT } } - // mo + /** + * mo + */ tinyxml2::XMLElement* const mo = doc.NewElement("mo"); mo->SetText("-"); mrow->InsertEndChild(mo); @@ -312,15 +320,21 @@ auto MathMLSerializer::TypedVisit(const Log<>& log) -> RetT auto MathMLSerializer::TypedVisit(const Negate& negate) -> RetT { - // mrow + /** + * mrow + */ tinyxml2::XMLElement* const mrow = doc.NewElement("mrow"); - // mo + /** + * mo + */ tinyxml2::XMLElement* const mo = doc.NewElement("mo"); mo->SetText("-"); mrow->InsertEndChild(mo); - // ( + /** + * ( + */ tinyxml2::XMLElement* const leftParen = doc.NewElement("mo"); leftParen->SetText("("); mrow->InsertEndChild(leftParen); @@ -328,7 +342,9 @@ auto MathMLSerializer::TypedVisit(const Negate& negate) -> RetT const auto operandElement = negate.GetOperand().Accept(*this).value(); mrow->InsertEndChild(operandElement); - // ) + /** + * ) + */ tinyxml2::XMLElement* const rightParen = doc.NewElement("mo"); rightParen->SetText(")"); mrow->InsertEndChild(rightParen); @@ -360,11 +376,15 @@ auto MathMLSerializer::TypedVisit(const Derivative<>& derivative) -> RetT mrow->InsertEndChild(mfrac); - // ( + /** + * ( + */ tinyxml2::XMLElement* const leftParen = doc.NewElement("mo"); leftParen->SetText("("); - // ) + /** + * ) + */ tinyxml2::XMLElement* const rightParen = doc.NewElement("mo"); rightParen->SetText(")"); @@ -381,7 +401,9 @@ auto MathMLSerializer::TypedVisit(const Integral<>& integral) -> RetT return GetOpsAsMathMLPair(integral).transform([this, integral](const auto& ops) { tinyxml2::XMLElement* mrow = doc.NewElement("mrow"); - // Integral symbol + /** + * Integral symbol + */ tinyxml2::XMLElement* inte = doc.NewElement("mo"); inte->SetText(u8"\u222B"); @@ -390,7 +412,9 @@ auto MathMLSerializer::TypedVisit(const Integral<>& integral) -> RetT auto [expElement, varElement] = ops; - // d variable + /** + * d variable + */ tinyxml2::XMLElement* dVar = doc.NewElement("mrow"); dVar->InsertEndChild(dNode); dVar->InsertEndChild(varElement); @@ -410,10 +434,14 @@ tinyxml2::XMLDocument& MathMLSerializer::GetDocument() const auto MathMLSerializer::TypedVisit(const Magnitude& magnitude) -> RetT { - // mrow + /** + * mrow + */ tinyxml2::XMLElement* const mrow = doc.NewElement("mrow"); - // ( + /** + * ( + */ tinyxml2::XMLElement* const leftParen = doc.NewElement("mo"); leftParen->SetText("|"); mrow->InsertEndChild(leftParen); @@ -421,7 +449,9 @@ auto MathMLSerializer::TypedVisit(const Magnitude& magnitude) -> Ret const auto operandElement = magnitude.GetOperand().Accept(*this).value(); mrow->InsertEndChild(operandElement); - // ) + /** + * ) + */ tinyxml2::XMLElement* const rightParen = doc.NewElement("mo"); rightParen->SetText("|"); mrow->InsertEndChild(rightParen); diff --git a/io/src/TeXSerializer.cpp b/io/src/TeXSerializer.cpp index 4d837d28..9bd976b7 100644 --- a/io/src/TeXSerializer.cpp +++ b/io/src/TeXSerializer.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 9/27/24. -// +/** + * Created by Andrew Nazareth on 9/27/24. + */ #include diff --git a/io/tests/InFixTests.cpp b/io/tests/InFixTests.cpp index 7506551e..5fc94030 100644 --- a/io/tests/InFixTests.cpp +++ b/io/tests/InFixTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/21/24. -// +/** + * Created by Matthew McCall on 4/21/24. + */ #include "catch2/catch_test_macros.hpp" diff --git a/io/tests/TeXTests.cpp b/io/tests/TeXTests.cpp index 1588bd6b..d5eb1eee 100644 --- a/io/tests/TeXTests.cpp +++ b/io/tests/TeXTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 9/30/24. -// +/** + * Created by Andrew Nazareth on 9/30/24. + */ #include "catch2/catch_test_macros.hpp" diff --git a/src/Add.cpp b/src/Add.cpp index 3b1f9a5a..a3d458d5 100644 --- a/src/Add.cpp +++ b/src/Add.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 7/2/23. -// +/** + * Created by Matthew McCall on 7/2/23. + */ #include #include "Oasis/Add.hpp" @@ -17,6 +17,9 @@ namespace Oasis { +/** + * Simplifies addition expression + */ auto Add::Simplify() const -> std::unique_ptr { auto simplifiedAugend = mostSigOp ? mostSigOp->Simplify() : nullptr; @@ -49,7 +52,9 @@ auto Add::Simplify() const -> std::unique_ptr } } - // matrix + matrix + /** + * matrix + matrix + */ if (auto matrixCase = RecursiveCast>(simplifiedAdd); matrixCase != nullptr) { const Oasis::IExpression auto& leftTerm = matrixCase->GetMostSigOp(); const Oasis::IExpression auto& rightTerm = matrixCase->GetLeastSigOp(); @@ -61,7 +66,9 @@ auto Add::Simplify() const -> std::unique_ptr } } - // log(a) + log(b) = log(ab) + /** + * log(a) + log(b) = log(ab) + */ if (auto logCase = RecursiveCast, Log>>(simplifiedAdd); logCase != nullptr) { if (logCase->GetMostSigOp().GetMostSigOp().Equals(logCase->GetLeastSigOp().GetMostSigOp())) { const IExpression auto& base = logCase->GetMostSigOp().GetMostSigOp(); @@ -70,21 +77,26 @@ auto Add::Simplify() const -> std::unique_ptr } } - // x + x = 2x + /** + * x + x = 2x + */ if (simplifiedAugend->Equals(*simplifiedAddend)) { return Multiply { Real { 2.0 }, *simplifiedAugend }.Simplify(); } - // 2x + x = 3x + /** + * 2x + x = 3x + */ if (const auto likeTermsCase2 = RecursiveCast, Expression>>(simplifiedAdd); likeTermsCase2 != nullptr) { if (likeTermsCase2->GetMostSigOp().GetLeastSigOp().Equals(likeTermsCase2->GetLeastSigOp())) { const Real& coeffiecent = likeTermsCase2->GetMostSigOp().GetMostSigOp(); return std::make_unique>(Real { coeffiecent.GetValue() + 1 }, likeTermsCase2->GetMostSigOp().GetLeastSigOp()); } } - - // simplifies expressions and combines like terms - // ex: 1 + 2x + 3 + 5x = 4 + 7x (or 7x + 4) + /** + * simplifies expressions and combines like terms + * ex: 1 + 2x + 3 + 5x = 4 + 7x (or 7x + 4) + */ std::vector> adds; std::vector> vals; simplifiedAdd.Flatten(adds); @@ -99,12 +111,16 @@ auto Add::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(addend->Generalize()); } continue; } - // single i + /** + * single i + */ if (auto img = RecursiveCast(*addend); img != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>(*vals[i]); valI != nullptr) { @@ -113,12 +129,16 @@ auto Add::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(Multiply { Real { 1.0 }, Imaginary {} }.Generalize()); } continue; } - // n*i + /** + * n*i + */ if (auto img = RecursiveCast>(*addend); img != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>(*vals[i]); valI != nullptr) { @@ -127,12 +147,16 @@ auto Add::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(img->Generalize()); } continue; } - // single variable + /** + * single variable + */ if (auto var = RecursiveCast(*addend); var != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>(*vals[i]); valI != nullptr) { @@ -144,16 +168,22 @@ auto Add::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(Multiply { Real { 1.0 }, *var }.Generalize()); } continue; } - // n*variable + /** + * n*variable + */ if (auto var = RecursiveCast>(*addend); var != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>(*vals[i]); valI != nullptr) { - // if (auto zeroCase = RecursiveCast>(*valI); zeroCase != nullptr) {} + /** + * if (auto zeroCase = RecursiveCast>(*valI); zeroCase != nullptr) {} + */ if (valI->GetLeastSigOp().GetName() == var->GetLeastSigOp().GetName()) { vals[i] = Multiply { *(Add { valI->GetMostSigOp(), var->GetMostSigOp() }.Simplify()), valI->GetLeastSigOp() }.Generalize(); break; @@ -162,12 +192,16 @@ auto Add::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(var->Generalize()); } continue; } - // single exponent + /** + * single exponent + */ if (auto exp = RecursiveCast>(*addend); exp != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>>(*vals[i]); valI != nullptr) { @@ -179,12 +213,16 @@ auto Add::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(Multiply { Real { 1.0 }, *exp }.Generalize()); } continue; } - // n*exponent + /** + * n*exponent + */ if (auto exp = RecursiveCast>>(*addend); exp != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>>(*vals[i]); valI != nullptr) { @@ -196,14 +234,17 @@ auto Add::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(exp->Generalize()); } continue; } } - // rebuild equation after simplification. - + /** + * rebuild equation after simplification. + */ for (auto& val : vals) { if (auto mul = RecursiveCast>(*val); mul != nullptr) { if (mul->GetMostSigOp().GetValue() == 1.0) { @@ -212,7 +253,9 @@ auto Add::Simplify() const -> std::unique_ptr } } - // filter out zero-equivalent expressions + /** + * filter out zero-equivalent expressions + */ std::vector> avals; for (auto& val : vals) { if (auto real = RecursiveCast(*val); real != nullptr) { @@ -235,13 +278,20 @@ auto Add::Simplify() const -> std::unique_ptr return simplifiedAdd.Copy(); } +/** + * Performs integration on addition expression + */ auto Add::Integrate(const Expression& integrationVariable) const -> std::unique_ptr { - // Single integration variable + /** + * Single integration variable + */ if (auto variable = RecursiveCast(integrationVariable); variable != nullptr) { auto simplifiedAdd = this->Simplify(); - // Make sure we're still adder + /** + * Make sure we're still adder + */ if (auto adder = RecursiveCast>(*simplifiedAdd); adder != nullptr) { auto leftRef = adder->GetLeastSigOp().Copy(); auto leftIntegral = leftRef->Integrate(integrationVariable); @@ -263,7 +313,9 @@ auto Add::Integrate(const Expression& integrationVariable) const -> return add.Simplify(); } - // If not, use other integration technique + /** + * If not, use other integration technique + */ else { return simplifiedAdd->Integrate(integrationVariable)->Simplify(); } @@ -273,6 +325,9 @@ auto Add::Integrate(const Expression& integrationVariable) const -> return integral.Copy(); } +/** + * Performs differentiation on addition expression + */ auto Add::Differentiate(const Expression& differentiationVariable) const -> std::unique_ptr { if (auto variable = RecursiveCast(differentiationVariable); variable != nullptr) { diff --git a/src/DefiniteIntegral.cpp b/src/DefiniteIntegral.cpp index e442a58c..5bbaf559 100644 --- a/src/DefiniteIntegral.cpp +++ b/src/DefiniteIntegral.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/30/24. -// +/** + * Created by Matthew McCall on 4/30/24. + */ #include "Oasis/DefiniteIntegral.hpp" diff --git a/src/Derivative.cpp b/src/Derivative.cpp index 1e6a159b..c58304e2 100644 --- a/src/Derivative.cpp +++ b/src/Derivative.cpp @@ -1,6 +1,6 @@ -// -// Created by bachia on 4/12/2024. -// +/** + * Created by bachia on 4/12/2024. + */ #include "Oasis/Derivative.hpp" #include "Oasis/Add.hpp" diff --git a/src/Divide.cpp b/src/Divide.cpp index e26a1950..ac6936d4 100644 --- a/src/Divide.cpp +++ b/src/Divide.cpp @@ -21,7 +21,9 @@ Divide::Divide(const Expression& dividend, const Expression& divisor : BinaryExpression(dividend, divisor) { } - +/** + *Simplifies a division expression + */ auto Divide::Simplify() const -> std::unique_ptr { auto simplifiedDividend = mostSigOp->Simplify(); // numerator @@ -33,8 +35,9 @@ auto Divide::Simplify() const -> std::unique_ptr const Real& divisor = realCase->GetLeastSigOp(); return std::make_unique(dividend.GetValue() / divisor.GetValue()); } - - // log(a)/log(b)=log[b](a) + /** + *log(a)/log(b)=log[b](a) + */ if (auto logCase = RecursiveCast, Log>>(simplifiedDivide); logCase != nullptr) { if (logCase->GetMostSigOp().GetMostSigOp().Equals(logCase->GetLeastSigOp().GetMostSigOp())) { const IExpression auto& base = logCase->GetLeastSigOp().GetLeastSigOp(); @@ -42,7 +45,9 @@ auto Divide::Simplify() const -> std::unique_ptr return std::make_unique>(base, argument); } } - // convert the terms in numerator and denominator into a vector to make manipulations easier + /** + * convert the terms in numerator and denominator into a vector to make manipulations easier + */ std::vector> numerator; std::vector> denominator; std::vector> result; @@ -61,7 +66,9 @@ auto Divide::Simplify() const -> std::unique_ptr denominator.push_back(simplifiedDivider->Copy()); } - // now that we have the terms in a vector, we have to cancel like terms and simplify them + /** + * now that we have the terms in a vector, we have to cancel like terms and simplify them + */ result.reserve(numerator.size()); for (const auto& num : numerator) { result.push_back(num->Copy()); @@ -163,7 +170,9 @@ auto Divide::Simplify() const -> std::unique_ptr } } - // rebuild into tree + /** + * rebuild into tree + */ for (const auto& val : result) { if (auto valI = RecursiveCast(*val); valI != nullptr) { if (valI->GetValue() != 1.0) { @@ -190,7 +199,9 @@ auto Divide::Simplify() const -> std::unique_ptr } } - // makes expr^1 into expr + /** + * makes expr^1 into expr + */ for (auto& val : numeratorVals) { if (auto exp = RecursiveCast>(*val); exp != nullptr) { if (exp->GetLeastSigOp().GetValue() == 1.0) { @@ -210,7 +221,9 @@ auto Divide::Simplify() const -> std::unique_ptr auto dividend = numeratorVals.size() == 1 ? std::move(numeratorVals.front()) : BuildFromVector(numeratorVals); auto divisor = denominatorVals.size() == 1 ? std::move(denominatorVals.front()) : BuildFromVector(denominatorVals); - // rebuild subtrees + /** + *rebuild subtrees + */ if (!dividend && divisor) return Divide { Real { 1.0 }, *divisor }.Copy(); @@ -223,6 +236,9 @@ auto Divide::Simplify() const -> std::unique_ptr return Divide { *dividend, *divisor }.Copy(); } +/** + * Performs integration on division expression + */ auto Divide::Integrate(const Expression& integrationVariable) const -> std::unique_ptr { // Single integration variable @@ -239,14 +255,20 @@ auto Divide::Integrate(const Expression& integrationVariable) const return integral.Copy(); } - +/** + * Performs Differentiation on division expression + */ auto Divide::Differentiate(const Oasis::Expression& differentiationVariable) const -> std::unique_ptr { - // Single differentiation variable + /** + * Single differentiation variable + */ if (auto variable = RecursiveCast(differentiationVariable); variable != nullptr) { auto simplifiedDiv = this->Simplify(); - // Constant case - differentiation over a divisor + /** + * Constant case - differentiation over a divisor + */ if (auto constant = RecursiveCast>(*simplifiedDiv); constant != nullptr) { auto exp = constant->GetMostSigOp().Copy(); auto num = constant->GetLeastSigOp(); @@ -255,7 +277,9 @@ auto Divide::Differentiate(const Oasis::Expression& differentiationV return std::make_unique>(Divide { *(add->Simplify()), Real { num.GetValue() } })->Simplify(); } } - // In case of simplify turning divide into mult + /** + * In case of simplify turning divide into mult + */ if (auto constant = RecursiveCast>(*simplifiedDiv); constant != nullptr) { auto exp = constant->GetMostSigOp().Copy(); auto num = constant->GetLeastSigOp(); @@ -264,7 +288,9 @@ auto Divide::Differentiate(const Oasis::Expression& differentiationV return std::make_unique>(Multiply { *(add->Simplify()), Real { num.GetValue() } })->Simplify(); } } - // Quotient Rule: d/dx (f(x)/g(x)) = (g(x)f'(x)-f(x)g'(x))/(g(x)^2) + /** + * Quotient Rule: d/dx (f(x)/g(x)) = (g(x)f'(x)-f(x)g'(x))/(g(x)^2) + */ if (auto quotient = RecursiveCast>(*simplifiedDiv); quotient != nullptr) { auto leftexp = quotient->GetMostSigOp().Copy(); auto rightexp = quotient->GetLeastSigOp().Copy(); diff --git a/src/EulerNumber.cpp b/src/EulerNumber.cpp index f878309e..aabfd3e8 100644 --- a/src/EulerNumber.cpp +++ b/src/EulerNumber.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 6/25/24. -// +/** + * Created by Andrew Nazareth on 6/25/24. + */ #include "Oasis/EulerNumber.hpp" #include "numbers" diff --git a/src/Exponent.cpp b/src/Exponent.cpp index fcc40172..37aee99f 100644 --- a/src/Exponent.cpp +++ b/src/Exponent.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 9/19/23. -// +/** + * Created by Andrew Nazareth on 9/19/23. + */ #include @@ -23,7 +23,9 @@ Exponent::Exponent(const Expression& base, const Expression& power) : BinaryExpression(base, power) { } - +/** + *Simplifies Expression with exponent + */ auto Exponent::Simplify() const -> std::unique_ptr { static constexpr auto match_cast = MatchCast() @@ -118,15 +120,21 @@ auto Exponent::Simplify() const -> std::unique_ptr auto matchResult = match_cast.Execute(simplifiedExponent, nullptr).value(); return matchResult ? std::move(matchResult) : std::move(simplifiedExponent.Copy()); } - +/** + *Integrates an expression with an exponent + */ auto Exponent::Integrate(const Expression& integrationVariable) const -> std::unique_ptr { - // variable integration + /** + *variable integration + */ if (auto variable = RecursiveCast(integrationVariable); variable != nullptr) { auto simplifiedExponent = this->Simplify(); std::unique_ptr integral; - // Variable with a constant power + /** + *Variable with a constant power + */ if (auto realExponent = RecursiveCast>(*simplifiedExponent); realExponent != nullptr) { const Variable& expBase = realExponent->GetMostSigOp(); const Real& expPow = realExponent->GetLeastSigOp(); @@ -149,15 +157,21 @@ auto Exponent::Integrate(const Expression& integrationVariable) cons return integral.Copy(); } - +/** + *Differentiates an expression with an exponent + */ auto Exponent::Differentiate(const Expression& differentiationVariable) const -> std::unique_ptr { - // variable diff + /** + *variable diff + */ if (auto variable = RecursiveCast(differentiationVariable); variable != nullptr) { auto simplifiedExponent = this->Simplify(); std::unique_ptr diff; - // Variable with a constant power + /** + *Variable with a constant power + */ if (auto realExponent = RecursiveCast>(*simplifiedExponent); realExponent != nullptr) { const Variable& expBase = realExponent->GetMostSigOp(); const Real& expPow = realExponent->GetLeastSigOp(); diff --git a/src/Expression.cpp b/src/Expression.cpp index 2d863e33..8604c53d 100644 --- a/src/Expression.cpp +++ b/src/Expression.cpp @@ -9,6 +9,8 @@ #include #include + +//Gets all factors for a given number n std::vector getAllFactors(long long n) { std::vector answer; @@ -23,6 +25,7 @@ std::vector getAllFactors(long long n) return answer; } +//returns the greatest common factor between 2 numbers a and b long long gcf(long long a, long long b) { if (b > a) { @@ -60,10 +63,18 @@ auto Expression::FindZeros() const -> std::vector> std::string varName = ""; std::vector> posCoefficents; std::vector> negCoefficents; + /** + *loops through each term in the expression + */ for (const auto& i : termsE) { std::unique_ptr coefficent; std::string variableName; double exponent; + + + /** + *tries to determine what type of expression the term i is + */ if (auto variableCase = RecursiveCast(*i); variableCase != nullptr) { coefficent = Real(1).Copy(); variableName = variableCase->GetName(); diff --git a/src/Imaginary.cpp b/src/Imaginary.cpp index 3d339f50..c37e26c6 100644 --- a/src/Imaginary.cpp +++ b/src/Imaginary.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 10/10/23. -// +/** + * Created by Andrew Nazareth on 10/10/23. + */ #include "Oasis/Imaginary.hpp" #include "string" diff --git a/src/Integral.cpp b/src/Integral.cpp index 3ab2876e..6ba7a768 100644 --- a/src/Integral.cpp +++ b/src/Integral.cpp @@ -14,10 +14,11 @@ Integral::Integral(const Expression& integrand, const Expression& di : BinaryExpression(integrand, differential) { } - +/** + * Returns a simplified integral + */ auto Integral::Simplify() const -> std::unique_ptr { - // Returns simplified Integral auto simplifiedIntegrand = mostSigOp ? mostSigOp->Simplify() : nullptr; auto simplifiedDifferential = leastSigOp ? leastSigOp->Simplify() : nullptr; @@ -25,6 +26,9 @@ auto Integral::Simplify() const -> std::unique_ptr return simplifiedIntegrand->Integrate(*simplifiedDifferential); } +/** + * Returns a simplified integral + */ auto Integral::Simplify(const Expression& upper, const Expression& lower) const -> std::unique_ptr { // Returns simplified Integral diff --git a/src/Linear.cpp b/src/Linear.cpp index 39f2fae3..a8a529e3 100644 --- a/src/Linear.cpp +++ b/src/Linear.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 2/16/24. -// +/** + * Created by Andrew Nazareth on 2/16/24. + */ #include "Oasis/Linear.hpp" #include "Oasis/Add.hpp" @@ -90,7 +90,9 @@ auto SolveLinearSystems(MatrixXXD& matrix) -> Matrix1D if (rows != cols) return Matrix1D {}; // unsolvable - // create matrices A and b + /** + * create matrices A and b + */ MatrixXXD A(rows, cols); Matrix1D b(rows); diff --git a/src/Log.cpp b/src/Log.cpp index c33a2a81..f83243d2 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -1,7 +1,7 @@ -// -// Created by Matthew McCall on 10/6/23. -// Modified by Blake Kessler on 10/10/23 -// +/** + * Created by Matthew McCall on 10/6/23. + * Modified by Blake Kessler on 10/10/23 + */ #include @@ -62,14 +62,18 @@ auto Log::Simplify() const -> std::unique_ptr return std::make_unique(log2(argument.GetValue()) * (1 / log2(base.GetValue()))); } - // log(a) with a < 0 log(-a) + /** + * log(a) with a < 0 log(-a) + */ if (auto negCase = RecursiveCast>(simplifiedLog); negCase != nullptr) { if (negCase->GetLeastSigOp().GetValue() < 0) { return Add { Log { negCase->GetMostSigOp(), Real { -1 * negCase->GetLeastSigOp().GetValue() } }, Multiply { Imaginary {}, Pi {} } }.Generalize(); } } - // log[a](b^x) = x * log[a](b) + /** + * log[a](b^x) = x * log[a](b) + */ if (const auto expCase = RecursiveCast>>(simplifiedLog); expCase != nullptr) { const auto exponent = expCase->GetLeastSigOp(); const IExpression auto& log = Log(expCase->GetMostSigOp(), exponent.GetMostSigOp()); // might need to check that it isnt nullptr @@ -82,9 +86,13 @@ auto Log::Simplify() const -> std::unique_ptr auto Log::Integrate(const Oasis::Expression& integrationVariable) const -> std::unique_ptr { - // TODO: Implement + /** + * TODO: Implement + */ if (this->mostSigOp->Equals(EulerNumber {})) { - // ln(x) + /** + * ln(x) + */ if (leastSigOp->Is() && RecursiveCast(*leastSigOp)->Equals(integrationVariable)) { return Subtract { Multiply { integrationVariable, *this }, integrationVariable }.Simplify(); } @@ -108,7 +116,9 @@ auto Log::Integrate(const Oasis::Expression& integrationVariable) co auto Log::Differentiate(const Oasis::Expression& differentiationVariable) const -> std::unique_ptr { - // d(log_e(6x))/dx = 1/6x * 6 + /** + * d(log_e(6x))/dx = 1/6x * 6 + */ if (auto lnCase = RecursiveCast(*mostSigOp); lnCase != nullptr) { Divide derivative { Oasis::Real { 1.0 }, *leastSigOp }; Derivative chain { *leastSigOp, differentiationVariable }; diff --git a/src/Magnitude.cpp b/src/Magnitude.cpp index 56539119..bafeedce 100644 --- a/src/Magnitude.cpp +++ b/src/Magnitude.cpp @@ -1,5 +1,5 @@ -// -// Created by Andrew Nazareth on 6/28/24. -// +/** + * Created by Andrew Nazareth on 6/28/24. + */ #include "Oasis/Magnitude.hpp" \ No newline at end of file diff --git a/src/Matrix.cpp b/src/Matrix.cpp index 0912f66f..fd0fe001 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 5/24/24. -// +/** + *Created by Andrew Nazareth on 5/24/24. + */ #include "Oasis/Matrix.hpp" #include "Oasis/Integral.hpp" #include "Oasis/Real.hpp" @@ -31,7 +31,9 @@ Matrix::Matrix(size_t numRows, size_t numCols, std::vector& vals) } } -// TO DO: Fix? +/** + * TO DO: Fix? + */ auto Matrix::Differentiate(const Expression&) const -> std::unique_ptr { return std::make_unique(0); @@ -69,7 +71,9 @@ auto Matrix::Inverse() const -> std::unique_ptr return std::make_unique(matrix.inverse()); } -// TO DO: Fix? +/** + * TO DO: Fix? + */ auto Matrix::Integrate(const Expression& integrationVariable) const -> std::unique_ptr { Integral integral { *(this->Copy()), *(integrationVariable.Copy()) }; diff --git a/src/Multiply.cpp b/src/Multiply.cpp index 607d7126..5807b8ac 100644 --- a/src/Multiply.cpp +++ b/src/Multiply.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/10/23. -// +/** + * Created by Matthew McCall on 8/10/23. + */ #include "Oasis/Multiply.hpp" #include "Oasis/Add.hpp" @@ -67,27 +67,28 @@ auto Multiply::Simplify() const -> std::unique_ptr return std::make_unique>(leftTerm, rightTerm); } } - - // Commented out to not cause massive problems with things that need factored expressions - // // c*(a-b) - // if (auto negated = RecursiveCast>>(simplifiedMultiply); negated != nullptr) { - // if (negated->GetMostSigOp().GetValue()<0){ - // return Add{Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetMostSigOp()}, - // Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetLeastSigOp()}}.Simplify(); - // } else if (negated->GetMostSigOp().GetValue()>0){ - // return Subtract{Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetMostSigOp()}, - // Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetLeastSigOp()}}.Simplify(); - // } else { - // return Real{0}.Copy(); - // } - // - // } - // - // // c*(a+b) - // if (auto negated = RecursiveCast>>(simplifiedMultiply); negated != nullptr) { - // return Add{Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetMostSigOp()}, - // Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetLeastSigOp()}}.Simplify(); - // } + /** + * Commented out to not cause massive problems with things that need factored expressions + * // c*(a-b) + * if (auto negated = RecursiveCast>>(simplifiedMultiply); negated != nullptr) { + * if (negated->GetMostSigOp().GetValue()<0){ + * return Add{Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetMostSigOp()}, + * Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetLeastSigOp()}}.Simplify(); + * } else if (negated->GetMostSigOp().GetValue()>0){ + * return Subtract{Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetMostSigOp()}, + * Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetLeastSigOp()}}.Simplify(); + * } else { + * return Real{0}.Copy(); + * } + * + * } + * + * // c*(a+b) + * if (auto negated = RecursiveCast>>(simplifiedMultiply); negated != nullptr) { + * return Add{Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetMostSigOp()}, + * Multiply{negated->GetMostSigOp(), negated->GetLeastSigOp().GetLeastSigOp()}}.Simplify(); + * } + */ if (auto multCase = RecursiveCast>>(simplifiedMultiply); multCase != nullptr) { auto m = Multiply { multCase->GetMostSigOp(), multCase->GetLeastSigOp().GetMostSigOp() }.Simplify(); @@ -107,7 +108,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // x*x^n + /** + * x*x^n + */ if (auto exprCase = RecursiveCast>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().Equals(exprCase->GetLeastSigOp().GetMostSigOp())) { return std::make_unique>(exprCase->GetMostSigOp(), @@ -122,7 +125,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // x^n*x^m + /** + * x^n*x^m + */ if (auto exprCase = RecursiveCast, Exponent>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().GetMostSigOp().Equals(exprCase->GetLeastSigOp().GetMostSigOp())) { return std::make_unique>(exprCase->GetMostSigOp().GetMostSigOp(), @@ -130,7 +135,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // a*x*x + /** + * a*x*x + */ if (auto exprCase = RecursiveCast, Expression>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().GetLeastSigOp().Equals(exprCase->GetLeastSigOp())) { return std::make_unique>(exprCase->GetMostSigOp().GetMostSigOp(), @@ -138,7 +145,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // a*x*b*x + /** + * a*x*b*x + */ if (auto exprCase = RecursiveCast, Multiply>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().GetLeastSigOp().Equals(exprCase->GetLeastSigOp().GetLeastSigOp())) { return std::make_unique>( @@ -147,7 +156,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // a*x^n*x + /** + * a*x^n*x + */ if (auto exprCase = RecursiveCast>, Expression>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().GetLeastSigOp().GetMostSigOp().Equals(exprCase->GetLeastSigOp())) { return std::make_unique>(exprCase->GetMostSigOp().GetMostSigOp(), @@ -156,7 +167,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // a*x*x^n + /** + * a*x*x^n + */ if (auto exprCase = RecursiveCast, Exponent>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().GetLeastSigOp().Equals(exprCase->GetLeastSigOp().GetMostSigOp())) { return std::make_unique>(exprCase->GetMostSigOp().GetMostSigOp(), @@ -170,7 +183,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // a*x^n*b*x + /** + * a*x^n*b*x + */ if (auto exprCase = RecursiveCast, Multiply>>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().GetLeastSigOp().Equals(exprCase->GetLeastSigOp().GetLeastSigOp().GetMostSigOp())) { return std::make_unique>( @@ -198,7 +213,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // a*x^n*x^m + /** + * a*x^n*x^m + */ if (auto exprCase = RecursiveCast>, Exponent>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().GetLeastSigOp().GetMostSigOp().Equals(exprCase->GetLeastSigOp().GetLeastSigOp())) { return std::make_unique>( @@ -208,7 +225,9 @@ auto Multiply::Simplify() const -> std::unique_ptr } } - // a*x^n*b*x^m + /** + * a*x^n*b*x^m + */ if (auto exprCase = RecursiveCast>, Multiply>>>(simplifiedMultiply); exprCase != nullptr) { if (exprCase->GetMostSigOp().GetLeastSigOp().GetMostSigOp().Equals(exprCase->GetLeastSigOp().GetLeastSigOp().GetMostSigOp())) { return std::make_unique>( @@ -217,13 +236,16 @@ auto Multiply::Simplify() const -> std::unique_ptr *(Add { exprCase->GetLeastSigOp().GetLeastSigOp().GetLeastSigOp(), exprCase->GetMostSigOp().GetLeastSigOp().GetLeastSigOp() }.Simplify()) }); } } - - // if (auto negate = RecursiveCast>>>(simplifiedMultiply); negate != nullptr){ - // return Add{Multiply{negate->GetMostSigOp(), negate->GetLeastSigOp().GetOperand().GetMostSigOp()}, - // Multiply{negate->GetMostSigOp(), negate->GetLeastSigOp().GetOperand().GetLeastSigOp()}}.Simplify(); - // } - - // multiply add like terms + /** + * if (auto negate = RecursiveCast>>>(simplifiedMultiply); negate != nullptr){ + * return Add{Multiply{negate->GetMostSigOp(), negate->GetLeastSigOp().GetOperand().GetMostSigOp()}, + * Multiply{negate->GetMostSigOp(), negate->GetLeastSigOp().GetOperand().GetLeastSigOp()}}.Simplify(); + * } + */ + + /** + * multiply add like terms + */ std::vector> multiplies; std::vector> vals; simplifiedMultiply.Flatten(multiplies); @@ -237,12 +259,16 @@ auto Multiply::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(multiplicand->Generalize()); } continue; } - // single i + /** + * single i + */ if (auto img = RecursiveCast(*multiplicand); img != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>(*vals[i]); valI != nullptr) { @@ -251,12 +277,16 @@ auto Multiply::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(Exponent { Imaginary {}, Real { 1.0 } }.Generalize()); } continue; } - // i^n + /** + * i^n + */ if (auto img = RecursiveCast>(*multiplicand); img != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>(*vals[i]); valI != nullptr) { @@ -265,13 +295,17 @@ auto Multiply::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only - // vals.push_back(Multiply { img->GetMostSigOp(), Imaginary {} }.Generalize()); + /** + * check to make sure it is one thing only + * vals.push_back(Multiply { img->GetMostSigOp(), Imaginary {} }.Generalize()); + */ vals.push_back(img->Generalize()); } continue; } - // expr^n + /** + * expr^n + */ if (auto expr = RecursiveCast>(*multiplicand); expr != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>(*vals[i]); valI != nullptr) { @@ -282,13 +316,17 @@ auto Multiply::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only - // vals.push_back(Multiply { img->GetMostSigOp(), Imaginary {} }.Generalize()); + /** + * check to make sure it is one thing only + * vals.push_back(Multiply { img->GetMostSigOp(), Imaginary {} }.Generalize()); + */ vals.push_back(expr->Generalize()); } continue; } - // single expr + /** + * single expr + */ if (auto expr = RecursiveCast(*multiplicand); expr != nullptr) { for (; i < vals.size(); i++) { if (auto valI = RecursiveCast>(*vals[i]); valI != nullptr) { @@ -299,14 +337,18 @@ auto Multiply::Simplify() const -> std::unique_ptr } } if (i >= vals.size()) { - // check to make sure it is one thing only + /** + * check to make sure it is one thing only + */ vals.push_back(Exponent { *expr, Real { 1.0 } }.Generalize()); } continue; } } - // makes all expr^1 into expr + /** + * makes all expr^1 into expr + */ for (auto& val : vals) { if (auto exp = RecursiveCast>(*val); exp != nullptr) { if (exp->GetLeastSigOp().GetValue() == 1.0) { @@ -322,16 +364,22 @@ auto Multiply::Simplify() const -> std::unique_ptr return BuildFromVector(vals); - // return simplifiedMultiply.Copy(); + /** + * return simplifiedMultiply.Copy(); + */ } auto Multiply::Integrate(const Expression& integrationVariable) const -> std::unique_ptr { - // Single integration variable + /** + * Single integration variable + */ if (auto variable = RecursiveCast(integrationVariable); variable != nullptr) { auto simplifiedMult = this->Simplify(); - // Constant case - Constant number multiplied by integrand + /** + * Constant case - Constant number multiplied by integrand + */ if (auto constant = RecursiveCast>(*simplifiedMult); constant != nullptr) { auto exp = constant->GetLeastSigOp().Copy(); auto num = constant->GetMostSigOp(); @@ -348,7 +396,9 @@ auto Multiply::Integrate(const Expression& integrationVariable) cons } } - // TODO: Implement integration by parts + /** + * TODO: Implement integration by parts + */ } Integral integral { *(this->Copy()), *(integrationVariable.Copy()) }; @@ -357,11 +407,15 @@ auto Multiply::Integrate(const Expression& integrationVariable) cons auto Multiply::Differentiate(const Expression& differentiationVariable) const -> std::unique_ptr { - // Single integration variable + /** + * Single integration variable + */ if (auto variable = RecursiveCast(differentiationVariable); variable != nullptr) { auto simplifiedMult = this->Simplify(); - // Constant case - Constant number multiplied by differentiate + /** + * Constant case - Constant number multiplied by differentiate + */ if (auto constant = RecursiveCast>(*simplifiedMult); constant != nullptr) { auto exp = constant->GetLeastSigOp().Copy(); auto num = constant->GetMostSigOp(); @@ -371,7 +425,9 @@ auto Multiply::Differentiate(const Expression& differentiationVariab } } - // Product rule: d/dx (f(x)*g(x)) = f'(x)*g(x) + f(x)*g'(x) + /** + * Product rule: d/dx (f(x)*g(x)) = f'(x)*g(x) + f(x)*g'(x) + */ else if (auto product = RecursiveCast>(*simplifiedMult); product != nullptr) { auto left = product->GetMostSigOp().Copy(); auto right = product->GetLeastSigOp().Copy(); diff --git a/src/Negate.cpp b/src/Negate.cpp index 60364736..3e31d857 100644 --- a/src/Negate.cpp +++ b/src/Negate.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 3/29/24. -// +/** + * Created by Matthew McCall on 3/29/24. + */ #include "Oasis/Negate.hpp" diff --git a/src/Pi.cpp b/src/Pi.cpp index b8d04882..b719296f 100644 --- a/src/Pi.cpp +++ b/src/Pi.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 6/25/24. -// +/** + * Created by Andrew Nazareth on 6/25/24. + */ #include "Oasis/Pi.hpp" #include "string" diff --git a/src/Real.cpp b/src/Real.cpp index 8eff8f56..e20d9b60 100644 --- a/src/Real.cpp +++ b/src/Real.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 7/2/23. -// +/** + * Created by Matthew McCall on 7/2/23. + */ #include @@ -33,10 +33,15 @@ auto Real::GetValue() const -> double return value; } +/** + * Performs integration on Real Number + */ auto Real::Integrate(const Expression& integrationVariable) const -> std::unique_ptr { if (auto variable = RecursiveCast(integrationVariable); variable != nullptr) { - // Constant rule + /** + * Constant rule + */ if (value != 0) { Add adder { @@ -46,7 +51,9 @@ auto Real::Integrate(const Expression& integrationVariable) const -> std::unique return adder.Simplify(); } - // Zero rule + /** + * Zero rule + */ return std::make_unique(Variable { "C" })->Simplify(); } diff --git a/src/Subtract.cpp b/src/Subtract.cpp index 81c9893d..e24b6d80 100644 --- a/src/Subtract.cpp +++ b/src/Subtract.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/10/23. -// +/** + * Created by Matthew McCall on 8/10/23. + */ #include "Oasis/Subtract.hpp" #include "Oasis/Add.hpp" @@ -18,7 +18,9 @@ Subtract::Subtract(const Expression& minuend, const Expression& subt : BinaryExpression(minuend, subtrahend) { } - +/** + * Simplifies subtraction expression + */ auto Subtract::Simplify() const -> std::unique_ptr { const auto simplifiedMinuend = mostSigOp ? mostSigOp->Simplify() : nullptr; @@ -26,7 +28,9 @@ auto Subtract::Simplify() const -> std::unique_ptr const Subtract simplifiedSubtract { *simplifiedMinuend, *simplifiedSubtrahend }; - // 2 - 1 = 1 + /** + * 2 - 1 = 1 + */ if (auto realCase = RecursiveCast>(simplifiedSubtract); realCase != nullptr) { const Real& minuend = realCase->GetMostSigOp(); const Real& subtrahend = realCase->GetLeastSigOp(); @@ -34,7 +38,9 @@ auto Subtract::Simplify() const -> std::unique_ptr return std::make_unique(minuend.GetValue() - subtrahend.GetValue()); } - // x - x = 0 + /** + * x - x = 0 + */ if (simplifiedMinuend->Equals(*simplifiedSubtrahend)) { return std::make_unique(Real { 0.0 }); } @@ -50,7 +56,9 @@ auto Subtract::Simplify() const -> std::unique_ptr } } - // ax - x = (a-1)x + /** + * ax - x = (a-1)x + */ if (const auto minusOneCase = RecursiveCast, Expression>>(simplifiedSubtract); minusOneCase != nullptr) { if (minusOneCase->GetMostSigOp().GetLeastSigOp().Equals(minusOneCase->GetLeastSigOp())) { const Subtract newCoefficient { minusOneCase->GetMostSigOp().GetMostSigOp(), Real { 1.0 } }; @@ -58,7 +66,9 @@ auto Subtract::Simplify() const -> std::unique_ptr } } - // x-ax = (1-a)x + /** + * x-ax = (1-a)x + */ if (const auto oneMinusCase = RecursiveCast>>(simplifiedSubtract); oneMinusCase != nullptr) { if (oneMinusCase->GetMostSigOp().Equals(oneMinusCase->GetLeastSigOp().GetLeastSigOp())) { const Subtract newCoefficient { Real { 1.0 }, oneMinusCase->GetLeastSigOp().GetMostSigOp() }; @@ -66,7 +76,9 @@ auto Subtract::Simplify() const -> std::unique_ptr } } - // ax-bx= (a-b)x + /** + * ax-bx= (a-b)x + */ if (const auto coefficientCase = RecursiveCast>>(simplifiedSubtract); coefficientCase != nullptr) { if (coefficientCase->GetMostSigOp().GetLeastSigOp().Equals(coefficientCase->GetLeastSigOp().GetLeastSigOp())) { const Subtract newCoefficient { coefficientCase->GetMostSigOp().GetMostSigOp(), coefficientCase->GetLeastSigOp().GetMostSigOp() }; @@ -74,7 +86,9 @@ auto Subtract::Simplify() const -> std::unique_ptr } } - // log(a) - log(b) = log(a / b) + /** + * log(a) - log(b) = log(a / b) + */ if (const auto logCase = RecursiveCast>>(simplifiedSubtract); logCase != nullptr) { if (logCase->GetMostSigOp().GetMostSigOp().Equals(logCase->GetLeastSigOp().GetMostSigOp())) { const IExpression auto& base = logCase->GetMostSigOp().GetMostSigOp(); @@ -83,7 +97,9 @@ auto Subtract::Simplify() const -> std::unique_ptr } } - // makes subtraction into addition because it is easier to deal with + /** + * makes subtraction into addition because it is easier to deal with + */ auto negated = Multiply { Real { -1 }, *simplifiedSubtrahend }; if (auto added = RecursiveCast>(negated.GetLeastSigOp()); added != nullptr) { auto RHS = Add { *(Multiply { Real { -1.0 }, added->GetMostSigOp() }.Simplify()), @@ -100,13 +116,20 @@ auto Subtract::Simplify() const -> std::unique_ptr return Add { *simplifiedMinuend, negated }.Simplify(); } +/** + * Performs Differentiation on subtraction expression + */ auto Subtract::Differentiate(const Expression& differentiationVariable) const -> std::unique_ptr { - // Single diff variable + /** + * Single diff variable + */ if (auto variable = RecursiveCast(differentiationVariable); variable != nullptr) { auto simplifiedSub = this->Simplify(); - // Make sure we're still subtracting + /** + * Make sure we're still subtracting + */ if (auto adder = RecursiveCast>(*simplifiedSub); adder != nullptr) { auto rightRef = adder->GetLeastSigOp().Copy(); auto rightDiff = rightRef->Differentiate(differentiationVariable); @@ -124,7 +147,9 @@ auto Subtract::Differentiate(const Expression& differentiationVariab return std::make_unique>(Subtract { *(specializedLeft->Copy()), *(specializedRight->Copy()) })->Simplify(); } - // If not, use other differentiation technique + /** + * If not, use other differentiation technique + */ else { return simplifiedSub->Differentiate(differentiationVariable); } @@ -132,13 +157,20 @@ auto Subtract::Differentiate(const Expression& differentiationVariab return Copy(); } +/** + * Perfroms integration on subtraction epxression + */ auto Subtract::Integrate(const Expression& integrationVariable) const -> std::unique_ptr { - // Single integration variable + /** + * Single integration variable + */ if (auto variable = RecursiveCast(integrationVariable); variable != nullptr) { auto simplifiedSub = this->Simplify(); - // Make sure we're still subtracting + /** + * Make sure we're still subtracting + */ if (auto adder = RecursiveCast>(*simplifiedSub); adder != nullptr) { auto leftRef = adder->GetLeastSigOp().Copy(); auto leftIntegral = leftRef->Integrate(integrationVariable); @@ -160,7 +192,9 @@ auto Subtract::Integrate(const Expression& integrationVariable) cons return add.Simplify(); } - // If not, use other integration technique + /** + * If not, use other integration technique + */ else { return simplifiedSub->Integrate(integrationVariable); } diff --git a/src/Summation.cpp b/src/Summation.cpp index edabe07e..eda715e8 100644 --- a/src/Summation.cpp +++ b/src/Summation.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 5/2/24. -// +/** + * Created by Matthew McCall on 5/2/24. + */ #include "Oasis/Summation.hpp" diff --git a/src/Undefined.cpp b/src/Undefined.cpp index f3e8b673..d040a5ee 100644 --- a/src/Undefined.cpp +++ b/src/Undefined.cpp @@ -1,6 +1,6 @@ -// -// Created by Blake Kessler on 10/13/23. -// +/** + * Created by Blake Kessler on 10/13/23. + */ #include "Oasis/Undefined.hpp" diff --git a/src/Variable.cpp b/src/Variable.cpp index b68981ab..6bd124ed 100644 --- a/src/Variable.cpp +++ b/src/Variable.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/15/23. -// +/** + * Created by Matthew McCall on 8/15/23. + */ #include "Oasis/Variable.hpp" #include "Oasis/Add.hpp" @@ -28,6 +28,9 @@ auto Variable::GetName() const -> std::string return name; } +/** + *Performs integration on variable + */ auto Variable::Integrate(const Expression& integrationVariable) const -> std::unique_ptr { if (auto variable = RecursiveCast(integrationVariable); variable != nullptr) { @@ -42,8 +45,9 @@ auto Variable::Integrate(const Expression& integrationVariable) const -> std::un }; return adder.Simplify(); } - - // Different variable, treat as constant + /** + *Different variable, treat as constant + */ Add adder { Multiply { Variable { name }, Variable { (*variable).GetName() } }, Variable { "C" } @@ -55,7 +59,9 @@ auto Variable::Integrate(const Expression& integrationVariable) const -> std::un return integral.Copy(); } - +/** + *Performs substitution on variable + */ auto Variable::Substitute(const Expression& var, const Expression& val) -> std::unique_ptr { auto varclone = RecursiveCast(var); @@ -67,18 +73,22 @@ auto Variable::Substitute(const Expression& var, const Expression& val) -> std:: } return Copy(); } - +/** + *Performs differentiation on variable + */ auto Variable::Differentiate(const Expression& differentiationVariable) const -> std::unique_ptr { if (auto variable = RecursiveCast(differentiationVariable); variable != nullptr) { - - // Power rule + /** + *Power rule + */ if (name == (*variable).GetName()) { return std::make_unique(Real { 1.0f }) ->Simplify(); } - - // Different variable, treat as constant + /** + *Different variable, treat as constant + */ return std::make_unique(Real { 0 }) ->Simplify(); } diff --git a/tests/AddTests.cpp b/tests/AddTests.cpp index 202eb14c..29a603b5 100644 --- a/tests/AddTests.cpp +++ b/tests/AddTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/7/23. -// +/** + * Created by Matthew McCall on 8/7/23. + */ #include "Common.hpp" #include "catch2/catch_test_macros.hpp" diff --git a/tests/BinaryExpressionTests.cpp b/tests/BinaryExpressionTests.cpp index 8d8c7bcb..53a57a49 100644 --- a/tests/BinaryExpressionTests.cpp +++ b/tests/BinaryExpressionTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 10/6/23. -// +/** + * Created by Matthew McCall on 10/6/23. + */ #include "catch2/catch_test_macros.hpp" #include "Oasis/Add.hpp" @@ -57,7 +57,9 @@ TEST_CASE("Specialize Recursively Considers Commutative Property", "[Symbolic]") auto generalizedMultiply = multiply.Generalize(); - // intentionally out of order + /** + * intentionally out of order + */ auto result2 = Oasis::RecursiveCast>>(*generalizedMultiply); REQUIRE(result2 != nullptr); } @@ -180,7 +182,9 @@ TEST_CASE("Equals follows associativity and commutativity") real3 }; - // (1 + 2) + 3 == 1 + (2 + 3) + /** + * (1 + 2) + 3 == 1 + (2 + 3) + */ SECTION("Associativity") { Oasis::Add add2 { @@ -193,7 +197,9 @@ TEST_CASE("Equals follows associativity and commutativity") REQUIRE(add1.Equals(add2)); } - // (1 + 2) + 3 == 3 + (1 + 2) + /** + * (1 + 2) + 3 == 3 + (1 + 2) + */ SECTION("Commutativity") { Oasis::Add add2 { @@ -206,7 +212,9 @@ TEST_CASE("Equals follows associativity and commutativity") REQUIRE(add1.Equals(add2)); } - // (1 + 2) + 3 == (3 + 2) + 1 + /** + * (1 + 2) + 3 == (3 + 2) + 1 + */ SECTION("Associativity and Commutativity") { Oasis::Add add2 { diff --git a/tests/Common.hpp b/tests/Common.hpp index 70504f2c..3e35852e 100644 --- a/tests/Common.hpp +++ b/tests/Common.hpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 1/31/25. -// +/** + * Created by Matthew McCall on 1/31/25. + */ #ifndef COMMON_HPP #define COMMON_HPP diff --git a/tests/DifferentiateTests.cpp b/tests/DifferentiateTests.cpp index 49e4c36f..8e1b526e 100644 --- a/tests/DifferentiateTests.cpp +++ b/tests/DifferentiateTests.cpp @@ -1,6 +1,6 @@ -// -// Created by bachia on 4/5/2024. -// +/** + * Created by bachia on 4/5/2024. + */ #include "catch2/catch_test_macros.hpp" #include "Oasis/Add.hpp" diff --git a/tests/DivideTests.cpp b/tests/DivideTests.cpp index 3658faea..0d90345e 100644 --- a/tests/DivideTests.cpp +++ b/tests/DivideTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/10/23. -// +/** + * Created by Matthew McCall on 8/10/23. + */ #include "catch2/catch_test_macros.hpp" @@ -180,8 +180,9 @@ TEST_CASE("Symbolic Division, equal exponents", "[Division][Symbolic]") TEST_CASE("Division of equal variables", "[Division][Symbolic]") { - // x/x = 1 - + /** + * x/x = 1 + */ Oasis::Divide div { Oasis::Variable { "x" }, Oasis::Variable { "x" } }; auto simplified = div.Simplify(); REQUIRE(Oasis::Real { 1 }.Equals(*simplified)); diff --git a/tests/ExponentTests.cpp b/tests/ExponentTests.cpp index b36da364..f216b81a 100644 --- a/tests/ExponentTests.cpp +++ b/tests/ExponentTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 9/22/23. -// +/** + * Created by Andrew Nazareth on 9/22/23. + */ #include "catch2/catch_test_macros.hpp" diff --git a/tests/LinearTests.cpp b/tests/LinearTests.cpp index 4af88be4..ef45b0fd 100644 --- a/tests/LinearTests.cpp +++ b/tests/LinearTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 2/16/24. -// +/** + * Created by Andrew Nazareth on 2/16/24. + */ #include "catch2/catch_test_macros.hpp" @@ -110,61 +110,61 @@ TEST_CASE("Linear Solve with subtraction", "[Linear][Subtract]") REQUIRE_THAT(result.find("z")->second, Catch::Matchers::WithinAbs(7.0, EPSILON)); } -// commented out test case to prevent problems with factoring and distributing -//TEST_CASE("Linear Solve with subtraction 2", "[Linear][Subtract]") -//{ -// Oasis::Add add1{ // ((4x - (7y + 5)) + z) -// Oasis::Subtract{ -// Oasis::Multiply{ -// Oasis::Real{4.0}, -// Oasis::Variable{"x"}}, -// Oasis::Add{ -// Oasis::Multiply{ -// Oasis::Real{7.0}, -// Oasis::Variable{"y"}}, -// Oasis::Real{5.0} -// }}, -// Oasis::Variable{"z"} -// }; -// Oasis::Add add2{ -// Oasis::Subtract{ // (((y + x) - 8) + z) -// Oasis::Add{ -// Oasis::Variable{"y"}, -// Oasis::Variable{"x"}}, -// Oasis::Real{8.0}}, -// Oasis::Variable{"z"} -// }; -// Oasis::Add add3{ // (((3x + 2z) - 23) + 3y) -// Oasis::Subtract{ -// Oasis::Add{ -// Oasis::Multiply{ -// Oasis::Real{3.0}, -// Oasis::Variable{"x"}}, -// Oasis::Multiply{ -// Oasis::Real{2.0}, -// Oasis::Variable{"z"}}}, -// Oasis::Real{23}}, -// Oasis::Multiply{ -// Oasis::Real{3}, -// Oasis::Variable{"y"} -// } -// }; -// -// std::vector> exprs; -// exprs.emplace_back(add1.Copy()); -// exprs.emplace_back(add2.Copy()); -// exprs.emplace_back(add3.Copy()); -// -// auto result = Oasis::SolveLinearSystems(exprs); -// -// REQUIRE(result.find("x") != result.end()); -// REQUIRE(result.find("y") != result.end()); -// REQUIRE(result.find("z") != result.end()); -// REQUIRE_THAT(result.find("x")->second, Catch::Matchers::WithinAbs(4.81818181818, EPSILON)); -// REQUIRE_THAT(result.find("y")->second, Catch::Matchers::WithinAbs(2.18181818181, EPSILON)); -// REQUIRE_THAT(result.find("z")->second, Catch::Matchers::WithinAbs(1.0, EPSILON)); -//} - +/**commented out test case to prevent problems with factoring and distributing + * TEST_CASE("Linear Solve with subtraction 2", "[Linear][Subtract]") + * { + * Oasis::Add add1{ // ((4x - (7y + 5)) + z) + * Oasis::Subtract{ + * Oasis::Multiply{ + * Oasis::Real{4.0}, + * Oasis::Variable{"x"}}, + * Oasis::Add{ + * Oasis::Multiply{ + * Oasis::Real{7.0}, + * Oasis::Variable{"y"}}, + * Oasis::Real{5.0} + * }}, + * Oasis::Variable{"z"} + * }; + * Oasis::Add add2{ + * Oasis::Subtract{ // (((y + x) - 8) + z) + * Oasis::Add{ + * Oasis::Variable{"y"}, + * Oasis::Variable{"x"}}, + * Oasis::Real{8.0}}, + * Oasis::Variable{"z"} + * }; + * Oasis::Add add3{ // (((3x + 2z) - 23) + 3y) + * Oasis::Subtract{ + * Oasis::Add{ + * Oasis::Multiply{ + * Oasis::Real{3.0}, + * Oasis::Variable{"x"}}, + * Oasis::Multiply{ + * Oasis::Real{2.0}, + * Oasis::Variable{"z"}}}, + * Oasis::Real{23}}, + * Oasis::Multiply{ + * Oasis::Real{3}, + * Oasis::Variable{"y"} + * } + * }; + * + * std::vector> exprs; + * exprs.emplace_back(add1.Copy()); + * exprs.emplace_back(add2.Copy()); + * exprs.emplace_back(add3.Copy()); + * + * auto result = Oasis::SolveLinearSystems(exprs); + * + * REQUIRE(result.find("x") != result.end()); + * REQUIRE(result.find("y") != result.end()); + * REQUIRE(result.find("z") != result.end()); + * REQUIRE_THAT(result.find("x")->second, Catch::Matchers::WithinAbs(4.81818181818, EPSILON)); + * REQUIRE_THAT(result.find("y")->second, Catch::Matchers::WithinAbs(2.18181818181, EPSILON)); + * REQUIRE_THAT(result.find("z")->second, Catch::Matchers::WithinAbs(1.0, EPSILON)); + *} + */ TEST_CASE("Solve Matrix", "[Linear]") { Oasis::MatrixXXD A(2, 3); diff --git a/tests/LogTests.cpp b/tests/LogTests.cpp index 2cf85ad5..0a0f69e8 100644 --- a/tests/LogTests.cpp +++ b/tests/LogTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Blake Kessler on 10/31/23 -// +/** + * Created by Blake Kessler on 10/31/23 + */ #include "catch2/catch_test_macros.hpp" #include @@ -106,7 +106,9 @@ TEST_CASE("Log of Exponentiation", "[Log][Exponent]") REQUIRE_THAT(simplifiedSpecialized->GetMostSigOp().GetValue(), Catch::Matchers::WithinAbs(1.0, EPSILON)); REQUIRE(simplifiedSpecialized->GetLeastSigOp().Equals(Oasis::Variable { "x" })); - //log[5](x^x) = xlog[5](x) + /** + * log[5](x^x) = xlog[5](x) + */ Oasis::Log logOfExp { Oasis::Real { 5.0 }, Oasis::Exponent { diff --git a/tests/MagnitudeTests.cpp b/tests/MagnitudeTests.cpp index bdcd63bb..9858f938 100644 --- a/tests/MagnitudeTests.cpp +++ b/tests/MagnitudeTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 6/28/24. -// +/** + * Created by Andrew Nazareth on 6/28/24. + */ #include "catch2/catch_test_macros.hpp" #include "Oasis/Magnitude.hpp" diff --git a/tests/MatrixTests.cpp b/tests/MatrixTests.cpp index 5ff1266c..113fddae 100644 --- a/tests/MatrixTests.cpp +++ b/tests/MatrixTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Andrew Nazareth on 5/24/24. -// +/** + * Created by Andrew Nazareth on 5/24/24. + */ #include "catch2/catch_test_macros.hpp" #include diff --git a/tests/MultiplyTests.cpp b/tests/MultiplyTests.cpp index 5993e0b2..a58c24e4 100644 --- a/tests/MultiplyTests.cpp +++ b/tests/MultiplyTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/10/23. -// +/** + * Created by Matthew McCall on 8/10/23. + */ #include "catch2/catch_test_macros.hpp" diff --git a/tests/NegateTests.cpp b/tests/NegateTests.cpp index 4e1640ca..2fea4620 100644 --- a/tests/NegateTests.cpp +++ b/tests/NegateTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/5/24. -// +/** + * Created by Matthew McCall on 4/5/24. + */ #include "catch2/catch_test_macros.hpp" diff --git a/tests/PolynomialTests.cpp b/tests/PolynomialTests.cpp index 7b7862bc..e1dffef7 100644 --- a/tests/PolynomialTests.cpp +++ b/tests/PolynomialTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/7/23. -// +/** + * Created by Matthew McCall on 8/7/23. + */ #include "catch2/catch_test_macros.hpp" #include "Oasis/Add.hpp" @@ -19,40 +19,41 @@ #include #include -// TODO: Figure out what's going out here -// TEST_CASE("7th degree polynomial with rational roots", "[factor][duplicateRoot]") -// { -// std::vector> vec; -// long offset = -3; -// std::vector vecL = { 24750, -200'925, 573'625, -631'406, 79184, 247'799, -92631, 8820 }; -// for (size_t i = 0; i < vecL.size(); i++) { -// Oasis::Real num = Oasis::Real(vecL[i]); -// long exp = ((long)i) + offset; -// if (exp < -1) { -// vec.push_back(Oasis::Divide(num, Oasis::Exponent(Oasis::Variable("x"), Oasis::Real(-exp * 1.0))).Copy()); -// } else if (exp == -1) { -// vec.push_back(Oasis::Divide(num, Oasis::Variable("x")).Copy()); -// } else if (exp == 0) { -// vec.push_back(num.Copy()); -// } else if (exp == 1) { -// vec.push_back(Oasis::Multiply(num, Oasis::Variable("x")).Copy()); -// } else { -// vec.push_back(Oasis::Multiply(num, Oasis::Exponent(Oasis::Variable("x"), Oasis::Real(exp * 1.0))).Copy()); -// } -// } -// auto add = Oasis::BuildFromVector(vec); -// auto zeros = add->FindZeros(); -// REQUIRE(zeros.size() == 6); -// std::set> goalSet = { std::tuple(1, 3), std::tuple(6, 7), std::tuple(3, 7), std::tuple(-5, 3), std::tuple(11, 20), std::tuple(5, 1) }; -// for (auto& i : zeros) { -// auto divideCase = Oasis::RecursiveCast>(*i); -// REQUIRE(divideCase != nullptr); -// std::tuple asTuple = std::tuple(std::lround(divideCase->GetMostSigOp().GetValue()), std::lround(divideCase->GetLeastSigOp().GetValue())); -// REQUIRE(goalSet.contains(asTuple)); -// goalSet.erase(asTuple); -// } -// } - +/** + * TODO: Figure out what's going out here + * TEST_CASE("7th degree polynomial with rational roots", "[factor][duplicateRoot]") + * { + * std::vector> vec; + * long offset = -3; + * std::vector vecL = { 24750, -200'925, 573'625, -631'406, 79184, 247'799, -92631, 8820 }; + * for (size_t i = 0; i < vecL.size(); i++) { + * Oasis::Real num = Oasis::Real(vecL[i]); + * long exp = ((long)i) + offset; + * if (exp < -1) { + * vec.push_back(Oasis::Divide(num, Oasis::Exponent(Oasis::Variable("x"), Oasis::Real(-exp * 1.0))).Copy()); + * } else if (exp == -1) { + * vec.push_back(Oasis::Divide(num, Oasis::Variable("x")).Copy()); + * } else if (exp == 0) { + * vec.push_back(num.Copy()); + * } else if (exp == 1) { + * vec.push_back(Oasis::Multiply(num, Oasis::Variable("x")).Copy()); + * } else { + * vec.push_back(Oasis::Multiply(num, Oasis::Exponent(Oasis::Variable("x"), Oasis::Real(exp * 1.0))).Copy()); + * } + * } + * auto add = Oasis::BuildFromVector(vec); + * auto zeros = add->FindZeros(); + * REQUIRE(zeros.size() == 6); + * std::set> goalSet = { std::tuple(1, 3), std::tuple(6, 7), std::tuple(3, 7), std::tuple(-5, 3), std::tuple(11, 20), std::tuple(5, 1) }; + * for (auto& i : zeros) { + * auto divideCase = Oasis::RecursiveCast>(*i); + * REQUIRE(divideCase != nullptr); + * std::tuple asTuple = std::tuple(std::lround(divideCase->GetMostSigOp().GetValue()), std::lround(divideCase->GetLeastSigOp().GetValue())); + * REQUIRE(goalSet.contains(asTuple)); + * goalSet.erase(asTuple); + * } + * } + */ TEST_CASE("imaginary linear polynomial") { Oasis::Add add { @@ -68,46 +69,48 @@ TEST_CASE("imaginary linear polynomial") } } -// TODO: Figure out what's going out here -// TEST_CASE("irrational quadratic", "[quadraticFormula]") -// { -// std::vector> vec; -// long offset = -3; -// std::vector vecL = { -1, 1, 1 }; -// for (size_t i = 0; i < vecL.size(); i++) { -// Oasis::Real num = Oasis::Real(vecL[i]); -// long exp = ((long)i) + offset; -// if (exp < -1) { -// vec.push_back(Oasis::Divide(num, Oasis::Exponent(Oasis::Variable("x"), Oasis::Real(-exp))).Copy()); -// } else if (exp == -1) { -// vec.push_back(Oasis::Divide(num, Oasis::Variable("x")).Copy()); -// } else if (exp == 0) { -// vec.push_back(num.Copy()); -// } else if (exp == 1) { -// vec.push_back(Oasis::Multiply(num, Oasis::Variable("x")).Copy()); -// } else { -// vec.push_back(Oasis::Multiply(num, Oasis::Exponent(Oasis::Variable("x"), Oasis::Real(exp))).Copy()); -// } -// } -// auto add = Oasis::BuildFromVector(vec); -// auto zeros = add->FindZeros(); -// REQUIRE(zeros.size() == 2); -// auto negOne = Oasis::Real(-1); -// auto two = Oasis::Real(2); -// auto root5 = Oasis::Exponent(Oasis::Real(5), Oasis::Divide(Oasis::Real(1), two)); -// std::list> goalSet = {}; -// goalSet.push_back(Oasis::Divide(Oasis::Add(negOne, root5), two).Copy()); -// goalSet.push_back(Oasis::Divide(Oasis::Subtract(negOne, root5), two).Copy()); -// for (auto& i : zeros) { -// for (auto i2 = goalSet.begin(); i2 != goalSet.end(); i2++) { -// if ((*i2)->Equals(*i)) { -// goalSet.erase(i2); -// break; -// } -// } -// } -// REQUIRE(goalSet.size() == 0); -// } +/** + * TODO: Figure out what's going out here + * TEST_CASE("irrational quadratic", "[quadraticFormula]") + * { + * std::vector> vec; + * long offset = -3; + * std::vector vecL = { -1, 1, 1 }; + * for (size_t i = 0; i < vecL.size(); i++) { + * Oasis::Real num = Oasis::Real(vecL[i]); + * long exp = ((long)i) + offset; + * if (exp < -1) { + * vec.push_back(Oasis::Divide(num, Oasis::Exponent(Oasis::Variable("x"), Oasis::Real(-exp))).Copy()); + * } else if (exp == -1) { + * vec.push_back(Oasis::Divide(num, Oasis::Variable("x")).Copy()); + * } else if (exp == 0) { + * vec.push_back(num.Copy()); + * } else if (exp == 1) { + * vec.push_back(Oasis::Multiply(num, Oasis::Variable("x")).Copy()); + * } else { + * vec.push_back(Oasis::Multiply(num, Oasis::Exponent(Oasis::Variable("x"), Oasis::Real(exp))).Copy()); + * } + * } + * auto add = Oasis::BuildFromVector(vec); + * auto zeros = add->FindZeros(); + * REQUIRE(zeros.size() == 2); + * auto negOne = Oasis::Real(-1); + * auto two = Oasis::Real(2); + * auto root5 = Oasis::Exponent(Oasis::Real(5), Oasis::Divide(Oasis::Real(1), two)); + * std::list> goalSet = {}; + * goalSet.push_back(Oasis::Divide(Oasis::Add(negOne, root5), two).Copy()); + * goalSet.push_back(Oasis::Divide(Oasis::Subtract(negOne, root5), two).Copy()); + * for (auto& i : zeros) { + * for (auto i2 = goalSet.begin(); i2 != goalSet.end(); i2++) { + * if ((*i2)->Equals(*i)) { + * goalSet.erase(i2); + * break; + * } + * } + * } + * REQUIRE(goalSet.size() == 0); + * } + */ TEST_CASE("linear polynomial", "[factor]") { diff --git a/tests/SubtractTests.cpp b/tests/SubtractTests.cpp index cb2612b9..47b42af2 100644 --- a/tests/SubtractTests.cpp +++ b/tests/SubtractTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 8/10/23. -// +/** + * Created by Matthew McCall on 8/10/23. + */ #include "catch2/catch_test_macros.hpp" diff --git a/tests/UnaryExpressionTests.cpp b/tests/UnaryExpressionTests.cpp index bca7a1b6..e412c23f 100644 --- a/tests/UnaryExpressionTests.cpp +++ b/tests/UnaryExpressionTests.cpp @@ -1,6 +1,6 @@ -// -// Created by Matthew McCall on 4/30/24. -// +/** + * Created by Matthew McCall on 4/30/24. + */ #include