Fix matrix inverse pivotting logic.

This commit is contained in:
James Goppert
2016-11-22 10:04:45 -05:00
parent 34fccdd680
commit f3e478cbff
2 changed files with 43 additions and 4 deletions
+4 -4
View File
@@ -128,16 +128,16 @@ SquareMatrix <Type, M> inv(const SquareMatrix<Type, M> & A)
// if diagonal is zero, swap with row below
if (fabsf(U(n, n)) < 1e-8f) {
//printf("trying pivot for row %d\n",n);
for (size_t i = 0; i < M; i++) {
if (i == n) {
continue;
}
for (size_t i = n + 1; i < M; i++) {
//printf("\ttrying row %d\n",i);
if (fabsf(U(i, n)) > 1e-8f) {
//printf("swapped %d\n",i);
U.swapRows(i, n);
P.swapRows(i, n);
L.swapRows(i, n);
L.swapCols(i, n);
break;
}
}
}