Fast K-NN using expanded equation (by Ian T Nabney)