diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index becbefc867..b4ccaa5277 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -4193,6 +4193,21 @@ void System::identifyDependentGeometryParametersInTransposedJacobianDenseQRDecom } +void System::eliminateNonZerosOverPivotInUpperTriangularMatrix( Eigen::MatrixXd &R, int rank) +{ + for (int i=1; i < rank; i++) { + // eliminate non zeros above pivot + assert(R(i,i) != 0); + for (int row=0; row < i; row++) { + if (R(row,i) != 0) { + double coef=R(row,i)/R(i,i); + R.block(row,i+1,1,R.cols()-i-1) -= coef * R.block(i,i+1,1,R.cols()-i-1); + R(row,i) = 0; + } + } + } +} + template void System::identifyConflictingRedundantConstraints( Algorithm alg, const T & qrJT, @@ -4204,17 +4219,7 @@ void System::identifyConflictingRedundantConstraints( Algorithm alg, int &nonredundantconstrNum ) { - for (int i=1; i < rank; i++) { - // eliminate non zeros above pivot - assert(R(i,i) != 0); - for (int row=0; row < i; row++) { - if (R(row,i) != 0) { - double coef=R(row,i)/R(i,i); - R.block(row,i+1,1,constrNum-i-1) -= coef * R.block(i,i+1,1,constrNum-i-1); - R(row,i) = 0; - } - } - } + eliminateNonZerosOverPivotInUpperTriangularMatrix(R, rank); std::vector< std::vector > conflictGroups(constrNum-rank); for (int j=rank; j < constrNum; j++) { diff --git a/src/Mod/Sketcher/App/planegcs/GCS.h b/src/Mod/Sketcher/App/planegcs/GCS.h index 7442866f42..13d4ba852d 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.h +++ b/src/Mod/Sketcher/App/planegcs/GCS.h @@ -161,6 +161,7 @@ namespace GCS int &nonredundantconstrNum ); + void eliminateNonZerosOverPivotInUpperTriangularMatrix(Eigen::MatrixXd &R, int rank); #ifdef _GCS_EXTRACT_SOLVER_SUBSYSTEM_ void extractSubsystem(SubSystem *subsys, bool isRedundantsolving);