public static double ddot_f77 (int n, double dx[], int incx, double
                      dy[], int incy) {

      double ddot;
      int i,ix,iy,m;

      ddot = 0.0;

      if (n <= 0) return ddot;

      if ((incx == 1) && (incy == 1)) {

//   both increments equal to 1

         m = n%5;

         for (i = 1; i <= m; i++) {

            ddot += dx[i]*dy[i];

         }

         for (i = m+1; i <= n; i += 5) {

            ddot += dx[i]*dy[i] + dx[i+1]*dy[i+1] + dx[i+2]*dy[i+2] +
                    dx[i+3]*dy[i+3] + dx[i+4]*dy[i+4];

         }

         return ddot;

      } else {

//   at least one increment not equal to 1

         ix = 1;
         iy = 1;

         if (incx < 0) ix = (-n+1)*incx + 1;
         if (incy < 0) iy = (-n+1)*incy + 1;

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

            ddot += dx[ix]*dy[iy];

            ix += incx;
            iy += incy;

         }

         return ddot;

      }

   }