private int computeNearestCoarseIndex(double[] vector) {
		int centroidIndex = -1;
		double minDistance = Double.MAX_VALUE;
		for (int i = 0; i < numCoarseCentroids; i++) {
			double distance = 0;
			for (int j = 0; j < vectorLength; j++) {
				distance += (coarseQuantizer[i][j] - vector[j]) * (coarseQuantizer[i][j] - vector[j]);
				if (distance >= minDistance) {
					break;
				}
			}
			if (distance < minDistance) {
				minDistance = distance;
				centroidIndex = i;
			}
		}
		return centroidIndex;
	}
private int computeNearestCoarseIndex ( double [ ] vector ) { int centroidIndex = - 1 ; double minDistance = Double . MAX_VALUE ; for ( int i = 0 ; i < numCoarseCentroids ; i ++ ) { double distance = 0 ; for ( int j = 0 ; j < vectorLength ; j ++ ) { distance += ( coarseQuantizer [ i ] [ j ] - vector [ j ] ) * ( coarseQuantizer [ i ] [ j ] - vector [ j ] ) ; if ( distance >= minDistance ) { break ; } } if ( distance < minDistance ) { minDistance = distance ; centroidIndex = i ; } } return centroidIndex ; }
Returns the index of the coarse centroid which is closer to the given vector.

@param vector
The vector
@return The index of the nearest coarse centroid