[Mlir-commits] [mlir] [MLIR][Presburger] Generating functions and quasi-polynomials for Barvinok's algorithm (PR #75702)
Arjun P
llvmlistbot at llvm.org
Thu Dec 21 06:17:37 PST 2023
================
@@ -71,6 +72,29 @@ inline void EXPECT_EQ_FRAC_MATRIX(FracMatrix a, FracMatrix b) {
EXPECT_EQ(a(row, col), b(row, col));
}
+// Check the coefficients (in order) of two quasipolynomials.
+// Note that this is not a true equality check.
+inline void EXPECT_EQ_QUASIPOLYNOMIAL(QuasiPolynomial a, QuasiPolynomial b) {
+ EXPECT_EQ(a.getNumParams(), b.getNumParams());
+
+ SmallVector<Fraction> aCoeffs = a.getCoefficients(),
+ bCoeffs = b.getCoefficients();
+ EXPECT_EQ(aCoeffs.size(), bCoeffs.size());
+ for (unsigned i = 0, e = aCoeffs.size(); i < e; i++)
+ EXPECT_EQ(aCoeffs[i], bCoeffs[i]);
+
+ std::vector<std::vector<SmallVector<Fraction>>> aAff = a.getAffine(),
+ bAff = b.getAffine();
+ EXPECT_EQ(aAff.size(), bAff.size());
+ for (unsigned i = 0, e = aAff.size(); i < e; i++) {
+ EXPECT_EQ(aAff[i].size(), bAff[i].size());
+ for (unsigned j = 0, f = aAff[i].size(); j < f; j++) {
----------------
Superty wrote:
So you can drop this brace. (but not the one above)
https://github.com/llvm/llvm-project/pull/75702
More information about the Mlir-commits
mailing list