optimize counting of k vector (consider only an hypersphere)
Merge branch 'master' into mac