@SuppressWarnings("unchecked")
	public KMeans(List<Double[]> descriptors) {
		int size = descriptors.size();
		this.kClusters = (int)Math.sqrt(size);
		this.points = descriptors;
		this.clustersCentroids = new ArrayList<Double[]>(kClusters);
		this.clustersMapping = (List<Integer>[]) new ArrayList[clustersCentroids.size()];
		this.dimension = descriptors.size() == 0? 0 : descriptors.get(0).length;
		for(int i = 0; i < points.size(); i++) {
			if(points.get(i).length < dimension) {
				Double[] d = new Double[dimension];
				for(int j = 0; j < points.get(i).length; j++)
					d[j] = points.get(i)[j];
				for(int j = points.get(i).length; j < dimension; j++)
					d[j] = 0.0;
				points.set(i, d);
			}
		}
	}