hmmer-3.3/easel/esl_vectorops.c
/* Function:  esl_vec_{DFIL}ArgMax()
 * Synopsis:  Return index of maximum element in a vector.           
 *
 * Purpose:   Returns the index of the maximum value in the <n> values
 *            in <vec>. In case of ties, return the smallest index.
 *            
 *            <n> can be 0 and <vec> can be <NULL>, in which case the
 *            function returns 0.
 *            
 * Note:      Do not change the behavior that the smallest index is
 *            returned in case of ties. Some functions rely on this
 *            behavior: optimal accuracy tracebacks in HMMER for example.           
 */
esl_vec_{DFIL}ArgMax()
Synopsis:  Return index of maximum element in a vector.

Returns the index of the maximum value in the  values
in . In case of ties, return the smallest index.

 can be 0 and  can be , in which case the
function returns 0.

Do not change the behavior that the smallest index is
returned in case of ties. Some functions rely on this
behavior: optimal accuracy tracebacks in HMMER for example.
esl_vec_ { DFIL } ArgMax () Synopsis : Return index of maximum element in a vector . Returns the index of the maximum value in the values in . In case of ties return the smallest index . can be 0 and can be in which case the function returns 0 . Do not change the behavior that the smallest index is returned in case of ties . Some functions rely on this behavior : optimal accuracy tracebacks in HMMER for example .
int
esl_vec_DArgMax(const double *vec, int n)
{
  int i;
  int best = 0;
  for (i = 1; i < n; i++)
    if (vec[i] > vec[best]) best = i;
  return best;
}
int esl_vec_DArgMax ( const double * vec , int n ) { int i ; int best = 0 ; for ( i = 1 ; i < n ; i ++ ) if ( vec [ i ] > vec [ best ] ) best = i ; return best ; }
Function:  esl_vec_{DFIL}ArgMax()
 Synopsis:  Return index of maximum element in a vector.
Function : esl_vec_ { DFIL } ArgMax () Synopsis : Return index of maximum element in a vector .