Skip to content

Commit

Permalink
Add debug traces for RCA of expression comparison failure
Browse files Browse the repository at this point in the history
Co-Authored-By: Serg Kryvonos <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and ohhmm committed Feb 10, 2025
1 parent 06d12ef commit 98085b0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
31 changes: 29 additions & 2 deletions omnn/math/Exponentiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,21 +843,48 @@ using namespace omnn::math;
}

bool Exponentiation::operator==(const Exponentiation& other) const {
return base::operator ==(other);
std::cout << "\n=== Exponentiation::operator==(Exponentiation) Debug ===" << std::endl;
std::cout << "Left base: " << ebase() << " (type: " << typeid(ebase()).name() << ")" << std::endl;

Check failure on line 847 in omnn/math/Exponentiation.cpp

View workflow job for this annotation

GitHub Actions / build (macos-latest)

expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Werror,-Wpotentially-evaluated-expression]
std::cout << "Right base: " << other.ebase() << " (type: " << typeid(other.ebase()).name() << ")" << std::endl;

Check failure on line 848 in omnn/math/Exponentiation.cpp

View workflow job for this annotation

GitHub Actions / build (macos-latest)

expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Werror,-Wpotentially-evaluated-expression]
std::cout << "Left exp: " << eexp() << " (type: " << typeid(eexp()).name() << ")" << std::endl;

Check failure on line 849 in omnn/math/Exponentiation.cpp

View workflow job for this annotation

GitHub Actions / build (macos-latest)

expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Werror,-Wpotentially-evaluated-expression]
std::cout << "Right exp: " << other.eexp() << " (type: " << typeid(other.eexp()).name() << ")" << std::endl;

Check failure on line 850 in omnn/math/Exponentiation.cpp

View workflow job for this annotation

GitHub Actions / build (macos-latest)

expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Werror,-Wpotentially-evaluated-expression]

bool result = base::operator==(other);
std::cout << "=== Result: " << (result ? "equal" : "not equal") << " ===" << std::endl;
return result;
}

bool Exponentiation::operator==(const Valuable& v) const
{
std::cout << "\n=== Exponentiation::operator== Debug ===" << std::endl;
std::cout << "Left: " << *this << " (type: " << typeid(*this).name() << ")" << std::endl;
std::cout << "Right: " << v << " (type: " << typeid(v).name() << ")" << std::endl;

auto eq = v.IsExponentiation();
std::cout << "Is right side Exponentiation? " << (eq ? "yes" : "no") << std::endl;

if(eq){
std::cout << "Comparing as Exponentiation" << std::endl;
std::cout << "Base: " << ebase() << " vs " << v.as<Exponentiation>().ebase() << std::endl;
std::cout << "Exp: " << eexp() << " vs " << v.as<Exponentiation>().eexp() << std::endl;
eq = operator==(v.as<Exponentiation>());
std::cout << "Result: " << (eq ? "equal" : "not equal") << std::endl;
} else if (v.IsFraction()) {
std::cout << "Comparing with Fraction" << std::endl;
std::cout << "Exp is int/simple fraction? " << ((eexp().IsInt() || eexp().IsSimpleFraction()) ? "yes" : "no") << std::endl;
std::cout << "Exp < 0? " << (eexp() < 0 ? "yes" : "no") << std::endl;
auto recip = v.Reciprocal() ^ (-eexp());
std::cout << "Base == reciprocal^(-exp)? " << (ebase() == recip ? "yes" : "no") << std::endl;
eq = (eexp().IsInt() || eexp().IsSimpleFraction())
&& eexp() < 0
&& ebase() == (v.Reciprocal() ^ (-eexp()));
&& ebase() == recip;
std::cout << "Result: " << (eq ? "equal" : "not equal") << std::endl;
} else if (v.IsProduct() || v.IsSum()) {
std::cout << "Comparing with Product/Sum" << std::endl;
eq = v.operator==(*this);
std::cout << "Result: " << (eq ? "equal" : "not equal") << std::endl;
}
std::cout << "=== Final Result: " << (eq ? "equal" : "not equal") << " ===" << std::endl;
return eq;
}

Expand Down
9 changes: 8 additions & 1 deletion omnn/math/Logarithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ Logarithm::operator double() const {
Valuable& Logarithm::d(const Variable& x) {
// For natural logarithm (base e), d/dx(ln(x)) = 1/x
if (_1.Is_e() && _2 == x) {
return Become(Exponentiation(x, -1));
std::cout << "\n=== Logarithm::d Debug ===" << std::endl;
std::cout << "Calculating d/dx(ln(x))" << std::endl;
std::cout << "Base is e? " << (_1.Is_e() ? "yes" : "no") << std::endl;
std::cout << "Argument equals x? " << (_2 == x ? "yes" : "no") << std::endl;
auto result = Exponentiation(x, -1);
std::cout << "Creating result: " << result << std::endl;
std::cout << "=== End Logarithm::d Debug ===" << std::endl;
return Become(std::move(result));
}
// For natural logarithm (base e), d/dx(ln(u)) = (1/u) * du/dx
if (_1.Is_e()) {
Expand Down

0 comments on commit 98085b0

Please sign in to comment.