Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4edb846
Added documentation to exponent.cpp
TreeSnowFence Apr 3, 2025
35e6d92
Added documentation to expression.cpp and Variable.cpp
TreeSnowFence Apr 3, 2025
2470f69
Added more documentation
TreeSnowFence Apr 3, 2025
4aadf6d
Merge branch 'open-algebra:master' into master
TreeSnowFence Apr 3, 2025
170f4d8
Added a document detailing how to input mathematical expressions in O…
TreeSnowFence Apr 4, 2025
1a49e12
Adjusted variable.cpp documentation to comply with javadoc style
TreeSnowFence Apr 4, 2025
64fd10a
Adjusted documentation for Expression.cpp/Exponent.cpp
TreeSnowFence Apr 4, 2025
1afba9e
Converted documentation in test cases to be javadoc style
TreeSnowFence Apr 24, 2025
faae322
Converted documentation in remaining testcases to be javadoc style
TreeSnowFence Apr 24, 2025
099cec1
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
12180e7
Converted documtation to javadoc style
TreeSnowFence Apr 24, 2025
a37935e
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
f369ec5
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
fce67da
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
5c2bfb6
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
b8cbd09
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
cd928f4
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
e4e71a7
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
195ecea
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
c67ff41
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
37969fa
Converted documentation to javadoc style
TreeSnowFence Apr 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ latex
# *.iml
# *.ipr


build
# CMake
cmake-build-*/

Expand Down Expand Up @@ -100,7 +102,8 @@ fabric.properties
.LSOverride

# Icon must end with two \r
Icon
Icon


# Thumbnails
._*
Expand Down
38 changes: 38 additions & 0 deletions HowToUseOASIS.txt
Original file line number Diff line number Diff line change
@@ -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)




6 changes: 3 additions & 3 deletions bindings/js/src/bindings.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by Matthew McCall on 3/10/25.
//
/**
* Created by Matthew McCall on 3/10/25.
*/
#include <emscripten/bind.h>

#include "Oasis/Expression.hpp"
Expand Down
18 changes: 12 additions & 6 deletions cli/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by Matthew McCall on 2/19/25.
//
/**
* Created by Matthew McCall on 2/19/25.
*/

#include <cctype>
#include <cstdio>
Expand All @@ -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
Expand All @@ -33,7 +35,9 @@ auto trim_whitespace(const std::string& str) -> std::string
| std::ranges::to<std::string>();
}

// 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)
Expand All @@ -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<Oasis::Expression>& expr) -> std::unique_ptr<Oasis::Expression> {
return expr->Simplify();
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Add.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/BinaryExpression.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/BoundedBinaryExpression.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/BoundedExpression.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 14 additions & 11 deletions include/Oasis/BoundedUnaryExpression.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -46,7 +46,9 @@ class BoundedUnaryExpression : public BoundedExpression<LowerBoundT, UpperBoundT

auto Copy(tf::Subflow&) const -> std::unique_ptr<Expression> final
{
// TODO: Actually implement
/**
* TODO: Actually implement
*/
return std::make_unique<DerivedSpecialized>(*static_cast<const DerivedSpecialized*>(this));
}

Expand All @@ -58,13 +60,14 @@ class BoundedUnaryExpression : public BoundedExpression<LowerBoundT, UpperBoundT
[[nodiscard]] auto Equals(const Expression& other) const -> 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;
}

Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Concepts.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/DefiniteIntegral.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Derivative.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Divide.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/EulerNumber.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Exponent.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Imaginary.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Integral.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/LeafExpression.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Linear.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Log.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 9 additions & 6 deletions include/Oasis/Magnitude.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -78,8 +78,9 @@ class Magnitude final : public UnaryExpression<Magnitude, OperandT> {

[[nodiscard]] auto Differentiate(const Expression& var) const -> std::unique_ptr<Expression> override
{
// TODO: Implement

/**
* TODO: Implement
*/
const std::unique_ptr<Expression> operandDerivative = this->GetOperand().Differentiate(var);
return Magnitude<Expression> {
*operandDerivative
Expand All @@ -89,7 +90,9 @@ class Magnitude final : public UnaryExpression<Magnitude, OperandT> {

[[nodiscard]] auto Integrate(const Expression& integrationVar) const -> std::unique_ptr<Expression> override
{
// TODO: Implement
/**
* TODO: Implement
*/
const std::unique_ptr<Expression> operandDerivative = this->GetOperand().Integrate(integrationVar);
return Magnitude<Expression> {
*operandDerivative
Expand Down
29 changes: 15 additions & 14 deletions include/Oasis/MatchCast.hpp
Original file line number Diff line number Diff line change
@@ -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 -- <path_to_this_file>
//
/**
* 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 -- <path_to_this_file>
*/

#ifndef OASIS_MATCHCAST_HPP
#define OASIS_MATCHCAST_HPP
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Matrix.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/Oasis/Multiply.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading
Loading