[Mlir-commits] [mlir] [MLIR][Presburger] Implement function to evaluate the number of terms in a generating function. (PR #78078)

Arjun P llvmlistbot at llvm.org
Tue Jan 16 16:28:05 PST 2024


================
@@ -245,3 +245,254 @@ QuasiPolynomial mlir::presburger::detail::getCoefficientInRationalFunction(
   }
   return coefficients[power].simplify();
 }
+
+static std::vector<Fraction> convolution(std::vector<Fraction> a,
+                                         std::vector<Fraction> b) {
+  // The length of the convolution is the maximum of the lengths
+  // of the two sequences. We pad the shorter one with zeroes.
+  unsigned len = a.size() + b.size();
+  a.resize(len);
+  b.resize(len);
+
+  std::vector<Fraction> convolution;
+  convolution.reserve(len);
+  for (unsigned k = 0; k < len; ++k) {
+    Fraction sum(0, 1);
+    for (unsigned l = 0; l <= k; ++l)
+      sum += a[l] * b[k - l];
+    convolution.push_back(sum);
+  }
+  return convolution;
+}
+
+/// Substitute x_i = (s+1)^μ_i in one term of a generating function,
----------------
Superty wrote:

This function just substitutes y^mu_i right? It doesn't really know about s+1. That is our reinterpretation/substitution in the other function.

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


More information about the Mlir-commits mailing list