Skip to content

Overcounting of Hamming weights due to csr operations #24

@StergiosKou

Description

@StergiosKou

When calculating Hamming weights in different points throughout the repo, the command get_nnz is called. Typically this is fine, but if the csr arrays used have undergone operations, they potentially contain extra entries, which will be overcounted.

eg:

from scipy.sparse import csr_matrix

a = csr_matrix([1, 1])
b = csr_matrix([0, 1])
c = a + b
c.data%= 2
print("getnnz weight:", b.getnnz())
print("Hamming weight:", (c != 0).sum())

returns:

getnnz weight: 2
Hamming weight: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions