[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
Sat Jan 20 08:46:12 PST 2024
================
@@ -245,3 +245,270 @@ QuasiPolynomial mlir::presburger::detail::getCoefficientInRationalFunction(
}
return coefficients[power].simplify();
}
+
+static std::vector<Fraction> convolution(ArrayRef<Fraction> a,
+ ArrayRef<Fraction> b) {
+ // The length of the convolution is the sum of the lengths
+ // of the two sequences. We pad the shorter one with zeroes.
+ unsigned len = a.size() + b.size();
+
+ // We define accessors to avoid out-of-bounds errors.
+ std::function<Fraction(unsigned i)> aGetItem = [a](unsigned i) -> Fraction {
+ if (i < a.size())
+ return a[i];
+ else
+ return 0;
+ };
+ std::function<Fraction(unsigned i)> bGetItem = [b](unsigned i) -> Fraction {
+ if (i < b.size())
+ return b[i];
+ else
+ return 0;
+ };
----------------
Superty wrote:
just make one lambda, take the array as a param
https://github.com/llvm/llvm-project/pull/78078
More information about the Mlir-commits
mailing list