[MLIR][Presburger] add a non-const Matrix::getRow() returning a MutableArrayRef

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D122136
This commit is contained in:
Arjun P 2022-03-17 22:20:42 +00:00
parent b9959590d4
commit d98dfdea17
2 changed files with 6 additions and 1 deletions

View File

@ -72,7 +72,8 @@ public:
/// reallocations. /// reallocations.
void reserveRows(unsigned rows); void reserveRows(unsigned rows);
/// Get an ArrayRef corresponding to the specified row. /// Get a [Mutable]ArrayRef corresponding to the specified row.
MutableArrayRef<int64_t> getRow(unsigned row);
ArrayRef<int64_t> getRow(unsigned row) const; ArrayRef<int64_t> getRow(unsigned row) const;
/// Insert columns having positions pos, pos + 1, ... pos + count - 1. /// Insert columns having positions pos, pos + 1, ... pos + count - 1.

View File

@ -101,6 +101,10 @@ void Matrix::swapColumns(unsigned column, unsigned otherColumn) {
std::swap(at(row, column), at(row, otherColumn)); std::swap(at(row, column), at(row, otherColumn));
} }
MutableArrayRef<int64_t> Matrix::getRow(unsigned row) {
return {&data[row * nReservedColumns], nColumns};
}
ArrayRef<int64_t> Matrix::getRow(unsigned row) const { ArrayRef<int64_t> Matrix::getRow(unsigned row) const {
return {&data[row * nReservedColumns], nColumns}; return {&data[row * nReservedColumns], nColumns};
} }