@@ -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();
@@ -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();
@@ -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
@@ -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)
@@ -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/Abhinav271828 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