findPivot method
Implementation
int findPivot(Matrix T) {
int n = T.rowCount;
// Find the smallest off-diagonal element in the last row
int pivot = n - 2;
double minValue = (T[n - 1][n - 2] as num).toDouble().abs();
for (int i = n - 3; i >= 0; i--) {
double value = (T[n - 1][i] as num).toDouble().abs();
if (value < minValue) {
minValue = value;
pivot = i;
}
}
return pivot;
}