optimize counting of k vector (consider only an hypersphere)