https://github.com/Superty edited
https://github.com/llvm/llvm-project/pull/95715
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -104,8 +104,9 @@ Simplex::Unknown &SimplexBase::unknownFromRow(unsigned row)
{
unsigned SimplexBase::addZeroRow(bool makeRestricted) {
// Resize the tableau to accommodate the extra row.
+ unsigned oldNumRows = getNumRows();
unsigned newRow = tableau.appendExtraRow()
@@ -104,8 +104,9 @@ Simplex::Unknown &SimplexBase::unknownFromRow(unsigned row)
{
unsigned SimplexBase::addZeroRow(bool makeRestricted) {
// Resize the tableau to accommodate the extra row.
+ unsigned oldNumRows = getNumRows();
unsigned newRow = tableau.appendExtraRow()
https://github.com/Superty approved this pull request.
https://github.com/llvm/llvm-project/pull/95373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -432,4 +432,138 @@ MPInt IntMatrix::normalizeRow(unsigned row, unsigned
cols) {
MPInt IntMatrix::normalizeRow(unsigned row) {
return normalizeRow(row, getNumColumns());
+}
+
+MPInt IntMatrix::determinant() {
+ unsigned r = getNumRows();
+ unsigned c = getNumColumns();
@@ -390,4 +463,83 @@ MPInt IntMatrix::normalizeRow(unsigned row, unsigned cols)
{
MPInt IntMatrix::normalizeRow(unsigned row) {
return normalizeRow(row, getNumColumns());
+}
+
+std::optional IntMatrix::integerInverse() {
+ Fraction det = Fraction(determinant(), 1);
+ Frac
@@ -390,4 +463,83 @@ MPInt IntMatrix::normalizeRow(unsigned row, unsigned cols)
{
MPInt IntMatrix::normalizeRow(unsigned row) {
return normalizeRow(row, getNumColumns());
+}
+
+std::optional IntMatrix::integerInverse() {
+ Fraction det = Fraction(determinant(), 1);
+ Frac
https://github.com/Superty requested changes to this pull request.
https://github.com/llvm/llvm-project/pull/67382
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -283,12 +326,43 @@ template bool
Matrix::hasConsistentState() const {
return true;
}
+template
+T Matrix::determinant() {
+ unsigned r = getNumRows();
+ unsigned c = getNumColumns();
+ if (r == 1)
+return at(0, 0);
+ if (r == 2)
+return (at(0, 0) * at(1, 1)
@@ -390,4 +463,83 @@ MPInt IntMatrix::normalizeRow(unsigned row, unsigned cols)
{
MPInt IntMatrix::normalizeRow(unsigned row) {
return normalizeRow(row, getNumColumns());
+}
+
+std::optional IntMatrix::integerInverse() {
+ Fraction det = Fraction(determinant(), 1);
+ Frac
@@ -241,6 +245,32 @@ class IntMatrix : public Matrix
/// Returns the GCD of the columns of the specified row.
MPInt normalizeRow(unsigned row);
+ // Return the integer inverse of the matrix, leaving the calling object
+ // unmodified.
+ std::optional integerInverse();
+
https://github.com/Superty closed
https://github.com/llvm/llvm-project/pull/68298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Superty wrote:
Thanks!
https://github.com/llvm/llvm-project/pull/68298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Superty wrote:
Thanks!
https://github.com/llvm/llvm-project/pull/68298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/Superty closed
https://github.com/llvm/llvm-project/pull/68298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,51 @@
+#include "mlir/Analysis/Presburger/Fraction.h"
+#include "./Utils.h"
+#include
+#include
+
+using namespace mlir;
+using namespace presburger;
+
+TEST(FractionTest, getAsInteger) {
+ Fraction f(3, 1);
+ EXPECT_EQ(f.getAsInteger(), MPInt(3));
+}
+
+TEST(Fracti
https://github.com/Superty requested changes to this pull request.
https://github.com/llvm/llvm-project/pull/68298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,51 @@
+#include "mlir/Analysis/Presburger/Fraction.h"
+#include "./Utils.h"
+#include
+#include
+
+using namespace mlir;
+using namespace presburger;
+
+TEST(FractionTest, getAsInteger) {
+ Fraction f(3, 1);
+ EXPECT_EQ(f.getAsInteger(), MPInt(3));
+}
+
+TEST(Fracti
https://github.com/Superty edited
https://github.com/llvm/llvm-project/pull/68298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,51 @@
+#include "mlir/Analysis/Presburger/Fraction.h"
+#include "./Utils.h"
+#include
+#include
+
+using namespace mlir;
+using namespace presburger;
+
+TEST(FractionTest, getAsInteger) {
+ Fraction f(3, 1);
+ EXPECT_EQ(f.getAsInteger(), MPInt(3));
+}
+
+TEST(Fracti
@@ -0,0 +1,51 @@
+#include "mlir/Analysis/Presburger/Fraction.h"
+#include "./Utils.h"
+#include
+#include
+
+using namespace mlir;
+using namespace presburger;
+
+TEST(FractionTest, getAsInteger) {
+ Fraction f(3, 1);
+ EXPECT_EQ(f.getAsInteger(), MPInt(3));
+}
+
+TEST(Fracti
https://github.com/Superty requested changes to this pull request.
https://github.com/llvm/llvm-project/pull/68298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Superty wrote:
By the way, what happens if the inverse doesn't exist?
https://github.com/llvm/llvm-project/pull/67382
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Superty wrote:
By the way, what happens if the inverse doesn't exist?
https://github.com/llvm/llvm-project/pull/67382
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Superty wrote:
By the way, what happens if the inverse doesn't exist?
https://github.com/llvm/llvm-project/pull/67382
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/Superty requested changes to this pull request.
https://github.com/llvm/llvm-project/pull/67382
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -102,7 +102,7 @@ inline bool operator>=(const Fraction &x, const Fraction
&y) {
inline Fraction reduce(const Fraction &f) {
if (f == Fraction(0))
return Fraction(0, 1);
- MPInt g = gcd(f.num, f.den);
+ MPInt g = gcd(abs(f.num), abs(f.den));
return Fraction(f.num
@@ -390,4 +390,68 @@ MPInt IntMatrix::normalizeRow(unsigned row, unsigned cols)
{
MPInt IntMatrix::normalizeRow(unsigned row) {
return normalizeRow(row, getNumColumns());
+}
+
+FracMatrix FracMatrix::identity(unsigned dimension) {
+ FracMatrix matrix(dimension, dimension);
@@ -244,6 +244,31 @@ class IntMatrix : public Matrix
};
+// An inherited class for rational matrices, with no new data attributes.
+// This is only used for the matrix-related method which apply only
+// to fractions (inverse).
Superty wrote:
"This class is
https://github.com/Superty edited
https://github.com/llvm/llvm-project/pull/67382
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/Superty requested changes to this pull request.
https://github.com/llvm/llvm-project/pull/67382
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -102,7 +102,7 @@ inline bool operator>=(const Fraction &x, const Fraction
&y) {
inline Fraction reduce(const Fraction &f) {
if (f == Fraction(0))
return Fraction(0, 1);
- MPInt g = gcd(f.num, f.den);
+ MPInt g = gcd(abs(f.num), abs(f.den));
return Fraction(f.num
32 matches
Mail list logo