diff --git a/include/Oasis/Add.hpp b/include/Oasis/Add.hpp index b61e6d7f..87b5e0e8 100644 --- a/include/Oasis/Add.hpp +++ b/include/Oasis/Add.hpp @@ -32,9 +32,113 @@ class Add< /** * The Add expression adds two expressions together. + * The Add expression takes in two parameters of any Oasis type. + * The Add expression may take in more than two parameters of Real types. * + * + * @section Parameters * @tparam AugendT The type of the expression to add be added to. * @tparam AddendT The type of the expression to add to the augend. + * + * @section Example Usage: + * The Add expression can take in a multitude of Oasis classes. + * + * @subsection val_val Adding two Real values together: + * @code + * Oasis::Add myAdditionSimple { + * Oasis::Real{4}, + * Oasis::Real{4}, + * }; + * Oasis::InFixSerializer result; + * + * auto resultant = myAdditionSimple.Simplify(); + * + * std::println("Result of addition: {}", resultant->Accept(result).value()); + * // Will print 8 + * @endcode + * + * @subsection val_var Adding a Real value and a Variable together: + * @code + * Oasis::Add myAddition { + Oasis::Variable{"x"}, + Oasis::Real{4} + }; + //Oasis::InFixSerializer result; + + resultant = myAddition.Simplify(); + + std::println("Result of addition: {}", resultant->Accept(result).value()); + // Will print x+4 + * @endcode + * + * @subsection var_var Adding two Variables together: + * @code + * Oasis::Add myAdditionX { + Oasis::Variable{"x"}, + Oasis::Variable{"x"} + }; + + resultant = myAdditionX.Simplify(); + + std::println("Result of addition: {}", resultant->Accept(result).value()); + // Will print 2*x + * @endcode + * + * @subsection var_var_n if they are not the same variable: + * @code + * Oasis::Add myAdditionXY { + Oasis::Variable{"x"}, + Oasis::Variable{"y"} + }; + + resultant = myAdditionXY.SimplifyVisitor(); + + std::println("Result of addition: {}", resultant->Accept(result).value()); + // Will print x+y + * @endcode + * + * @subsubsection multi Adding more than two values together: + * + * @code + * auto myAdditionSimple = Oasis::Add<> { + Oasis::Real{4}, + Oasis::Real{4}, + Oasis::Real{4} + }; + Oasis::InFixSerializer result; + + auto resultant = myAdditionSimple.Simplify(); + + std::println("Result of addition: {}", resultant->Accept(result).value()); + * @endcode + * + * @subsection exprAdd Adding two expressions together: + * + * @code + * std::string expr1 = {"2x+3y+15"}; + std::string expr2 = {"5x+9y-10"}; + + const auto prepoc1 = Oasis::PreProcessInFix(expr1); + const auto prepoc2 = Oasis::PreProcessInFix(expr2); + + auto midResult1 = Oasis::FromInFix(prepoc1); + auto midResult2 = Oasis::FromInFix(prepoc2); + + const std::unique_ptr expression1 = std::move(midResult1).value(); + const std::unique_ptr expression2 = std::move(midResult2).value(); + + Oasis::Add exprAdd { + *expression1, + *expression2 + }; + Oasis::InFixSerializer result; + + auto resultant = exprAdd.Simplify(); + + std::println("Result: {}", resultant->Accept(result).value()); + // Will print (((7*x)+(12*y))+5) + * @endcode + * */ template class Add : public BinaryExpression { diff --git a/include/Oasis/BinaryExpression.hpp b/include/Oasis/BinaryExpression.hpp index 30af5a1b..01bafa4d 100644 --- a/include/Oasis/BinaryExpression.hpp +++ b/include/Oasis/BinaryExpression.hpp @@ -17,6 +17,9 @@ namespace Oasis { /** * A concept for an operand of a binary expression. + * @note This class is not intended to be used directly by end users. + * + * @section Parameters * @tparam MostSigOpT The type of the most significant operand. * @tparam LeastSigOpT The type of the least significant operand. * @tparam T The type to check. diff --git a/include/Oasis/BoundedBinaryExpression.hpp b/include/Oasis/BoundedBinaryExpression.hpp index 8b8c4391..c5a2919d 100644 --- a/include/Oasis/BoundedBinaryExpression.hpp +++ b/include/Oasis/BoundedBinaryExpression.hpp @@ -11,6 +11,16 @@ #include "Visit.hpp" namespace Oasis { +/** + * A concept for an operand of a binary expression with bounds. + * @note This class is not intended to be used directly by end users. + * + * @section Parameters + * @tparam MostSigOpT The type of the most significant operand. + * @tparam LeastSigOpT The type of the least significant operand. + * @tparam LowerBoundT The lower bound of the binary expression. + * @tparam UpperBoundT The upper bound of the binary expression. + */ template