Skip to content

Commit

Permalink
cost
Browse files Browse the repository at this point in the history
  • Loading branch information
NoureldinYosri committed Nov 13, 2024
1 parent cd00a9a commit c84bca1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion qualtran/bloqs/factoring/ecc/ec_add_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def test_ec_add_symbolic_cost():
# toffoli cost for Kaliski Mod Inverse, n extra toffolis in ModNeg, 2n extra toffolis to do n
# 3-controlled toffolis in step 2. The expression is written with rationals because sympy
# comparison fails with floats.
assert total_toff == sympy.Rational(253, 2) * n**2 + sympy.Rational(391, 2) * n - 31
assert total_toff == sympy.Rational(253, 2) * n**2 + sympy.Rational(407, 2) * n - 31


def test_ec_add(bloq_autotester):
Expand Down
4 changes: 2 additions & 2 deletions qualtran/bloqs/mod_arithmetic/mod_division_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def test_kaliski_symbolic_cost():
# construction this is just $n-1$ (BitwiseNot -> Add(p+1)).
# - The cost of an iteration in Litinski $13n$ since they ignore constants.
# Our construction is exactly the same but we also count the constants
# which amout to $3$. for a total cost of $13n + 3$.
# which amout to $3$. for a total cost of $13n + 4$.
# For example the cost of ModDbl is 2n+1. In their figure 8, they report
# it as just $2n$. ModDbl gets executed within the 2n loop so its contribution
# to the overal cost should be 4n^2 + 2n instead of just 4n^2.
assert total_toff == 26 * n**2 + 7 * n - 1
assert total_toff == 26 * n**2 + 9 * n - 1


def test_kaliskimodinverse_example(bloq_autotester):
Expand Down

0 comments on commit c84bca1

Please sign in to comment.