Skip to content

Commit

Permalink
Maked intermediate additions unsigned in ModAdd (#1424)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpapa250 authored Sep 28, 2024
1 parent d661d69 commit b14f1b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions qualtran/bloqs/mod_arithmetic/mod_addition.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def build_composite_bloq(self, bb: 'BloqBuilder', x: Soquet, y: Soquet) -> Dict[
x = bb.join(x_split[1:], dtype=QMontgomeryUInt(bitsize=self.bitsize))

# Add constant -p to the y register.
y = bb.add(AddK(bitsize=self.bitsize + 1, k=-1 * self.mod, signed=True, cvs=()), x=y)
y = bb.add(AddK(bitsize=self.bitsize + 1, k=-1 * self.mod, signed=False, cvs=()), x=y)

# Controlled addition of classical constant p if the sign of y after the last addition is
# negative.
Expand All @@ -125,7 +125,7 @@ def build_composite_bloq(self, bb: 'BloqBuilder', x: Soquet, y: Soquet) -> Dict[

sign_split = bb.split(sign)
sign_split, y = bb.add(
AddK(bitsize=self.bitsize, k=self.mod, signed=True, cvs=(1,)), x=y, ctrls=sign_split
AddK(bitsize=self.bitsize, k=self.mod, signed=False, cvs=(1,)), x=y, ctrls=sign_split
)
sign = bb.join(sign_split)

Expand Down

0 comments on commit b14f1b4

Please sign in to comment.