Skip to content

Commit

Permalink
Fixing tutorial_apply_qsvt (#912)
Browse files Browse the repository at this point in the history
This is a PR to solve [this
issue](#910).

---------

Co-authored-by: Jay Soni <[email protected]>
  • Loading branch information
KetpuntoG and Jaybsoni authored Sep 6, 2023
1 parent a264b0d commit 6c1f8e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demonstrations/tutorial_apply_qsvt.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
],
"dateOfPublication": "2023-08-22T00:00:00+00:00",
"dateOfLastModification": "2023-08-22T00:00:00+00:00",
"dateOfLastModification": "2023-09-05T00:00:00+00:00",
"categories": [
"Quantum Computing",
"Algorithms",
Expand Down
12 changes: 7 additions & 5 deletions demonstrations/tutorial_apply_qsvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,17 @@ def loss_func(phi):
#
# .. math::
#
# \hat{U}_{real}(\vec{\phi}) = \frac{1}{2} \ ( \hat{U}_{qsvt}(\vec{\phi}) + \hat{U}^{\dagger}_{qsvt}(\vec{\phi}) ).
# \hat{U}_{real}(\vec{\phi}) = \frac{1}{2} \ ( \hat{U}_{qsvt}(\vec{\phi}) + \hat{U}^{*}_{qsvt}(\vec{\phi}) ).
#
# Here we use a two-term LCU to define the quantum function for this operator:
# Here we use a two-term LCU to define the quantum function for this operator. We obtain the complex
# conjugate of :math:`\hat{U}_{qsvt}` by taking the adjoint of the operator block-encoding :math:`A^{T}`:


def real_u(A, phi):
qml.Hadamard(wires="ancilla1")

qml.ctrl(sum_even_odd_circ, control=("ancilla1",), control_values=(0,))(A, phi, "ancilla2", [0, 1, 2])
qml.ctrl(qml.adjoint(sum_even_odd_circ), control=("ancilla1",), control_values=(1,))(A, phi, "ancilla2", [0, 1, 2])
qml.ctrl(qml.adjoint(sum_even_odd_circ), control=("ancilla1",), control_values=(1,))(A.T, phi, "ancilla2", [0, 1, 2])

qml.Hadamard(wires="ancilla1")

Expand All @@ -306,8 +307,9 @@ def real_u(A, phi):
#
# Solving a Linear System with QSVT
# ---------------------------------
# Our goal is to solve the equation :math:`A \cdot \vec{x} = \vec{b}`. Let's begin by
# defining the specific matrix :math:`A` and vector :math:`\vec{b}` :
# Our goal is to solve the equation :math:`A \cdot \vec{x} = \vec{b}`. This method assumes
# the matrix we will invert is hermitian. Let's begin by defining the specific matrix :math:`A`
# and vector :math:`\vec{b}` :
#

A = np.array(
Expand Down

0 comments on commit 6c1f8e7

Please sign in to comment.