Itseez/opencv — pull request #2010 by pemmanuelviel (2013-12-17 12:54:22+00:00)
Title: Ensure KMeans++ will pick centers with a probability proportional to their squared distance

Some distances such as L2 are already returning their squared value actually, while many distances (e.g. Hamming, L1, ...) don't. It's helpful to have a way to be sure the returned value is squared without having to look at the code to check how distances are processed. This is what we do by using a template ensureSquareDistance( dist ) for efficiency to avoid passing through conditional branches at runtime.