Here you can find the source of minIndex(double values[])
Parameter | Description |
---|---|
values | the vector |
public static int minIndex(double values[])
//package com.java2s; //License from project: Open Source License public class Main { /**//ww w. j a v a 2 s . c o m * Finds the index of the minimum value in the given vector. * @param values the vector * @return index of the minimum in the given vector */ public static int minIndex(double values[]) { double min = Double.NEGATIVE_INFINITY; int minIndex = 0; int index = 0; for (double value : values) { if (value < min) { min = value; minIndex = index; } index++; } return minIndex; } /** * Finds the index of the minimum value in the given vector. * @param values the vector * @param mask mask denoting from which elements the minimum should be selected * @return index of the minimum in the given vector (w.r.t. the given mask) */ public static int minIndex(double values[], boolean[] mask) { double min = Double.NEGATIVE_INFINITY; int minIndex = 0; int index = 0; for (double value : values) { if (mask[index] && value < min) { min = value; minIndex = index; } index++; } return minIndex; } /** * Finds the index of the minimum value in the given vector. * @param values the vector * @param mask mask denoting from which elements the minimum should be selected * @return index of the minimum in the given vector (w.r.t. the given mask) */ public static int minIndex(int values[]) { int min = Integer.MAX_VALUE; int minIndex = 0; int index = 0; for (int value : values) { if (value < min) { min = value; minIndex = index; } index++; } return minIndex; } }