You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Improve ansatz generation API docs
This also fixes#62, which is a one-line docs change.
* Simplify example section
* Add comment about abstract.py
* fix typo
* Address complaints from lint and sphinx
qc: A circuit, which is assumed to be unitary. Barriers are ignored.
130
132
qubits_initially_zero: If ``True``, the first Z rotation on each qubit
131
-
is removed from the ansatz under the assumption that it has no effect.
133
+
is fixed to zero because such a rotation has no effect on the state
134
+
:math:`|0\rangle`.
132
135
parameter_name: Name for the :class:`~qiskit.circuit.ParameterVector`
133
136
representing the free parameters in the returned ansatz circuit.
134
137
135
138
Returns:
136
139
``(ansatz, parameter_values)`` such that ``ansatz.assign_parameters(parameter_values)``
137
140
is equivalent to ``qc`` up to a global phase.
141
+
142
+
Example:
143
+
========
144
+
145
+
Consider the following circuit as an example:
146
+
147
+
.. plot::
148
+
:alt: Circuit diagram output by the previous code.
149
+
:include-source:
150
+
:context: reset
151
+
152
+
from qiskit import QuantumCircuit
153
+
154
+
qc = QuantumCircuit(6)
155
+
qc.rx(0.4, 0)
156
+
qc.ryy(0.2, 2, 3)
157
+
qc.h(2)
158
+
qc.rz(0.1, 2)
159
+
qc.rxx(0.3, 0, 1)
160
+
qc.rzz(0.3, 0, 1)
161
+
qc.cx(2, 1)
162
+
qc.s(1)
163
+
qc.h(4)
164
+
qc.draw("mpl")
165
+
166
+
If the above circuit is passed to :func:`.generate_ansatz_from_circuit`, it will return an ansatz with parametrized two-qubit KAK rotations in the same locations as the input:
167
+
168
+
.. plot::
169
+
:alt: Circuit diagram output by the previous code.
170
+
:include-source:
171
+
:context: close-figs
172
+
173
+
from qiskit_addon_aqc_tensor import generate_ansatz_from_circuit
Note that in the generated ansatz, all consecutive single-qubit gates are collapsed into the same ZXZ block, and all consecutive two-qubit gates are collapsed into a single KAK block, up to single-qubit rotations.
181
+
182
+
Further, the :func:`.generate_ansatz_from_circuit` function provides parameters which, when bound to the ansatz, will result in a circuit equivalent to the original one, up to a global phase:
183
+
184
+
.. plot::
185
+
:alt: Circuit diagram output by the previous code.
0 commit comments