[Mlir-commits] [mlir] [MLIR][Presburger] Add LLL basis reduction (PR #75565)
Arjun P
llvmlistbot at llvm.org
Sat Dec 16 13:00:16 PST 2023
================
@@ -124,6 +129,14 @@ inline Fraction operator-(const Fraction &x, const Fraction &y) {
return reduce(Fraction(x.num * y.den - x.den * y.num, x.den * y.den));
}
+// Find the integer nearest to a given fraction.
+inline MPInt round(const Fraction &f) {
+ MPInt rem = f.num % f.den;
+ if (rem < Fraction(f.den, 2))
----------------
Superty wrote:
this is equivalent to `rem < f.den/2` which would be faster
https://github.com/llvm/llvm-project/pull/75565
More information about the Mlir-commits
mailing list