public double[] estimateL2DistanceSquared(Datum queryDatum){
  RealVector vector=queryDatum.metrics();
  double[] estimates=new double[2];
  for (int i=0; i < k; i++) {
    double deltaLo=vector.getEntry(i) - this.boundaries[i][0];
    double deltaHi=this.boundaries[i][1] - vector.getEntry(i);
    double sqDeltaLo=deltaLo * deltaLo;
    double sqDeltaHi=deltaHi * deltaHi;
    if (deltaLo < 0 || deltaHi < 0) {
      if (sqDeltaHi < sqDeltaLo) {
        estimates[0]+=sqDeltaHi;
        estimates[1]+=sqDeltaLo;
      }
 else {
        estimates[0]+=sqDeltaLo;
        estimates[1]+=sqDeltaHi;
      }
    }
 else {
      estimates[1]+=Math.max(sqDeltaHi,sqDeltaLo);
    }
  }
  return estimates;
}

public double [ ] estimateL2DistanceSquared ( Datum queryDatum ) { RealVector vector = queryDatum . metrics ( ) ; double [ ] estimates = new double [ 2 ] ; for ( int i = 0 ; i < k ; i ++ ) { double deltaLo = vector . getEntry ( i ) - this . boundaries [ i ] [ 0 ] ; double deltaHi = this . boundaries [ i ] [ 1 ] - vector . getEntry ( i ) ; double sqDeltaLo = deltaLo * deltaLo ; double sqDeltaHi = deltaHi * deltaHi ; if ( deltaLo < 0 || deltaHi < 0 ) { if ( sqDeltaHi < sqDeltaLo ) { estimates [ 0 ] += sqDeltaHi ; estimates [ 1 ] += sqDeltaLo ; } else { estimates [ 0 ] += sqDeltaLo ; estimates [ 1 ] += sqDeltaHi ; } } else { estimates [ 1 ] += Math . max ( sqDeltaHi , sqDeltaLo ) ; } } return estimates ; }
estimates bounds on the distance to a region
