public static int argmax(float[] a) {
    float max = Float.NEGATIVE_INFINITY;
    int argmax = 0;
    for (int i = 0; i < a.length; i++) {
      if (a[i] > max) {
        max = a[i];
        argmax = i;
      }
    }
    return argmax;
  }
public static int argmax ( float [ ] a ) { float max = Float . NEGATIVE_INFINITY ; int argmax = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] > max ) { max = a [ i ] ; argmax = i ; } } return argmax ; }
@return the index of the max value; if max is a tie, returns the first one.