public VectorApproximation calculateApproximation(DBID id,V dv){
  int[] approximation=new int[dv.getDimensionality()];
  for (int d=0; d < splitPositions.length; d++) {
    final double val=dv.doubleValue(d);
    final int lastBorderIndex=splitPositions[d].length - 1;
    if (val < splitPositions[d][0]) {
      approximation[d]=0;
      if (id != null) {
        LOG.warning("Vector outside of VAFile grid!");
      }
    }
 else     if (val > splitPositions[d][lastBorderIndex]) {
      approximation[d]=lastBorderIndex - 1;
      if (id != null) {
        LOG.warning("Vector outside of VAFile grid!");
      }
    }
 else {
      int pos=Arrays.binarySearch(splitPositions[d],val);
      pos=(pos >= 0) ? pos : ((-pos) - 2);
      approximation[d]=pos;
    }
  }
  return new VectorApproximation(id,approximation);
}

public VectorApproximation calculateApproximation ( DBID id , V dv ) { int [ ] approximation = new int [ dv . getDimensionality ( ) ] ; for ( int d = 0 ; d < splitPositions . length ; d ++ ) { final double val = dv . doubleValue ( d ) ; final int lastBorderIndex = splitPositions [ d ] . length - 1 ; if ( val < splitPositions [ d ] [ 0 ] ) { approximation [ d ] = 0 ; if ( id != null ) { LOG . warning ( "Vector outside of VAFile grid!" ) ; } } else if ( val > splitPositions [ d ] [ lastBorderIndex ] ) { approximation [ d ] = lastBorderIndex - 1 ; if ( id != null ) { LOG . warning ( "Vector outside of VAFile grid!" ) ; } } else { int pos = Arrays . binarySearch ( splitPositions [ d ] , val ) ; pos = ( pos >= 0 ) ? pos : ( ( - pos ) - 2 ) ; approximation [ d ] = pos ; } } return new VectorApproximation ( id , approximation ) ; }
calculate the va file position given the existing borders .
