[Mlir-commits] [mlir] [MLIR][Presburger] Add Gram-Schmidt (PR #70843)
Arjun P
llvmlistbot at llvm.org
Thu Nov 2 09:18:39 PDT 2023
================
@@ -548,4 +548,29 @@ Fraction FracMatrix::determinant(FracMatrix *inverse) const {
determinant *= m.at(i, i);
return determinant;
+}
+
+FracMatrix FracMatrix::gramSchmidt() const {
+ bool linIndep =
+ (nRows < nColumns) || (nRows == nColumns && determinant(nullptr) != 0);
+ assert(linIndep && "the vectors must be linearly independent!");
+
+ // Create a copy of the argument to store
+ // the orthogonalised version.
+ FracMatrix orth(*this);
+
+ // 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++) {
----------------
Superty wrote:
for (i = 1, e = getNumRows(); i < e; ++i)
https://github.com/llvm/llvm-project/pull/70843
More information about the Mlir-commits
mailing list