Here you can find the source of argmin(final double[] vec)
Parameter | Description |
---|---|
vec | the vector to find the argmin of |
public static int argmin(final double[] vec)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w. j a v a 2 s. co m * Returns the index of the smallest element in a vector. * Precondition : vec != null * @param vec the vector to find the argmin of * @return the argmin of vec */ public static int argmin(final double[] vec) { assert vec != null; double min = vec[0]; int argmin = 0; for (int i = 1; i < vec.length; i++) { final double tmp = vec[i]; if (tmp < min) { min = tmp; argmin = i; } } return argmin; } }