Skip to content

Commit

Permalink
improved restructured text
Browse files Browse the repository at this point in the history
  • Loading branch information
rrtucci committed Mar 26, 2020
1 parent ca7bd48 commit 52e9075
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 239 deletions.
150 changes: 76 additions & 74 deletions qubiter/adv_applications/StairsCkt_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class StairsCkt_writer(SEO_writer):
"""
This class is a subclass of class SEO_writer and it writes a "Stairs
Circuit". For example, this is what the Picture file of a Stairs Circuit
looks like for num_qbits = 3
looks like for num_qbits = 3::
U | |
O---U |
@---U |
O---O---U
O---@---U
@---O---U
@---@---U
U | |
O---U |
@---U |
O---O---U
O---@---U
@---O---U
@---@---U
Here, U is a general U(2) matrix with 4 parameters, all of which can be
made into placeholder variables. If each U is represented by a node and
Expand All @@ -30,88 +30,90 @@ class StairsCkt_writer(SEO_writer):
than all the ones to its left. For example, suppose that in the
num_qbits=3 case, we restrict the parents of the U in the last step to
just one, instead of the 2 parents that it has in the fully connected
case. Then we get
case. Then we get::
U | |
O---U |
@---U |
O---+---U
@---+---U
U | |
O---U |
@---U |
O---+---U
@---+---U
or
or::
U | |
O---U |
@---U |
| O---U
| @---U
U | |
O---U |
@---U |
| O---U
| @---U
The constructor of this class has as input an ordered dictionary called
The constructor of this class has as input an ordered dictionary called
gate_str_to_rads_list. This dictionary gives for each gate in the
quantum circuit, a gate string gate_str that specifies the gate.
gate_str_to_rads_list maps gate_str to a list of 4 floats (or
placeholder variables for those floats) for the 4 parameters of the U
matrix. For example, here are possible values for gate_str_to_rads_list
for the num_qbits=3 fully connected qb net
with every rads_list item filled with the same constant .3
{'prior': [0.3, 0.3, 0.3, 0.3],
'2F': [0.3, 0.3, 0.3, 0.3],
'2T': [0.3, 0.3, 0.3, 0.3],
'2F1F': [0.3, 0.3, 0.3, 0.3],
'2F1T': [0.3, 0.3, 0.3, 0.3],
'2T1F': [0.3, 0.3, 0.3, 0.3],
'2T1T': [0.3, 0.3, 0.3, 0.3]}
with every rads_list item filled by a random number between 0 and 2pi
{'prior': [0.46731839721496604,
0.012285135138256131,
0.20001353832948487,
0.36694428209569985],
'2F': [4.1968011007222898,
5.1978252498063808,
4.8063090848060321,
4.2509081392354409],
'2T': [4.3359074640905213,
2.0749617893052315,
4.555666727197961,
5.3092010293653802],
'2F1F': [0.99177045463186475,
3.3344615340103325,
2.1441702948866386,
2.4603764283165521],
'2F1T': [4.0909522483111145,
2.0714182784661888,
5.4034187072431923,
6.0856723571386766],
'2T1F': [4.0000452017061194,
3.7193341571216658,
3.381322125034953,
5.4492142181489802],
'2T1T': [6.2597553541046853,
0.077807529496169509,
3.7389318319862217,
6.2233264819972307]}
with every rads_list item filled with the same constant .3::
{'prior': [0.3, 0.3, 0.3, 0.3],
'2F': [0.3, 0.3, 0.3, 0.3],
'2T': [0.3, 0.3, 0.3, 0.3],
'2F1F': [0.3, 0.3, 0.3, 0.3],
'2F1T': [0.3, 0.3, 0.3, 0.3],
'2T1F': [0.3, 0.3, 0.3, 0.3],
'2T1T': [0.3, 0.3, 0.3, 0.3]}
with every rads_list item filled by a random number between 0 and 2pi::
{'prior': [0.46731839721496604,
0.012285135138256131,
0.20001353832948487,
0.36694428209569985],
'2F': [4.1968011007222898,
5.1978252498063808,
4.8063090848060321,
4.2509081392354409],
'2T': [4.3359074640905213,
2.0749617893052315,
4.555666727197961,
5.3092010293653802],
'2F1F': [0.99177045463186475,
3.3344615340103325,
2.1441702948866386,
2.4603764283165521],
'2F1T': [4.0909522483111145,
2.0714182784661888,
5.4034187072431923,
6.0856723571386766],
'2T1F': [4.0000452017061194,
3.7193341571216658,
3.381322125034953,
5.4492142181489802],
'2T1T': [6.2597553541046853,
0.077807529496169509,
3.7389318319862217,
6.2233264819972307]}
with every rads_list item filled by a unique placeholder variable string
{'prior': ['#50', '#51', '#52', '#53'],
'2F': ['#500', '#501', '#502', '#503'],
'2T': ['#510', '#511', '#512', '#513'],
'2F1F': ['#5000', '#5001', '#5002', '#5003'],
'2F1T': ['#5010', '#5011', '#5012', '#5013'],
'2T1F': ['#5100', '#5101', '#5102', '#5103'],
'2T1T': ['#5110', '#5111', '#5112', '#5113']}
with every rads_list item filled by a unique placeholder variable string::
{'prior': ['#50', '#51', '#52', '#53'],
'2F': ['#500', '#501', '#502', '#503'],
'2T': ['#510', '#511', '#512', '#513'],
'2F1F': ['#5000', '#5001', '#5002', '#5003'],
'2F1T': ['#5010', '#5011', '#5012', '#5013'],
'2T1F': ['#5100', '#5101', '#5102', '#5103'],
'2T1T': ['#5110', '#5111', '#5112', '#5113']}
This is what gate_str_to_rads_list looks like in the num_qbits=3 case,
when the last U has only one parent (qbit 2) instead of two parents (
qbits 1 and 2):
qbits 1 and 2)::
{'prior': ['#50', '#51', '#52', '#53'],
'2F': ['#500', '#501', '#502', '#503'],
'2T': ['#510', '#511', '#512', '#513'],
'2F1_': ['#5050', '#5051', '#5052', '#5053'],
'2T1_': ['#5150', '#5151', '#5152', '#5153']}
{'prior': ['#50', '#51', '#52', '#53'],
'2F': ['#500', '#501', '#502', '#503'],
'2T': ['#510', '#511', '#512', '#513'],
'2F1_': ['#5050', '#5051', '#5052', '#5053'],
'2T1_': ['#5150', '#5151', '#5152', '#5153']}
Note that all placeholder strings begin with '#5' to insure that once
the hash character is removed, the remaining number doesn't start with
Expand Down
12 changes: 6 additions & 6 deletions qubiter/adv_applications/StairsDerivCkt_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class StairsDerivCkt_writer(SEO_writer):
parameters. To take the derivative wrt t_r of a given multi-controlled
gate U in a stairs circuit, we need to evaluate several circuits (we
call them dparts, which stands for derivative parts). Say, for instance,
that GATE= @---O---+---U. To calculate d/dt_r GATE(t_0, t_1, t_2, t_3),
that ``GATE= @---O---+---U``. To calculate d/dt_r GATE(t_0, t_1, t_2, t_3),
for r=0,1, 2, 3, we need to calculate a new circuit wherein the GATE in
the parent circuit is replaced by
the parent circuit is replaced by::
sum_k c_k @---@---O---+---U_k
sum_k c_k @---@---O---+---U_k
(which is said to have `has_neg_polarity`=False) and
(which is said to have `has_neg_polarity`=False) and::
sum_k c_k @---@---O---+---U_k
Z---@---O | |
sum_k c_k @---@---O---+---U_k
Z---@---O | |
(which is said to have `has_neg_polarity`=True)
Expand Down

0 comments on commit 52e9075

Please sign in to comment.