dwavesystems / dwavebinarycsp

Map constraint satisfaction problems with binary variables to binary quadratic models.
https://docs.ocean.dwavesys.com/projects/binarycsp/en/latest
Apache License 2.0
20 stars 27 forks source link

circuits.py - num_multiplier_bits vs num_multiplicand_bits #49

Closed myriagon closed 6 years ago

myriagon commented 6 years ago

In circuits.py, comments say that

    # throughout, we will use the following convention:
    #   i to refer to the bits of the multiplier
    #   j to refer to the bits of the multiplicand

In line 47 we have

num_multiplier_bits = num_multiplicand_bits = nbit

Then in lines 68-69 we have

    for i in range(num_multiplicand_bits):
        for j in range(num_multiplier_bits):

Although num_multiplier_bits and num_multiplicand_bits have the same value, perhaps for clarity this ought to be

    for i in range(num_multiplier_bits):
        for j in range(num_multiplicand_bits):

Or am I missing something?

Thank you.

arcondello commented 6 years ago

Hi @myriagon ,

You're right, this is confusing. I have made a PR to correct the double for loop to use the correct notation.

The num_multiplier_bits = num_multiplicand_bits = nbit line is an artifact from when the function was written. Originally it allowed the user to specify a different number of bits for the multiplier and the multiplicand.