Skip to content

Commit

Permalink
Units and uncertainties now parse.
Browse files Browse the repository at this point in the history
  • Loading branch information
toastedcrumpets committed Sep 16, 2021
1 parent f4bc72b commit b21bd23
Show file tree
Hide file tree
Showing 10 changed files with 703 additions and 480 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ if(GTest_FOUND)
stator_test(symbolic_ad_test)
stator_test(symbolic_array_test)
stator_test(symbolic_interval_test)
stator_test(symbolic_units_test)
stator_test(symbolic_uncertainty_test)
#stator_test(symbolic_integration_test)
else()
message(WARNING "Cannot find GTest library, disabling unit tests!")
Expand Down
9 changes: 8 additions & 1 deletion stator/symbolic/binary_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace sym {
static constexpr auto associativity = Associativity::LEFT;
static constexpr bool commutative = true;
static constexpr bool associative = true;
static constexpr bool wrapped = false;
typedef Null left_identity;
typedef Null right_identity;
typedef NoIdentity left_zero;
Expand All @@ -80,6 +81,7 @@ namespace sym {
static constexpr auto associativity = Associativity::LEFT;
static constexpr bool commutative = false;
static constexpr bool associative = false;
static constexpr bool wrapped = false;
typedef NoIdentity left_identity;
typedef Null right_identity;
typedef NoIdentity left_zero;
Expand All @@ -99,6 +101,7 @@ namespace sym {
static constexpr auto associativity = Associativity::LEFT;
static constexpr bool commutative = true;
static constexpr bool associative = true;
static constexpr bool wrapped = false;
typedef Unity left_identity;
typedef Unity right_identity;
typedef Null left_zero;
Expand All @@ -118,6 +121,7 @@ namespace sym {
static constexpr auto associativity = Associativity::LEFT;
static constexpr bool commutative = false;
static constexpr bool associative = false;
static constexpr bool wrapped = false;
typedef NoIdentity left_identity;
typedef Unity right_identity;
typedef Null left_zero;
Expand All @@ -137,6 +141,7 @@ namespace sym {
static constexpr auto associativity = Associativity::RIGHT;
static constexpr bool commutative = false;
static constexpr bool associative = false;
static constexpr bool wrapped = false;
static inline std::string l_repr() { return ""; }
static inline std::string repr() { return "^"; }
static inline std::string r_repr() { return ""; }
Expand All @@ -160,6 +165,7 @@ namespace sym {
static constexpr auto associativity = Associativity::RIGHT;
static constexpr bool commutative = false;
static constexpr bool associative = false;
static constexpr bool wrapped = false;
typedef NoIdentity left_identity;
typedef NoIdentity right_identity;
typedef NoIdentity left_zero;
Expand All @@ -181,6 +187,7 @@ namespace sym {
static constexpr auto associativity = Associativity::LEFT;
static constexpr bool commutative = false;
static constexpr bool associative = false;
static constexpr bool wrapped = true;
static inline std::string l_repr() { return ""; }
static inline std::string repr() { return "["; }
static inline std::string r_repr() { return "]"; }
Expand Down Expand Up @@ -446,7 +453,7 @@ namespace sym {
LHS_repr = detail::paren_wrap<Config>(LHS_repr);

std::string RHS_repr = repr<Config>(op._r);
if (this_BP.second > RHS_BP.first || Config::Force_parenthesis)
if (((this_BP.second > RHS_BP.first) && !Op::wrapped) || Config::Force_parenthesis)
RHS_repr = detail::paren_wrap<Config>(RHS_repr);

return (Config::Latex_output ? Op::l_latex_repr() : Op::l_repr())
Expand Down
Loading

0 comments on commit b21bd23

Please sign in to comment.