Lines Matching full:matrix

1 //===- Matrix.cpp - MLIR Matrix Class -------------------------------------===//
9 #include "mlir/Analysis/Presburger/Matrix.h"
22 Matrix<T>::Matrix(unsigned rows, unsigned columns, unsigned reservedRows,
33 bool Matrix<T>::operator==(const Matrix<T> &m) const {
47 Matrix<T> Matrix<T>::identity(unsigned dimension) {
48 Matrix matrix(dimension, dimension);
50 matrix(i, i) = 1;
51 return matrix;
55 unsigned Matrix<T>::getNumReservedRows() const {
60 void Matrix<T>::reserveRows(unsigned rows) {
65 unsigned Matrix<T>::appendExtraRow() {
71 unsigned Matrix<T>::appendExtraRow(ArrayRef<T> elems) {
80 Matrix<T> Matrix<T>::transpose() const {
81 Matrix<T> transp(nColumns, nRows);
90 void Matrix<T>::resizeHorizontally(unsigned newNColumns) {
98 void Matrix<T>::resize(unsigned newNRows, unsigned newNColumns) {
104 void Matrix<T>::resizeVertically(unsigned newNRows) {
110 void Matrix<T>::swapRows(unsigned row, unsigned otherRow) {
120 void Matrix<T>::swapColumns(unsigned column, unsigned otherColumn) {
130 MutableArrayRef<T> Matrix<T>::getRow(unsigned row) {
135 ArrayRef<T> Matrix<T>::getRow(unsigned row) const {
140 void Matrix<T>::setRow(unsigned row, ArrayRef<T> elems) {
148 void Matrix<T>::insertColumn(unsigned pos) {
152 void Matrix<T>::insertColumns(unsigned pos, unsigned count) {
194 void Matrix<T>::removeColumn(unsigned pos) {
198 void Matrix<T>::removeColumns(unsigned pos, unsigned count) {
212 void Matrix<T>::insertRow(unsigned pos) {
216 void Matrix<T>::insertRows(unsigned pos, unsigned count) {
230 void Matrix<T>::removeRow(unsigned pos) {
234 void Matrix<T>::removeRows(unsigned pos, unsigned count) {
244 void Matrix<T>::copyRow(unsigned sourceRow, unsigned targetRow) {
252 void Matrix<T>::fillRow(unsigned row, const T &value) {
266 void Matrix<T>::moveColumns(unsigned srcPos, unsigned num, unsigned dstPos) {
275 "move source range exceeds matrix columns");
277 "move destination range exceeds matrix columns");
299 void Matrix<T>::addToRow(unsigned sourceRow, unsigned targetRow,
305 void Matrix<T>::addToRow(unsigned row, ArrayRef<T> rowVec, const T &scale) {
313 void Matrix<T>::scaleRow(unsigned row, const T &scale) {
319 void Matrix<T>::addToColumn(unsigned sourceColumn, unsigned targetColumn,
328 void Matrix<T>::negateColumn(unsigned column) {
334 void Matrix<T>::negateRow(unsigned row) {
340 void Matrix<T>::negateMatrix() {
346 SmallVector<T, 8> Matrix<T>::preMultiplyWithRow(ArrayRef<T> rowVec) const {
357 SmallVector<T, 8> Matrix<T>::postMultiplyWithColumn(ArrayRef<T> colVec) const {
373 static void modEntryColumnOperation(Matrix<DynamicAPInt> &m, unsigned row,
375 Matrix<DynamicAPInt> &otherMatrix) {
384 Matrix<T> Matrix<T>::getSubMatrix(unsigned fromRow, unsigned toRow,
392 Matrix<T> subMatrix(toRow - fromRow + 1, toColumn - fromColumn + 1);
400 void Matrix<T>::print(raw_ostream &os) const {
415 /// we append it to one matrix, and if it is zero, we append it to the other.
417 std::pair<Matrix<T>, Matrix<T>>
418 Matrix<T>::splitByBitset(ArrayRef<int> indicator) {
419 Matrix<T> rowsForOne(0, nColumns), rowsForZero(0, nColumns);
430 void Matrix<T>::dump() const {
435 bool Matrix<T>::hasConsistentState() const {
451 template class Matrix<DynamicAPInt>;
452 template class Matrix<Fraction>;
457 IntMatrix matrix(dimension, dimension);
459 matrix(i, i) = 1;
460 return matrix;
464 // We start with u as an identity matrix and perform operations on h until h
581 return Matrix::identity(dimension);
601 // Make the matrix into upper triangular form using
604 // to turn the matrix into diagonal form. We apply
605 // the same operations to the inverse matrix,
659 // normalize them and apply the same scale to the inverse matrix.
681 // For each vector (row) in the matrix, subtract its unit
698 // Convert the matrix, interpreted (row-wise) as a basis
729 // of the matrix at all times. It is recomputed every
730 // time the matrix is modified during the algorithm.