added Fast kmeans for calculating dictionary