[Mlir-commits] [mlir] [MLIR][Presburger] Template Matrix to allow MPInt and Fraction and separate out IntMatrix (PR #66897)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Sep 20 06:17:33 PDT 2023


================
@@ -267,12 +259,53 @@ static void modEntryColumnOperation(Matrix<MPInt> &m, unsigned row, unsigned sou
   otherMatrix.addToColumn(sourceCol, targetCol, ratio);
 }
 
-template <> std::pair<Matrix<MPInt>, Matrix<MPInt>> Matrix<MPInt>::computeHermiteNormalForm() const {
+template <typename T> void Matrix<T>::print(raw_ostream &os) const {
+  for (unsigned row = 0; row < nRows; ++row) {
+    for (unsigned column = 0; column < nColumns; ++column)
+      os << at(row, column) << ' ';
+    os << '\n';
+  }
+}
+
+template <typename T> void Matrix<T>::dump() const { print(llvm::errs()); }
+
+template <typename T> bool Matrix<T>::hasConsistentState() const {
+  if (data.size() != nRows * nReservedColumns)
+    return false;
+  if (nColumns > nReservedColumns)
+    return false;
+#ifdef EXPENSIVE_CHECKS
+  for (unsigned r = 0; r < nRows; ++r)
+    for (unsigned c = nColumns; c < nReservedColumns; ++c)
+      if (data[r * nReservedColumns + c] != 0)
+        return false;
+#endif
+  return true;
+}
+
+namespace mlir
+{
+namespace presburger
+{
----------------
Abhinav271828 wrote:

Done!

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


More information about the Mlir-commits mailing list