Skip to content

Commit

Permalink
Fix Modulo::IsComesBefore implementation to provide consistent ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] authored and ohhmm committed Feb 14, 2025
1 parent f25583e commit ab1f810
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions omnn/math/Modulo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,13 @@ Valuable& Modulo::sq() {
}

bool Modulo::IsComesBefore(const Modulo& mod) const {
auto& modDividend = mod.getDividend();
auto equalDividends = getDividend() == modDividend;
if (equalDividends) {
// First compare divisors (Y^4 in both cases)
if (getDevisor() != mod.getDevisor()) {
return getDevisor().IsComesBefore(mod.getDevisor());
}
auto equalDivisors = getDevisor() == mod.getDevisor();
if (equalDivisors) {
return getDividend().IsComesBefore(modDividend);
}
auto is = _1.IsComesBefore(modDividend);
if (!is) {
is = _1 == modDividend && mod.get2().IsComesBefore(_2);
}
return is;

// If divisors are equal, compare dividends (1 vs -4*Y^3)
return getDividend().IsComesBefore(mod.getDividend());
}

bool Modulo::IsComesBefore(const Valuable& v) const
Expand Down

0 comments on commit ab1f810

Please sign in to comment.