private static int idamax ( int n , double [ ] dx , int ix0 , int incx ) { int ix , imax ; double dmax ; if ( n < 1 ) { return - 1 ; } if ( n == 1 ) { return 0 ; } if ( incx == 0 ) { return - 1 ; } ix = ( incx < 0 ) ? ix0 + ( ( - n + 1 ) * incx ) : ix0 ; imax = ix ; dmax = Math . abs ( dx [ ix ] ) ; for ( int i = 1 ; i < n ; i ++ ) { ix += incx ; double dtemp = Math . abs ( dx [ ix ] ) ; if ( dtemp > dmax ) { dmax = dtemp ; imax = ix ; } } return imax ; }
Find the index of element having maximum absolute value .