src/metaspades/ext/src/easel/esl_vectorops.c
/* Function:  esl_vec_DArgMax()
 * 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, the element with the smallest index
 *            is returned. 
 *            
 *            <n> can be 0 and <vec> can be <NULL>, in which case the
 *            function returns 0.
 *            
 *            <esl_vec_FArgMax()> and <esl_vec_IArgMax()> do the same,
 *            for float and integer vectors.
 *            
 * 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_DArgMax()
Synopsis:  Return index of maximum element in a vector.

Returns the index of the maximum value in the  values
in . In case of ties, the element with the smallest index
is returned.

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

 and  do the same,
for float and integer vectors.

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_DArgMax () Synopsis : Return index of maximum element in a vector . Returns the index of the maximum value in the values in . In case of ties the element with the smallest index is returned . can be 0 and can be in which case the function returns 0 . and do the same for float and integer vectors . 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_DArgMax()
 Synopsis:  Return index of maximum element in a vector.
Function : esl_vec_DArgMax () Synopsis : Return index of maximum element in a vector .