Here you can find the source of maxIndices(double M[][])
public static int[] maxIndices(double M[][])
//package com.java2s; /*//from w w w . j a va 2s.c om * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * returns argmax_{j,k} M[j][k] */ public static int[] maxIndices(double M[][]) { double max = Double.MIN_VALUE; int i_max = -1; int j_max = -1; for (int i = 0; i < M.length; i++) { for (int j = 0; j < M[i].length; j++) { if (M[i][j] > max) { max = M[i][j]; i_max = i; j_max = j; } } } return new int[] { i_max, j_max }; } }