Java Array Min Value minInRowIndex(double[][] M, int row)

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

Description

Returns the row index of the minimal 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 minInRowIndex(double[][] M, int row) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   w w  w . jav  a  2s. c om*/
     * Returns the row index of the minimal 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 minInRowIndex(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. minIndex(int[] from)
  2. minIndex(int[] ints)
  3. minIndex(int[] values)
  4. minIndex(Number[] array)
  5. minIndexGreaterThan(final double[] array, final double p)
  6. minInt(int... values)
  7. minkowskiDistance(double[] coord1, double[] coord2)
  8. minLengthCheck(final byte[] buffer, final byte length)
  9. minList(int[] listA, int[] listB)