Skip to content

Commit 6d2d304

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 ac6d4a6 commit 6d2d304

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Fraction &x) {
165165
return os;
166166
}
167167

168+
inline Fraction operator/(const Fraction &x, const Fraction &y) {
169+
return Fraction(x.num * y.den, x.den * y.num);
170+
}
171+
172+
inline Fraction operator+(const Fraction &x, const Fraction &y) {
173+
return Fraction(x.num * y.den + x.den * y.num, x.den * y.den);
174+
}
175+
176+
inline Fraction operator-(const Fraction &x, const Fraction &y) {
177+
return Fraction(x.num * y.den - x.den * y.num, x.den * y.den);
178+
}
179+
180+
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Fraction &x) {
181+
x.print(os);
182+
return os;
183+
}
184+
168185
} // namespace presburger
169186
} // namespace mlir
170187

0 commit comments

Comments
 (0)