-
Notifications
You must be signed in to change notification settings - Fork 269
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
Allow to apply unitary qubit operators to qubits #263
Allow to apply unitary qubit operators to qubits #263
Conversation
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.
Thanks a lot! 👍
I added a few comments
Example: | ||
|
||
.. code-block:: python | ||
|
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.
This code is missing indentation I think
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.
done
projectq/ops/_qubit_operator.py
Outdated
raise TypeError("Only one qubit or qureg allowed.") | ||
# Check that operator is unitary | ||
if not len(self.terms) == 1: | ||
raise TypeError("Only unitary QubitOperators can be applied to " |
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.
Only QubitOperators consisting of a single Pauli string with a coefficient of unit length can be applied.
Otherwise, people might get confused if their operator actually is unitary but consists of multiple terms.
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 it be unitary with multiple terms?
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.
1/sqrt(2) * X + 1/sqrt(2) * Z = H
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.
Great, thanks for the example
projectq/ops/_qubit_operator.py
Outdated
Return the inverse gate if QubitOperator is unitary. | ||
|
||
Raises: | ||
NotInvertible: inverse is not implemented if not unitary |
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.
if there are multiple terms or the coefficient is not 1 in absolute value
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.
done
projectq/ops/_qubit_operator.py
Outdated
Raises: | ||
NotInvertible: inverse is not implemented if not unitary | ||
""" | ||
if len(self.terms) == 1: |
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.
and abs(coefficient)...
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.
done
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.
It won't raise an exception now, though...
projectq/ops/_qubit_operator.py
Outdated
Standard implementation of get_merged: | ||
|
||
Raises: | ||
NotMergeable: merging is not implemented |
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.
These docs are a bit strange ;-)
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, changed.
projectq/ops/_qubit_operator.py
Outdated
len(other.terms) == 1 and | ||
len(self.terms) == 1): | ||
return self * other | ||
|
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.
Do we still need the comments below?
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.
hmm nope
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.
💯
…ojectQ-Framework/ProjectQ into feature/unitary-qubitoperator-as-gate
No description provided.