14 #ifndef MLIR_ANALYSIS_PRESBURGER_MATRIX_H 15 #define MLIR_ANALYSIS_PRESBURGER_MATRIX_H 18 #include "llvm/ADT/ArrayRef.h" 19 #include "llvm/Support/raw_ostream.h" 24 namespace presburger {
44 Matrix(
unsigned rows,
unsigned columns,
unsigned reservedRows = 0,
45 unsigned reservedColumns = 0);
51 int64_t &
at(
unsigned row,
unsigned column) {
52 assert(row < nRows &&
"Row outside of range");
53 assert(column < nColumns &&
"Column outside of range");
54 return data[row * nReservedColumns + column];
57 int64_t
at(
unsigned row,
unsigned column)
const {
58 assert(row < nRows &&
"Row outside of range");
59 assert(column < nColumns &&
"Column outside of range");
60 return data[row * nReservedColumns + column];
63 int64_t &
operator()(
unsigned row,
unsigned column) {
return at(row, column); }
65 int64_t
operator()(
unsigned row,
unsigned column)
const {
66 return at(row, column);
70 void swapColumns(
unsigned column,
unsigned otherColumn);
73 void swapRows(
unsigned row,
unsigned otherRow);
106 void insertRows(
unsigned pos,
unsigned count);
122 void removeRows(
unsigned pos,
unsigned count);
125 void copyRow(
unsigned sourceRow,
unsigned targetRow);
130 void addToRow(
unsigned sourceRow,
unsigned targetRow, int64_t scale);
133 void addToColumn(
unsigned sourceColumn,
unsigned targetColumn, int64_t scale);
164 void resize(
unsigned newNRows,
unsigned newNColumns);
175 void print(raw_ostream &os)
const;
187 unsigned nRows, nColumns, nReservedColumns;
197 #endif // MLIR_ANALYSIS_PRESBURGER_MATRIX_H int64_t normalizeRow(unsigned row, unsigned nCols)
Divide the first nCols of the specified row by their GCD.
Include the generated interface declarations.
void insertColumn(unsigned pos)
bool hasConsistentState() const
Return whether the Matrix is in a consistent state with all its invariants satisfied.
void resizeHorizontally(unsigned newNColumns)
void removeRows(unsigned pos, unsigned count)
Remove the rows having positions pos, pos + 1, ...
unsigned getNumRows() const
void insertRows(unsigned pos, unsigned count)
Insert rows having positions pos, pos + 1, ...
void fillRow(unsigned row, int64_t value)
void addToColumn(unsigned sourceColumn, unsigned targetColumn, int64_t scale)
Add scale multiples of the source column to the target column.
void removeColumn(unsigned pos)
This is a class to represent a resizable matrix.
void reserveRows(unsigned rows)
Reserve enough space to resize to the specified number of rows without reallocations.
static Matrix identity(unsigned dimension)
Return the identity matrix of the specified dimension.
static constexpr const bool value
void swapColumns(unsigned column, unsigned otherColumn)
Swap the given columns.
void copyRow(unsigned sourceRow, unsigned targetRow)
void insertColumns(unsigned pos, unsigned count)
Insert columns having positions pos, pos + 1, ...
void removeRow(unsigned pos)
int64_t operator()(unsigned row, unsigned column) const
unsigned getNumReservedRows() const
Return the maximum number of rows/columns that can be added without incurring a reallocation.
void addToRow(unsigned sourceRow, unsigned targetRow, int64_t scale)
Add scale multiples of the source row to the target row.
unsigned appendExtraRow()
Add an extra row at the bottom of the matrix and return its position.
SmallVector< int64_t, 8 > postMultiplyWithColumn(ArrayRef< int64_t > colVec) const
The given vector is interpreted as a column vector v.
void negateRow(unsigned row)
Negate the specified row.
void resizeVertically(unsigned newNRows)
void setRow(unsigned row, ArrayRef< int64_t > elems)
Set the specified row to elems.
unsigned getNumColumns() const
int64_t & at(unsigned row, unsigned column)
Access the element at the specified row and column.
MutableArrayRef< int64_t > getRow(unsigned row)
Get a [Mutable]ArrayRef corresponding to the specified row.
void resize(unsigned newNRows, unsigned newNColumns)
Resize the matrix to the specified dimensions.
void swapRows(unsigned row, unsigned otherRow)
Swap the given rows.
void insertRow(unsigned pos)
int64_t at(unsigned row, unsigned column) const
int64_t & operator()(unsigned row, unsigned column)
SmallVector< int64_t, 8 > preMultiplyWithRow(ArrayRef< int64_t > rowVec) const
The given vector is interpreted as a row vector v.
void print(raw_ostream &os) const
Print the matrix.
unsigned getNumReservedColumns() const
void negateColumn(unsigned column)
Negate the specified column.
void removeColumns(unsigned pos, unsigned count)
Remove the columns having positions pos, pos + 1, ...