-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shape error for tensor-like parameters in pauli arithmetic fixed (Add…
…ition to PR: #6562) (#6587) **Context:** I added Pauli string decompositions for single qubit parametrized gates in PR: #6562. Pennylane exploits these Pauli string representations when, for example, computing ```python (qml.RX(1.11, wires=0) @ qml.RY(1.23, wires=0)).matrix() ``` The example above works as intended, but ```python (qml.RX([1.11, 2.11, 3.11], wires=0) @ qml.RY([1.23, 2.23, 3.23], wires=0)).matrix() # shape error ``` or ```python (qml.RX(np.array([1.11, 2.11, 3.11]), wires=0) @ qml.RY(np.array([1.23, 2.23, 3.23]), wires=0)).matrix() # shape error ``` returns a shape error. The code above should work since `RX`and `RY`support tensor-like (flattened) parameters as it can be seen from ```python qml.RX([1.11, 2.11, 3.11], wires=0).matrix() # works! ``` **Description of the Change:** I added an outer product in `pauli_arithmetic`. **Benefits:** - Pauli representations can now be leveraged for the matrix conversion of products of ops. - A Pauli representation of the `PhaseShift gate` could be added - this was not possible before as the `PCPhase` gate used the `pauli_arithmetic`, which gave an error in the pytests. **Possible Drawbacks:** None **Related GitHub Issues:** #6243 and PR: #6562 --------- Co-authored-by: Lasse Dierich <[email protected]> Co-authored-by: David Wierichs <[email protected]> Co-authored-by: Christina Lee <[email protected]>
- Loading branch information
Showing
3 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters