minIndex function
Find the index of the maximum value in the matrix
matrixThe matrix to find the maximum value index- Returns A list containing the row and column index of the maximum value
Implementation
List<int> minIndex(Matrix matrix) {
int maxRow = 0;
int maxCol = 0;
double minValue = matrix.getAt(0, 0);
for (int i = 0; i < matrix.row; i++) {
for (int j = 0; j < matrix.col; j++) {
double currentValue = matrix.getAt(i, j);
if (currentValue < minValue) {
minValue = currentValue;
maxRow = i;
maxCol = j;
}
}
}
return [maxRow, maxCol];
}