Implement Deutsch-Jozsa Algorithm In Qiskit - #3447
Conversation
78894a5 to
cf60aa6
Compare
8dd6f21 to
a387935
Compare
a387935 to
e9c3d82
Compare
b7ea8ec to
ce74e77
Compare
ce74e77 to
d408785
Compare
a766869 to
d740492
Compare
d740492 to
8d9ce52
Compare
809321b to
7c5da9e
Compare
Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
7c5da9e to
931a9dd
Compare
f17c98a to
e4d6caf
Compare
| classical algorithm | ||
|
|
||
| Premise: | ||
| We are given a hidden Boolean function f , |
There was a problem hiding this comment.
| We are given a hidden Boolean function f , | |
| We are given a hidden Boolean function f, |
There was a problem hiding this comment.
@cclauss fixed extra whitespace in newly added commit
e4d6caf to
56bcf6f
Compare
06d8e34 to
07d33ab
Compare
Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
07d33ab to
4e2a95b
Compare
55faf64 to
517d327
Compare
|
@cclauss What's the deal with this GitHub action which applies Oh, nevermind. I get it why it works on some and not on others. The user has turned on the workflow in their forked copy and this is coming from there. I propose to remove it and the codespell action as both of them are checked with |
|
The thing that it does do is... If a maintainer (with write privileges to the repo) creates a PR then the Action blackens the entire repo. This ensures that from time to time the entire repo is blackened even if someone lands a PR that is not green. Go ahead and make the changes that you suggest above. |
| counts = deutsch_jozsa("constant", 3) | ||
| print(f"Deutsch Jozsa - Constant Oracle: {counts}") | ||
|
|
||
| counts = deutsch_jozsa("balanced", 3) | ||
| print(f"Deutsch Jozsa - Balanced Oracle: {counts}") |
There was a problem hiding this comment.
| counts = deutsch_jozsa("constant", 3) | |
| print(f"Deutsch Jozsa - Constant Oracle: {counts}") | |
| counts = deutsch_jozsa("balanced", 3) | |
| print(f"Deutsch Jozsa - Balanced Oracle: {counts}") | |
| print(f"Deutsch Jozsa - Constant Oracle: {deutsch_jozsa("constant", 3)}") | |
| print(f"Deutsch Jozsa - Balanced Oracle: {deutsch_jozsa("balanced", 3)}") |
| # wrap in X-gates: | ||
| b = np.random.randint(1, 2 ** n) | ||
| # Next, format 'b' as a binary string of length 'n', padded with zeros: | ||
| b_str = format(b, "0" + str(n) + "b") |
There was a problem hiding this comment.
switched to f-string
| # Next, we place the first X-gates. Each digit in our binary string | ||
| # correspopnds to a qubit, if the digit is 0, we do nothing, if it's 1 | ||
| # we apply an X-gate to that qubit: | ||
| for qubit in range(len(b_str)): |
There was a problem hiding this comment.
Please use enumerate() instead of range(len()).
There was a problem hiding this comment.
qubit is not a qubit, it is an int. Maybe call it I or index.
There was a problem hiding this comment.
using enumerate now, changed var name to index
| for qubit in range(n): | ||
| oracle_qc.cx(qubit, n) | ||
| # Next, place the final X-gates | ||
| for qubit in range(len(b_str)): |
There was a problem hiding this comment.
Perhaps this should be two separate functions.
There was a problem hiding this comment.
The variable name n is not self documenting. Can we come up with a more descriptive name.
There was a problem hiding this comment.
changed var name from n to num_qubits
There was a problem hiding this comment.
However, I feel the function is fine as it is.
I think we shouldn't split the function, as it seems to be more complete in its current form. @cclauss what do you think?
517d327 to
1a33ec4
Compare
5745184 to
c818db8
Compare
* Implement Deutsch-Jozsa Algorithm In Qiskit
Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
* Add Changes Requested In Review
Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
* Address Further Review Comments
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Implement Deutsch-Jozsa Algorithm In Qiskit
Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
* Add Changes Requested In Review
Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
* Address Further Review Comments
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Implement Deutsch-Jozsa Algorithm In Qiskit
Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
* Add Changes Requested In Review
Signed-off-by: Abhishek Jaisingh <abhi2254015@gmail.com>
* Address Further Review Comments
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>

Signed-off-by: Abhishek Jaisingh abhi2254015@gmail.com
Describe your change:
Implement Deutsch-Jozsa Algorithm In Qiskit
Checklist:
Fixes: #{$ISSUE_NO}.