Java Matrix Max Value maxInRowIndex(double[][] M, int row)

Here you can find the source of maxInRowIndex(double[][] M, int row)

Description

Returns the row index of the maximal element in the given row of the given matrix.

License

Open Source License

Parameter

Parameter Description
M matrix (2-dimensional array of type <code>double</code>).
row row index.

Return

index of the element in the row.

Declaration

public static int maxInRowIndex(double[][] M, int row) 

Method Source Code

//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;
    }
}

Related

  1. max(float[][] originalValues, float[][] newValues, int[] indexArray, float value)
  2. max_abs(double[][] matrix)
  3. maxDifffer(double[][] pos)
  4. maxDistance(double[][] _values)
  5. maxIndices(double M[][])
  6. maxtrixPermutation(int beforeArray[][])