Updated intel syntax x86-64 asm files to also support MS win64 call convention (ifdef...
[gromacs/rigid-bodies.git] / src / gmxlib / gmx_blas / idamax.c
bloba68b6a47b6aafe4e1c301ed2122ec785ca084d5d
1 #include <math.h>
2 #include "gmx_blas.h"
4 int
5 F77_FUNC(idamax,IDAMAX)(int *n__,
6 double *dx,
7 int *incx__)
9 int i,ix,idxmax;
10 double dmax,tmp;
12 int n = *n__;
13 int incx = *incx__;
15 if(n<1 || incx<=0)
16 return -1;
18 if(n==1)
19 return 1;
21 dmax = fabs(dx[0]);
22 idxmax = 1;
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;
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;
43 return idxmax;