[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


================
@@ -377,4 +377,51 @@ TEST(MatrixTest, gramSchmidt) {
   gs = mat.gramSchmidt();
 
   EXPECT_EQ_FRAC_MATRIX(gs, FracMatrix::identity(10));
+}
+
+void checkReducedBasis(FracMatrix mat, Fraction delta) {
+  FracMatrix gsOrth = mat.gramSchmidt();
+
+  // Size-reduced check.
+  for (unsigned i = 0; i < mat.getNumRows(); i++)
+    for (unsigned j = 0; j < i; j++) {
+      Fraction mu = dotProduct(mat.getRow(i), gsOrth.getRow(j)) /
+                    dotProduct(gsOrth.getRow(j), gsOrth.getRow(j));
+      ASSERT_TRUE(abs(mu) <= Fraction(1, 2));
+    }
+
+  // Lovasz condition check.
+  for (unsigned i = 1; i < mat.getNumRows(); i++) {
+    Fraction mu = dotProduct(mat.getRow(i), gsOrth.getRow(i - 1)) /
+                  dotProduct(gsOrth.getRow(i - 1), gsOrth.getRow(i - 1));
+    ASSERT_TRUE(dotProduct(mat.getRow(i), mat.getRow(i)) >
----------------
Superty wrote:

Just EXPECT_TRUE. I think ASSERT will prevent later LLL tests from running

https://github.com/llvm/llvm-project/pull/75565


More information about the Mlir-commits mailing list