Skip to content

Commit

Permalink
SRQK uses Circuit copy
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathonMisiewicz committed May 20, 2024
1 parent 6191f4d commit 3af1661
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/qforte/qkd/srqk.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ def build_qk_mats_fast(self):

for m in range(self._nstates):
# Compute U_m = exp(-i m dt H)
Um = qforte.Circuit()
Um.add(self._Uprep)
Um = qforte.Circuit(self._Uprep)
phase1 = 1.0

if m > 0:
Expand Down Expand Up @@ -234,6 +233,9 @@ def matrix_element(self, m, n, use_op=False):
n : int
The number of time steps for the Un evolution.
use_op : bool
Should the matrix element be of H (true) or S (false)?
Returns
-------
value : complex
Expand Down Expand Up @@ -277,11 +279,7 @@ def matrix_element(self, m, n, use_op=False):
Ub.add(gate)

if not use_op:
# TODO (opt): use Uprep
cir = qforte.Circuit()
for j in range(self._nqb):
if self._ref[j] == 1:
cir.add(qforte.gate("X", j, j))
cir = qforte.Circuit(self._Uprep)

cir.add(qforte.gate("H", ancilla_idx, ancilla_idx))

Expand Down Expand Up @@ -323,11 +321,7 @@ def matrix_element(self, m, n, use_op=False):
control_gate_str = "c" + gate_str
cV_l.add(qforte.gate(control_gate_str, target, ancilla_idx))

cir = qforte.Circuit()
# TODO (opt): use Uprep
for j in range(self._nqb):
if self._ref[j] == 1:
cir.add(qforte.gate("X", j, j))
cir = qforte.Circuit(self._Uprep)

cir.add(qforte.gate("H", ancilla_idx, ancilla_idx))

Expand Down

0 comments on commit 3af1661

Please sign in to comment.