-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Deutsch-Jozsa algorithm example #36
Conversation
So there's a simplified version of Deutsch in examples already, but this one seems like a mapping from the qiskit link you provided, is that true? |
let measured = measurements.get_measurement(&m).unwrap(); | ||
|
||
assert_eq!(measured.0, output as u64); | ||
assert_eq!(measured.1, 1.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use some sort of almost_eq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ?
examples/deutsch_jozsa.rs
Outdated
let (_, measurements) = run_local::<f64>(&r).unwrap(); | ||
let measured = measurements.get_measurement(&m).unwrap(); | ||
|
||
if measured.1 > 0.99 && measured.0 == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 1.0 - f64::epsilon rather than 0.99 if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples/deutsch_jozsa.rs
Outdated
Ok(()) | ||
} | ||
|
||
#[derive(Clone, Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can add Copy to remove .clone() call later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it seems several textbooks/courses treat the Deutsch algorithm and the general version called Deutsch-Jozsa as different algorithms and that makes sense to me for a few reasons:
Technically they are very similar but as you said, for variety i think it will be good to have this one. |
I was learning about the Deutsch-Jozsa so i wrote some code for a demo. Feel free to: