//===- Matrix.h - MLIR Matrix Class -----------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This is a simple 2D matrix class that supports reading, writing, resizing, // swapping rows, and swapping columns. It can hold integers (DynamicAPInt) or // rational numbers (Fraction). // //===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_PRESBURGER_MATRIX_H #define MLIR_ANALYSIS_PRESBURGER_MATRIX_H #include "mlir/Analysis/Presburger/Fraction.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/raw_ostream.h" #include <cassert> namespace mlir { namespace presburger { ArrayRef; MutableArrayRef; raw_ostream; SmallVector; /// This is a class to represent a resizable matrix. /// /// More columns and rows can be reserved than are currently used. The data is /// stored as a single 1D array, viewed as a 2D matrix with nRows rows and /// nReservedColumns columns, stored in row major form. Thus the element at /// (i, j) is stored at data[i*nReservedColumns + j]. The reserved but unused /// columns always have all zero values. The reserved rows are just reserved /// space in the underlying SmallVector's capacity. /// This class only works for the types DynamicAPInt and Fraction, since the /// method implementations are in the Matrix.cpp file. Only these two types have /// been explicitly instantiated there. template <typename T> class Matrix { … }; extern template class Matrix<DynamicAPInt>; extern template class Matrix<Fraction>; // An inherited class for integer matrices, with no new data attributes. // This is only used for the matrix-related methods which apply only // to integers (hermite normal form computation and row normalisation). class IntMatrix : public Matrix<DynamicAPInt> { … }; // An inherited class for rational matrices, with no new data attributes. // This class is for functionality that only applies to matrices of fractions. class FracMatrix : public Matrix<Fraction> { … }; } // namespace presburger } // namespace mlir #endif // MLIR_ANALYSIS_PRESBURGER_MATRIX_H