Here you can find the source of maxInRowIndex(double[][] M, int row)
Parameter | Description |
---|---|
M | matrix (2-dimensional array of type <code>double</code>). |
row | row index. |
public static int maxInRowIndex(double[][] M, int row)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w.j a v a 2 s. c om*/ * Returns the row index of the maximal element in the given row of the given matrix. * @param M matrix (2-dimensional array of type <code>double</code>). * @param row row index. * @return index of the element in the row. */ public static int maxInRowIndex(double[][] M, int row) { int idx = -1; if (M == null) return idx; int m = M.length; int n = M[0].length; if ((row < 0) || (row >= m)) return idx; idx = 0; for (int i = 1; i < n; i++) if (M[row][i] > M[row][idx]) idx = i; return idx; } }