Skip to content

Commit ac6d4a6

Browse files
committed
Template Matrix to Matrix<T> (for MPInt and Fraction) with explicit instantiation
Duplicate makeMatrix to makeIntMatrix and makeFracMatrix Implement arithmetic operations for Fraction for compatibility
1 parent 24bee0e commit ac6d4a6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mlir/include/mlir/Analysis/Presburger/Fraction.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define MLIR_ANALYSIS_PRESBURGER_FRACTION_H
1616

1717
#include "mlir/Analysis/Presburger/MPInt.h"
18+
#include "mlir/Analysis/Presburger/Utils.h"
1819
#include "mlir/Support/MathExtras.h"
1920

2021
namespace mlir {
@@ -147,6 +148,23 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Fraction &x) {
147148
return os;
148149
}
149150

151+
inline Fraction operator/(const Fraction &x, const Fraction &y) {
152+
return Fraction(x.num * y.den, x.den * y.num);
153+
}
154+
155+
inline Fraction operator+(const Fraction &x, const Fraction &y) {
156+
return Fraction(x.num * y.den + x.den * y.num, x.den * y.den);
157+
}
158+
159+
inline Fraction operator-(const Fraction &x, const Fraction &y) {
160+
return Fraction(x.num * y.den - x.den * y.num, x.den * y.den);
161+
}
162+
163+
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Fraction &x) {
164+
x.print(os);
165+
return os;
166+
}
167+
150168
} // namespace presburger
151169
} // namespace mlir
152170

0 commit comments

Comments
 (0)