biod.pnpi.spb.ru
/
alexxy
/
gromacs.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
9f60db479cfefb64876498e803a53878c87c9cb5
[alexxy/gromacs.git]
/
src
/
gmxlib
/
gmx_blas
/
isamax.c
1
#include <math.h>
2
#include "gmx_blas.h"
3
4
int
5
F77_FUNC(isamax,ISAMAX)(int *n__,
6
float *dx,
7
int *incx__)
8
{
9
int i,ix,idxmax;
10
float 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
}