public static int isamax_f77 (int n, double x[], int incx) {

      double xmax;
      int isamax,i,ix;

      if (n < 1) {

         isamax = 0;

      } else if (n == 1) {

         isamax = 1;

      } else if (incx == 1) {

         isamax = 1;
         xmax = Math.abs(x[1]);
         
         for (i = 2; i <= n; i++) {

            if (Math.abs(x[i]) > xmax) {

               isamax = i;
               xmax = Math.abs(x[i]);

            }

         }

      } else {

         isamax = 1;
         ix = 1;
         xmax = Math.abs(x[ix]);
         ix += incx;

         for (i = 2; i <= n; i++) {

            if (Math.abs(x[ix]) > xmax) {

               isamax = i;
               xmax = Math.abs(x[ix]);

            }

            ix += incx;

         }
        
      }

      return isamax;

   }