code: private double rdist(double[] x1, double[] x2) {
          double d = 0.0;
          for (int i = 0; i < x1.length; i++) {
              double t = x1[i] - x2[i];
              d += t * t;
          }
          return Math.sqrt(d);
      }
docs: Cartesian distance.