Updated KMeans to work with row_major matrices