[Mlir-commits] [mlir] [MLIR][Presburger] Add Gram-Schmidt (PR #70843)
Arjun P
llvmlistbot at llvm.org
Tue Oct 31 11:19:14 PDT 2023
================
@@ -548,4 +548,27 @@ Fraction FracMatrix::determinant(FracMatrix *inverse) const {
determinant *= m.at(i, i);
return determinant;
+}
+
+FracMatrix FracMatrix::gramSchmidt() const {
+
+ // Create a copy of the argument to store
+ // the orthogonalised version.
+ FracMatrix orth(*this);
+ Fraction projectionScale;
+
+ // For each vector (row) in the matrix,
+ // subtract its unit projection along
+ // each of the previous vectors.
+ // This ensures that it has no component
+ // in the direction of any of the
+ // previous vectors.
+ for (unsigned i = 1; i < getNumRows(); i++) {
+ for (unsigned j = 0; j < i; j++) {
+ projectionScale = dotProduct(orth.getRow(i), orth.getRow(j)) /
+ dotProduct(orth.getRow(j), orth.getRow(j));
----------------
Superty wrote:
what happens if some row becomes zero?
https://github.com/llvm/llvm-project/pull/70843
More information about the Mlir-commits
mailing list