Commit c54342d7 by Tim Gymnich

### fixed span efficiency

parent cdd89b09
 ... @@ -161,8 +161,8 @@ bool AffineRelation::leastUpperBound(AffineRelation const& rhs) { ... @@ -161,8 +161,8 @@ bool AffineRelation::leastUpperBound(AffineRelation const& rhs) { vectors.push_back(m.toVector()); vectors.push_back(m.toVector()); } } // FIXME: i think this is transposing it twice. Maybe create a fast path for this kind of thing. // FIXME: i think this is transposing it twice. Maybe create a fast path for this kind of thing. Matrix combined = Matrix(vectors).transpose(); Matrix combined = Matrix(vectors); Matrix result = Matrix::span(combined); Matrix result = Matrix::span(combined, true); basis = result.reshapeColumns(basis.front().getHeight(), basis.front().getWidth()); basis = result.reshapeColumns(basis.front().getHeight(), basis.front().getWidth()); // FIXME: figure out a better way to detect changes // FIXME: figure out a better way to detect changes ... @@ -182,8 +182,8 @@ void AffineRelation::affineAssignment(Value const* xi, unordered_map vector = Matrix(Wr.toVector()).transpose(); Matrix vector = Matrix(Wr.toVector()); Matrix vectorSpan = Matrix::span(vector); Matrix vectorSpan = Matrix::span(vector, true); Wr = vectorSpan.reshape(Wr.getHeight(), Wr.getWidth()); Wr = vectorSpan.reshape(Wr.getHeight(), Wr.getWidth()); for (Matrix& matrix: basis) { for (Matrix& matrix: basis) { ... @@ -217,8 +217,8 @@ void AffineRelation::nonDeterminsticAssignment(Value const* xi) { ... @@ -217,8 +217,8 @@ void AffineRelation::nonDeterminsticAssignment(Value const* xi) { assignment_vectors.push_back(T0.toVector()); assignment_vectors.push_back(T0.toVector()); assignment_vectors.push_back(T1.toVector()); assignment_vectors.push_back(T1.toVector()); Matrix combined = Matrix(assignment_vectors).transpose(); Matrix combined = Matrix(assignment_vectors); Matrix result = Matrix::span(combined); Matrix result = Matrix::span(combined, true); vector> span = result.reshapeColumns(T0.getHeight(), T0.getWidth()); vector> span = result.reshapeColumns(T0.getHeight(), T0.getWidth()); ... ...
 ... @@ -150,9 +150,11 @@ public: ... @@ -150,9 +150,11 @@ public: } } /// Basis of the linear span of the column vectors /// Basis of the linear span of the column vectors static Matrix span(Matrix const& matrix) { static Matrix span(Matrix const& matrix, bool transposed = false) { std::vector> rows; std::vector> rows; Matrix te = matrix.transpose().echelonForm(); // if matrix is already transposed don't do it again Matrix t = transposed ? matrix : matrix.transpose(); Matrix te = t.echelonForm(); int rank = te.getRank(); int rank = te.getRank(); rows.reserve(rank); rows.reserve(rank); for (int row = 0; row < rank; row++) { for (int row = 0; row < rank; row++) { ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!