Distance matrix computation for different metrics in torch7 (lua) with cuda