biod.pnpi.spb.ru
/
alexxy
/
gromacs.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
a68b6a47b6aafe4e1c301ed2122ec785ca084d5d
[alexxy/gromacs.git]
/
src
/
gmxlib
/
gmx_blas
/
idamax.c
1
#include <math.h>
2
#include "gmx_blas.h"
3
4
int
5
F77_FUNC(idamax,IDAMAX)(int *n__,
6
double *dx,
7
int *incx__)
8
{
9
int i,ix,idxmax;
10
double dmax,tmp;
11
12
int n = *n__;
13
int incx = *incx__;
14
15
if(n<1 || incx<=0)
16
return -1;
17
18
if(n==1)
19
return 1;
20
21
dmax = fabs(dx[0]);
22
idxmax = 1;
23
24
if(incx==1) {
25
for(i=1;i<n;i++) {
26
tmp = fabs(dx[i]);
27
if(tmp>dmax) {
28
dmax = tmp;
29
idxmax = i+1;
30
}
31
}
32
} else {
33
/* Non-unit increments */
34
ix = incx; /* this is really 0 + an increment */
35
for(i=1;i<n;i++,ix+=incx) {
36
tmp = fabs(dx[ix]);
37
if(tmp>dmax) {
38
dmax = tmp;
39
idxmax = ix+1;
40
}
41
}
42
}
43
return idxmax;
44
}