Merged quantization into similarity matrix computation