def subquantizer_flops(D, M, clusters=256):
    """
    Given the dimension of the data, the number of subquantizers and the
    subquantizer vocabulary size, compute the number of flops to compute
    a projected query's LOPQ distance for a single half of the query.
    """
    # (subquants per half) * (dims per subquant) * (cluster per subquant) * (flops per squared distance)
    return (M / 2) * (D / M) * clusters * 2