[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
Sun Jan 14 12:01:46 PST 2024
================
@@ -245,3 +245,253 @@ 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 convlen = std::max(a.size(), b.size());
+ for (unsigned k = a.size(); k < convlen; ++k)
+ a.push_back(0);
+ for (unsigned k = b.size(); k < convlen; ++k)
+ b.push_back(0);
+
+ std::vector<Fraction> convolution;
+ convolution.reserve(convlen);
+ convolution.clear();
+ for (unsigned k = 0; k < convlen; ++k) {
+ Fraction sum(0, 1);
+ for (unsigned l = 0; l <= k; ++l)
+ sum = 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,
+/// returning
+/// a quasipolynomial which represents the exponent of the numerator
+/// of the result, and
+/// a vector which represents the exponents of the denominator of the
+/// result.
----------------
Superty wrote:
explain what the representation you are substituting into is, in terms of v and ds
https://github.com/llvm/llvm-project/pull/78078
More information about the Mlir-commits
mailing list