qiskit 2.1.0rc1__cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qiskit/VERSION.txt +1 -0
- qiskit/__init__.py +159 -0
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/_numpy_compat.py +73 -0
- qiskit/circuit/__init__.py +1335 -0
- qiskit/circuit/_add_control.py +338 -0
- qiskit/circuit/_classical_resource_map.py +154 -0
- qiskit/circuit/_standard_gates_commutations.py +3849 -0
- qiskit/circuit/_utils.py +167 -0
- qiskit/circuit/annotated_operation.py +279 -0
- qiskit/circuit/annotation.py +404 -0
- qiskit/circuit/barrier.py +46 -0
- qiskit/circuit/classical/__init__.py +41 -0
- qiskit/circuit/classical/expr/__init__.py +266 -0
- qiskit/circuit/classical/expr/constructors.py +764 -0
- qiskit/circuit/classical/expr/expr.py +156 -0
- qiskit/circuit/classical/expr/visitors.py +381 -0
- qiskit/circuit/classical/types/__init__.py +113 -0
- qiskit/circuit/classical/types/ordering.py +229 -0
- qiskit/circuit/classical/types/types.py +30 -0
- qiskit/circuit/commutation_checker.py +133 -0
- qiskit/circuit/commutation_library.py +20 -0
- qiskit/circuit/controlflow/__init__.py +59 -0
- qiskit/circuit/controlflow/_builder_utils.py +211 -0
- qiskit/circuit/controlflow/box.py +188 -0
- qiskit/circuit/controlflow/break_loop.py +56 -0
- qiskit/circuit/controlflow/builder.py +791 -0
- qiskit/circuit/controlflow/continue_loop.py +56 -0
- qiskit/circuit/controlflow/control_flow.py +94 -0
- qiskit/circuit/controlflow/for_loop.py +218 -0
- qiskit/circuit/controlflow/if_else.py +498 -0
- qiskit/circuit/controlflow/switch_case.py +411 -0
- qiskit/circuit/controlflow/while_loop.py +166 -0
- qiskit/circuit/controlledgate.py +274 -0
- qiskit/circuit/delay.py +159 -0
- qiskit/circuit/duration.py +80 -0
- qiskit/circuit/equivalence.py +94 -0
- qiskit/circuit/equivalence_library.py +18 -0
- qiskit/circuit/exceptions.py +19 -0
- qiskit/circuit/gate.py +261 -0
- qiskit/circuit/instruction.py +564 -0
- qiskit/circuit/instructionset.py +132 -0
- qiskit/circuit/library/__init__.py +984 -0
- qiskit/circuit/library/arithmetic/__init__.py +40 -0
- qiskit/circuit/library/arithmetic/adders/__init__.py +18 -0
- qiskit/circuit/library/arithmetic/adders/adder.py +235 -0
- qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +123 -0
- qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +129 -0
- qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +95 -0
- qiskit/circuit/library/arithmetic/exact_reciprocal.py +131 -0
- qiskit/circuit/library/arithmetic/functional_pauli_rotations.py +114 -0
- qiskit/circuit/library/arithmetic/integer_comparator.py +200 -0
- qiskit/circuit/library/arithmetic/linear_amplitude_function.py +363 -0
- qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +243 -0
- qiskit/circuit/library/arithmetic/multipliers/__init__.py +17 -0
- qiskit/circuit/library/arithmetic/multipliers/hrs_cumulative_multiplier.py +145 -0
- qiskit/circuit/library/arithmetic/multipliers/multiplier.py +201 -0
- qiskit/circuit/library/arithmetic/multipliers/rg_qft_multiplier.py +108 -0
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +506 -0
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +395 -0
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +501 -0
- qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +389 -0
- qiskit/circuit/library/arithmetic/quadratic_form.py +370 -0
- qiskit/circuit/library/arithmetic/weighted_adder.py +428 -0
- qiskit/circuit/library/basis_change/__init__.py +15 -0
- qiskit/circuit/library/basis_change/qft.py +316 -0
- qiskit/circuit/library/bit_flip_oracle.py +130 -0
- qiskit/circuit/library/blueprintcircuit.py +322 -0
- qiskit/circuit/library/boolean_logic/__init__.py +18 -0
- qiskit/circuit/library/boolean_logic/inner_product.py +157 -0
- qiskit/circuit/library/boolean_logic/quantum_and.py +204 -0
- qiskit/circuit/library/boolean_logic/quantum_or.py +206 -0
- qiskit/circuit/library/boolean_logic/quantum_xor.py +167 -0
- qiskit/circuit/library/data_preparation/__init__.py +57 -0
- qiskit/circuit/library/data_preparation/_z_feature_map.py +115 -0
- qiskit/circuit/library/data_preparation/_zz_feature_map.py +150 -0
- qiskit/circuit/library/data_preparation/initializer.py +107 -0
- qiskit/circuit/library/data_preparation/pauli_feature_map.py +656 -0
- qiskit/circuit/library/data_preparation/state_preparation.py +336 -0
- qiskit/circuit/library/fourier_checking.py +160 -0
- qiskit/circuit/library/generalized_gates/__init__.py +30 -0
- qiskit/circuit/library/generalized_gates/diagonal.py +163 -0
- qiskit/circuit/library/generalized_gates/gms.py +179 -0
- qiskit/circuit/library/generalized_gates/gr.py +219 -0
- qiskit/circuit/library/generalized_gates/isometry.py +370 -0
- qiskit/circuit/library/generalized_gates/linear_function.py +318 -0
- qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +143 -0
- qiskit/circuit/library/generalized_gates/mcmt.py +316 -0
- qiskit/circuit/library/generalized_gates/pauli.py +84 -0
- qiskit/circuit/library/generalized_gates/permutation.py +202 -0
- qiskit/circuit/library/generalized_gates/rv.py +96 -0
- qiskit/circuit/library/generalized_gates/uc.py +303 -0
- qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +164 -0
- qiskit/circuit/library/generalized_gates/ucrx.py +32 -0
- qiskit/circuit/library/generalized_gates/ucry.py +32 -0
- qiskit/circuit/library/generalized_gates/ucrz.py +32 -0
- qiskit/circuit/library/generalized_gates/unitary.py +236 -0
- qiskit/circuit/library/graph_state.py +172 -0
- qiskit/circuit/library/grover_operator.py +583 -0
- qiskit/circuit/library/hamiltonian_gate.py +142 -0
- qiskit/circuit/library/hidden_linear_function.py +163 -0
- qiskit/circuit/library/iqp.py +180 -0
- qiskit/circuit/library/n_local/__init__.py +45 -0
- qiskit/circuit/library/n_local/efficient_su2.py +282 -0
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +520 -0
- qiskit/circuit/library/n_local/excitation_preserving.py +301 -0
- qiskit/circuit/library/n_local/n_local.py +1478 -0
- qiskit/circuit/library/n_local/pauli_two_design.py +246 -0
- qiskit/circuit/library/n_local/qaoa_ansatz.py +367 -0
- qiskit/circuit/library/n_local/real_amplitudes.py +312 -0
- qiskit/circuit/library/n_local/two_local.py +289 -0
- qiskit/circuit/library/overlap.py +183 -0
- qiskit/circuit/library/pauli_evolution.py +202 -0
- qiskit/circuit/library/phase_estimation.py +177 -0
- qiskit/circuit/library/phase_oracle.py +239 -0
- qiskit/circuit/library/quantum_volume.py +179 -0
- qiskit/circuit/library/standard_gates/__init__.py +141 -0
- qiskit/circuit/library/standard_gates/dcx.py +76 -0
- qiskit/circuit/library/standard_gates/ecr.py +126 -0
- qiskit/circuit/library/standard_gates/equivalence_library.py +1936 -0
- qiskit/circuit/library/standard_gates/global_phase.py +83 -0
- qiskit/circuit/library/standard_gates/h.py +230 -0
- qiskit/circuit/library/standard_gates/i.py +76 -0
- qiskit/circuit/library/standard_gates/iswap.py +115 -0
- qiskit/circuit/library/standard_gates/p.py +415 -0
- qiskit/circuit/library/standard_gates/r.py +108 -0
- qiskit/circuit/library/standard_gates/rx.py +269 -0
- qiskit/circuit/library/standard_gates/rxx.py +165 -0
- qiskit/circuit/library/standard_gates/ry.py +268 -0
- qiskit/circuit/library/standard_gates/ryy.py +165 -0
- qiskit/circuit/library/standard_gates/rz.py +290 -0
- qiskit/circuit/library/standard_gates/rzx.py +211 -0
- qiskit/circuit/library/standard_gates/rzz.py +181 -0
- qiskit/circuit/library/standard_gates/s.py +424 -0
- qiskit/circuit/library/standard_gates/swap.py +268 -0
- qiskit/circuit/library/standard_gates/sx.py +303 -0
- qiskit/circuit/library/standard_gates/t.py +169 -0
- qiskit/circuit/library/standard_gates/u.py +379 -0
- qiskit/circuit/library/standard_gates/u1.py +466 -0
- qiskit/circuit/library/standard_gates/u2.py +145 -0
- qiskit/circuit/library/standard_gates/u3.py +412 -0
- qiskit/circuit/library/standard_gates/x.py +1335 -0
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +164 -0
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +197 -0
- qiskit/circuit/library/standard_gates/y.py +253 -0
- qiskit/circuit/library/standard_gates/z.py +331 -0
- qiskit/circuit/library/templates/__init__.py +92 -0
- qiskit/circuit/library/templates/clifford/__init__.py +33 -0
- qiskit/circuit/library/templates/clifford/clifford_2_1.py +34 -0
- qiskit/circuit/library/templates/clifford/clifford_2_2.py +35 -0
- qiskit/circuit/library/templates/clifford/clifford_2_3.py +34 -0
- qiskit/circuit/library/templates/clifford/clifford_2_4.py +34 -0
- qiskit/circuit/library/templates/clifford/clifford_3_1.py +35 -0
- qiskit/circuit/library/templates/clifford/clifford_4_1.py +38 -0
- qiskit/circuit/library/templates/clifford/clifford_4_2.py +37 -0
- qiskit/circuit/library/templates/clifford/clifford_4_3.py +38 -0
- qiskit/circuit/library/templates/clifford/clifford_4_4.py +37 -0
- qiskit/circuit/library/templates/clifford/clifford_5_1.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_6_1.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_6_2.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_6_3.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_6_4.py +38 -0
- qiskit/circuit/library/templates/clifford/clifford_6_5.py +40 -0
- qiskit/circuit/library/templates/clifford/clifford_8_1.py +42 -0
- qiskit/circuit/library/templates/clifford/clifford_8_2.py +42 -0
- qiskit/circuit/library/templates/clifford/clifford_8_3.py +41 -0
- qiskit/circuit/library/templates/nct/__init__.py +67 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_1.py +34 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_2.py +35 -0
- qiskit/circuit/library/templates/nct/template_nct_2a_3.py +37 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_2.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_4a_3.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_4b_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_4b_2.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_1.py +40 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_2.py +40 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_3.py +40 -0
- qiskit/circuit/library/templates/nct/template_nct_5a_4.py +39 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_1.py +40 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_2.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_3.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6a_4.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6b_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6b_2.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_6c_1.py +41 -0
- qiskit/circuit/library/templates/nct/template_nct_7a_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_7b_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_7c_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_7d_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_7e_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_9a_1.py +45 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_10.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_11.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_12.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_2.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_3.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_4.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_5.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_6.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_7.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_8.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9c_9.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_1.py +43 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_10.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_2.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_3.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_4.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_5.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_6.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_7.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_8.py +44 -0
- qiskit/circuit/library/templates/nct/template_nct_9d_9.py +44 -0
- qiskit/circuit/library/templates/rzx/__init__.py +25 -0
- qiskit/circuit/library/templates/rzx/rzx_cy.py +47 -0
- qiskit/circuit/library/templates/rzx/rzx_xz.py +54 -0
- qiskit/circuit/library/templates/rzx/rzx_yz.py +45 -0
- qiskit/circuit/library/templates/rzx/rzx_zz1.py +69 -0
- qiskit/circuit/library/templates/rzx/rzx_zz2.py +59 -0
- qiskit/circuit/library/templates/rzx/rzx_zz3.py +59 -0
- qiskit/circuit/measure.py +53 -0
- qiskit/circuit/operation.py +68 -0
- qiskit/circuit/parameter.py +188 -0
- qiskit/circuit/parameterexpression.py +737 -0
- qiskit/circuit/parametertable.py +119 -0
- qiskit/circuit/parametervector.py +140 -0
- qiskit/circuit/quantumcircuit.py +7610 -0
- qiskit/circuit/quantumcircuitdata.py +137 -0
- qiskit/circuit/random/__init__.py +50 -0
- qiskit/circuit/random/utils.py +755 -0
- qiskit/circuit/reset.py +37 -0
- qiskit/circuit/singleton.py +600 -0
- qiskit/circuit/store.py +89 -0
- qiskit/circuit/tools/__init__.py +16 -0
- qiskit/circuit/tools/pi_check.py +185 -0
- qiskit/circuit/twirling.py +145 -0
- qiskit/compiler/__init__.py +27 -0
- qiskit/compiler/transpiler.py +375 -0
- qiskit/converters/__init__.py +74 -0
- qiskit/converters/circuit_to_dag.py +80 -0
- qiskit/converters/circuit_to_dagdependency.py +49 -0
- qiskit/converters/circuit_to_dagdependency_v2.py +46 -0
- qiskit/converters/circuit_to_gate.py +107 -0
- qiskit/converters/circuit_to_instruction.py +142 -0
- qiskit/converters/dag_to_circuit.py +79 -0
- qiskit/converters/dag_to_dagdependency.py +54 -0
- qiskit/converters/dag_to_dagdependency_v2.py +43 -0
- qiskit/converters/dagdependency_to_circuit.py +40 -0
- qiskit/converters/dagdependency_to_dag.py +48 -0
- qiskit/dagcircuit/__init__.py +44 -0
- qiskit/dagcircuit/collect_blocks.py +403 -0
- qiskit/dagcircuit/dagcircuit.py +24 -0
- qiskit/dagcircuit/dagdependency.py +612 -0
- qiskit/dagcircuit/dagdependency_v2.py +566 -0
- qiskit/dagcircuit/dagdepnode.py +160 -0
- qiskit/dagcircuit/dagnode.py +193 -0
- qiskit/dagcircuit/exceptions.py +42 -0
- qiskit/exceptions.py +153 -0
- qiskit/passmanager/__init__.py +258 -0
- qiskit/passmanager/base_tasks.py +230 -0
- qiskit/passmanager/compilation_status.py +74 -0
- qiskit/passmanager/exceptions.py +19 -0
- qiskit/passmanager/flow_controllers.py +116 -0
- qiskit/passmanager/passmanager.py +353 -0
- qiskit/primitives/__init__.py +490 -0
- qiskit/primitives/backend_estimator_v2.py +530 -0
- qiskit/primitives/backend_sampler_v2.py +339 -0
- qiskit/primitives/base/__init__.py +20 -0
- qiskit/primitives/base/base_estimator.py +247 -0
- qiskit/primitives/base/base_primitive_job.py +78 -0
- qiskit/primitives/base/base_primitive_v1.py +45 -0
- qiskit/primitives/base/base_result_v1.py +65 -0
- qiskit/primitives/base/base_sampler.py +196 -0
- qiskit/primitives/base/estimator_result_v1.py +46 -0
- qiskit/primitives/base/sampler_result_v1.py +45 -0
- qiskit/primitives/base/validation_v1.py +250 -0
- qiskit/primitives/containers/__init__.py +26 -0
- qiskit/primitives/containers/bindings_array.py +391 -0
- qiskit/primitives/containers/bit_array.py +764 -0
- qiskit/primitives/containers/data_bin.py +172 -0
- qiskit/primitives/containers/estimator_pub.py +222 -0
- qiskit/primitives/containers/object_array.py +94 -0
- qiskit/primitives/containers/observables_array.py +380 -0
- qiskit/primitives/containers/primitive_result.py +53 -0
- qiskit/primitives/containers/pub_result.py +51 -0
- qiskit/primitives/containers/sampler_pub.py +193 -0
- qiskit/primitives/containers/sampler_pub_result.py +74 -0
- qiskit/primitives/containers/shape.py +129 -0
- qiskit/primitives/primitive_job.py +100 -0
- qiskit/primitives/statevector_estimator.py +175 -0
- qiskit/primitives/statevector_sampler.py +290 -0
- qiskit/primitives/utils.py +72 -0
- qiskit/providers/__init__.py +677 -0
- qiskit/providers/backend.py +364 -0
- qiskit/providers/basic_provider/__init__.py +47 -0
- qiskit/providers/basic_provider/basic_provider.py +121 -0
- qiskit/providers/basic_provider/basic_provider_job.py +65 -0
- qiskit/providers/basic_provider/basic_provider_tools.py +218 -0
- qiskit/providers/basic_provider/basic_simulator.py +693 -0
- qiskit/providers/basic_provider/exceptions.py +30 -0
- qiskit/providers/exceptions.py +33 -0
- qiskit/providers/fake_provider/__init__.py +69 -0
- qiskit/providers/fake_provider/generic_backend_v2.py +376 -0
- qiskit/providers/fake_provider/utils/__init__.py +15 -0
- qiskit/providers/job.py +147 -0
- qiskit/providers/jobstatus.py +30 -0
- qiskit/providers/options.py +273 -0
- qiskit/providers/providerutils.py +110 -0
- qiskit/qasm/libs/dummy/stdgates.inc +75 -0
- qiskit/qasm/libs/qelib1.inc +266 -0
- qiskit/qasm/libs/stdgates.inc +82 -0
- qiskit/qasm2/__init__.py +669 -0
- qiskit/qasm2/exceptions.py +27 -0
- qiskit/qasm2/export.py +364 -0
- qiskit/qasm2/parse.py +438 -0
- qiskit/qasm3/__init__.py +466 -0
- qiskit/qasm3/ast.py +796 -0
- qiskit/qasm3/exceptions.py +27 -0
- qiskit/qasm3/experimental.py +70 -0
- qiskit/qasm3/exporter.py +1363 -0
- qiskit/qasm3/printer.py +620 -0
- qiskit/qpy/__init__.py +2141 -0
- qiskit/qpy/binary_io/__init__.py +35 -0
- qiskit/qpy/binary_io/circuits.py +1687 -0
- qiskit/qpy/binary_io/parse_sympy_repr.py +126 -0
- qiskit/qpy/binary_io/schedules.py +288 -0
- qiskit/qpy/binary_io/value.py +1183 -0
- qiskit/qpy/common.py +361 -0
- qiskit/qpy/exceptions.py +53 -0
- qiskit/qpy/formats.py +458 -0
- qiskit/qpy/interface.py +384 -0
- qiskit/qpy/type_keys.py +415 -0
- qiskit/quantum_info/__init__.py +172 -0
- qiskit/quantum_info/analysis/__init__.py +17 -0
- qiskit/quantum_info/analysis/average.py +47 -0
- qiskit/quantum_info/analysis/distance.py +104 -0
- qiskit/quantum_info/analysis/make_observable.py +44 -0
- qiskit/quantum_info/analysis/z2_symmetries.py +484 -0
- qiskit/quantum_info/operators/__init__.py +29 -0
- qiskit/quantum_info/operators/base_operator.py +145 -0
- qiskit/quantum_info/operators/channel/__init__.py +29 -0
- qiskit/quantum_info/operators/channel/chi.py +191 -0
- qiskit/quantum_info/operators/channel/choi.py +218 -0
- qiskit/quantum_info/operators/channel/kraus.py +337 -0
- qiskit/quantum_info/operators/channel/ptm.py +204 -0
- qiskit/quantum_info/operators/channel/quantum_channel.py +348 -0
- qiskit/quantum_info/operators/channel/stinespring.py +296 -0
- qiskit/quantum_info/operators/channel/superop.py +373 -0
- qiskit/quantum_info/operators/channel/transformations.py +490 -0
- qiskit/quantum_info/operators/custom_iterator.py +48 -0
- qiskit/quantum_info/operators/dihedral/__init__.py +18 -0
- qiskit/quantum_info/operators/dihedral/dihedral.py +511 -0
- qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +216 -0
- qiskit/quantum_info/operators/dihedral/polynomial.py +313 -0
- qiskit/quantum_info/operators/dihedral/random.py +64 -0
- qiskit/quantum_info/operators/linear_op.py +25 -0
- qiskit/quantum_info/operators/measures.py +418 -0
- qiskit/quantum_info/operators/mixins/__init__.py +52 -0
- qiskit/quantum_info/operators/mixins/adjoint.py +52 -0
- qiskit/quantum_info/operators/mixins/group.py +171 -0
- qiskit/quantum_info/operators/mixins/linear.py +84 -0
- qiskit/quantum_info/operators/mixins/multiply.py +62 -0
- qiskit/quantum_info/operators/mixins/tolerances.py +72 -0
- qiskit/quantum_info/operators/op_shape.py +525 -0
- qiskit/quantum_info/operators/operator.py +869 -0
- qiskit/quantum_info/operators/operator_utils.py +76 -0
- qiskit/quantum_info/operators/predicates.py +183 -0
- qiskit/quantum_info/operators/random.py +154 -0
- qiskit/quantum_info/operators/scalar_op.py +254 -0
- qiskit/quantum_info/operators/symplectic/__init__.py +24 -0
- qiskit/quantum_info/operators/symplectic/base_pauli.py +719 -0
- qiskit/quantum_info/operators/symplectic/clifford.py +1032 -0
- qiskit/quantum_info/operators/symplectic/clifford_circuits.py +584 -0
- qiskit/quantum_info/operators/symplectic/pauli.py +755 -0
- qiskit/quantum_info/operators/symplectic/pauli_list.py +1242 -0
- qiskit/quantum_info/operators/symplectic/pauli_utils.py +40 -0
- qiskit/quantum_info/operators/symplectic/random.py +117 -0
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +1239 -0
- qiskit/quantum_info/operators/utils/__init__.py +20 -0
- qiskit/quantum_info/operators/utils/anti_commutator.py +36 -0
- qiskit/quantum_info/operators/utils/commutator.py +36 -0
- qiskit/quantum_info/operators/utils/double_commutator.py +76 -0
- qiskit/quantum_info/quaternion.py +156 -0
- qiskit/quantum_info/random.py +26 -0
- qiskit/quantum_info/states/__init__.py +28 -0
- qiskit/quantum_info/states/densitymatrix.py +857 -0
- qiskit/quantum_info/states/measures.py +288 -0
- qiskit/quantum_info/states/quantum_state.py +503 -0
- qiskit/quantum_info/states/random.py +157 -0
- qiskit/quantum_info/states/stabilizerstate.py +805 -0
- qiskit/quantum_info/states/statevector.py +977 -0
- qiskit/quantum_info/states/utils.py +247 -0
- qiskit/result/__init__.py +61 -0
- qiskit/result/counts.py +189 -0
- qiskit/result/distributions/__init__.py +17 -0
- qiskit/result/distributions/probability.py +100 -0
- qiskit/result/distributions/quasi.py +154 -0
- qiskit/result/exceptions.py +40 -0
- qiskit/result/models.py +241 -0
- qiskit/result/postprocess.py +239 -0
- qiskit/result/result.py +385 -0
- qiskit/result/sampled_expval.py +76 -0
- qiskit/result/utils.py +294 -0
- qiskit/synthesis/__init__.py +250 -0
- qiskit/synthesis/arithmetic/__init__.py +18 -0
- qiskit/synthesis/arithmetic/adders/__init__.py +18 -0
- qiskit/synthesis/arithmetic/adders/cdkm_ripple_carry_adder.py +154 -0
- qiskit/synthesis/arithmetic/adders/draper_qft_adder.py +107 -0
- qiskit/synthesis/arithmetic/adders/rv_ripple_carry_adder.py +156 -0
- qiskit/synthesis/arithmetic/adders/vbe_ripple_carry_adder.py +161 -0
- qiskit/synthesis/arithmetic/comparators/__init__.py +16 -0
- qiskit/synthesis/arithmetic/comparators/compare_2s.py +112 -0
- qiskit/synthesis/arithmetic/comparators/compare_greedy.py +66 -0
- qiskit/synthesis/arithmetic/multipliers/__init__.py +16 -0
- qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +103 -0
- qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +100 -0
- qiskit/synthesis/arithmetic/weighted_sum.py +155 -0
- qiskit/synthesis/boolean/__init__.py +13 -0
- qiskit/synthesis/boolean/boolean_expression.py +231 -0
- qiskit/synthesis/boolean/boolean_expression_synth.py +124 -0
- qiskit/synthesis/boolean/boolean_expression_visitor.py +96 -0
- qiskit/synthesis/clifford/__init__.py +19 -0
- qiskit/synthesis/clifford/clifford_decompose_ag.py +178 -0
- qiskit/synthesis/clifford/clifford_decompose_bm.py +46 -0
- qiskit/synthesis/clifford/clifford_decompose_full.py +64 -0
- qiskit/synthesis/clifford/clifford_decompose_greedy.py +58 -0
- qiskit/synthesis/clifford/clifford_decompose_layers.py +447 -0
- qiskit/synthesis/cnotdihedral/__init__.py +17 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +52 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +141 -0
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_two_qubits.py +266 -0
- qiskit/synthesis/discrete_basis/__init__.py +16 -0
- qiskit/synthesis/discrete_basis/generate_basis_approximations.py +53 -0
- qiskit/synthesis/discrete_basis/solovay_kitaev.py +280 -0
- qiskit/synthesis/evolution/__init__.py +21 -0
- qiskit/synthesis/evolution/evolution_synthesis.py +48 -0
- qiskit/synthesis/evolution/lie_trotter.py +123 -0
- qiskit/synthesis/evolution/matrix_synthesis.py +47 -0
- qiskit/synthesis/evolution/pauli_network.py +80 -0
- qiskit/synthesis/evolution/product_formula.py +316 -0
- qiskit/synthesis/evolution/qdrift.py +133 -0
- qiskit/synthesis/evolution/suzuki_trotter.py +227 -0
- qiskit/synthesis/linear/__init__.py +26 -0
- qiskit/synthesis/linear/cnot_synth.py +69 -0
- qiskit/synthesis/linear/linear_circuits_utils.py +128 -0
- qiskit/synthesis/linear/linear_depth_lnn.py +61 -0
- qiskit/synthesis/linear/linear_matrix_utils.py +27 -0
- qiskit/synthesis/linear_phase/__init__.py +17 -0
- qiskit/synthesis/linear_phase/cnot_phase_synth.py +206 -0
- qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +61 -0
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +58 -0
- qiskit/synthesis/multi_controlled/__init__.py +29 -0
- qiskit/synthesis/multi_controlled/mcmt_vchain.py +52 -0
- qiskit/synthesis/multi_controlled/mcx_synthesis.py +583 -0
- qiskit/synthesis/multi_controlled/multi_control_rotation_gates.py +205 -0
- qiskit/synthesis/one_qubit/__init__.py +15 -0
- qiskit/synthesis/one_qubit/one_qubit_decompose.py +288 -0
- qiskit/synthesis/permutation/__init__.py +18 -0
- qiskit/synthesis/permutation/permutation_full.py +78 -0
- qiskit/synthesis/permutation/permutation_lnn.py +54 -0
- qiskit/synthesis/permutation/permutation_reverse_lnn.py +93 -0
- qiskit/synthesis/permutation/permutation_utils.py +16 -0
- qiskit/synthesis/qft/__init__.py +16 -0
- qiskit/synthesis/qft/qft_decompose_full.py +97 -0
- qiskit/synthesis/qft/qft_decompose_lnn.py +61 -0
- qiskit/synthesis/stabilizer/__init__.py +16 -0
- qiskit/synthesis/stabilizer/stabilizer_circuit.py +149 -0
- qiskit/synthesis/stabilizer/stabilizer_decompose.py +194 -0
- qiskit/synthesis/two_qubit/__init__.py +20 -0
- qiskit/synthesis/two_qubit/local_invariance.py +63 -0
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +583 -0
- qiskit/synthesis/two_qubit/xx_decompose/__init__.py +19 -0
- qiskit/synthesis/two_qubit/xx_decompose/circuits.py +300 -0
- qiskit/synthesis/two_qubit/xx_decompose/decomposer.py +324 -0
- qiskit/synthesis/two_qubit/xx_decompose/embodiments.py +163 -0
- qiskit/synthesis/two_qubit/xx_decompose/paths.py +412 -0
- qiskit/synthesis/two_qubit/xx_decompose/polytopes.py +262 -0
- qiskit/synthesis/two_qubit/xx_decompose/utilities.py +40 -0
- qiskit/synthesis/two_qubit/xx_decompose/weyl.py +133 -0
- qiskit/synthesis/unitary/__init__.py +13 -0
- qiskit/synthesis/unitary/aqc/__init__.py +177 -0
- qiskit/synthesis/unitary/aqc/approximate.py +116 -0
- qiskit/synthesis/unitary/aqc/aqc.py +175 -0
- qiskit/synthesis/unitary/aqc/cnot_structures.py +300 -0
- qiskit/synthesis/unitary/aqc/cnot_unit_circuit.py +103 -0
- qiskit/synthesis/unitary/aqc/cnot_unit_objective.py +299 -0
- qiskit/synthesis/unitary/aqc/elementary_operations.py +108 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/__init__.py +164 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/fast_grad_utils.py +237 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/fast_gradient.py +226 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/layer.py +370 -0
- qiskit/synthesis/unitary/aqc/fast_gradient/pmatrix.py +312 -0
- qiskit/synthesis/unitary/qsd.py +359 -0
- qiskit/transpiler/__init__.py +1352 -0
- qiskit/transpiler/basepasses.py +190 -0
- qiskit/transpiler/coupling.py +500 -0
- qiskit/transpiler/exceptions.py +59 -0
- qiskit/transpiler/instruction_durations.py +263 -0
- qiskit/transpiler/layout.py +740 -0
- qiskit/transpiler/passes/__init__.py +278 -0
- qiskit/transpiler/passes/analysis/__init__.py +23 -0
- qiskit/transpiler/passes/analysis/count_ops.py +30 -0
- qiskit/transpiler/passes/analysis/count_ops_longest_path.py +26 -0
- qiskit/transpiler/passes/analysis/dag_longest_path.py +24 -0
- qiskit/transpiler/passes/analysis/depth.py +33 -0
- qiskit/transpiler/passes/analysis/num_qubits.py +26 -0
- qiskit/transpiler/passes/analysis/num_tensor_factors.py +26 -0
- qiskit/transpiler/passes/analysis/resource_estimation.py +41 -0
- qiskit/transpiler/passes/analysis/size.py +36 -0
- qiskit/transpiler/passes/analysis/width.py +27 -0
- qiskit/transpiler/passes/basis/__init__.py +19 -0
- qiskit/transpiler/passes/basis/basis_translator.py +138 -0
- qiskit/transpiler/passes/basis/decompose.py +137 -0
- qiskit/transpiler/passes/basis/translate_parameterized.py +175 -0
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +84 -0
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +110 -0
- qiskit/transpiler/passes/layout/__init__.py +26 -0
- qiskit/transpiler/passes/layout/_csp_custom_solver.py +65 -0
- qiskit/transpiler/passes/layout/apply_layout.py +128 -0
- qiskit/transpiler/passes/layout/csp_layout.py +132 -0
- qiskit/transpiler/passes/layout/dense_layout.py +197 -0
- qiskit/transpiler/passes/layout/disjoint_utils.py +54 -0
- qiskit/transpiler/passes/layout/enlarge_with_ancilla.py +49 -0
- qiskit/transpiler/passes/layout/full_ancilla_allocation.py +116 -0
- qiskit/transpiler/passes/layout/layout_2q_distance.py +77 -0
- qiskit/transpiler/passes/layout/sabre_layout.py +525 -0
- qiskit/transpiler/passes/layout/sabre_pre_layout.py +225 -0
- qiskit/transpiler/passes/layout/set_layout.py +69 -0
- qiskit/transpiler/passes/layout/trivial_layout.py +66 -0
- qiskit/transpiler/passes/layout/vf2_layout.py +292 -0
- qiskit/transpiler/passes/layout/vf2_post_layout.py +376 -0
- qiskit/transpiler/passes/layout/vf2_utils.py +245 -0
- qiskit/transpiler/passes/optimization/__init__.py +42 -0
- qiskit/transpiler/passes/optimization/_gate_extension.py +80 -0
- qiskit/transpiler/passes/optimization/collect_1q_runs.py +31 -0
- qiskit/transpiler/passes/optimization/collect_2q_blocks.py +35 -0
- qiskit/transpiler/passes/optimization/collect_and_collapse.py +117 -0
- qiskit/transpiler/passes/optimization/collect_cliffords.py +109 -0
- qiskit/transpiler/passes/optimization/collect_linear_functions.py +85 -0
- qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +242 -0
- qiskit/transpiler/passes/optimization/commutation_analysis.py +44 -0
- qiskit/transpiler/passes/optimization/commutative_cancellation.py +82 -0
- qiskit/transpiler/passes/optimization/commutative_inverse_cancellation.py +140 -0
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +176 -0
- qiskit/transpiler/passes/optimization/contract_idle_wires_in_control_flow.py +104 -0
- qiskit/transpiler/passes/optimization/elide_permutations.py +91 -0
- qiskit/transpiler/passes/optimization/hoare_opt.py +420 -0
- qiskit/transpiler/passes/optimization/inverse_cancellation.py +95 -0
- qiskit/transpiler/passes/optimization/light_cone.py +135 -0
- qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +267 -0
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +251 -0
- qiskit/transpiler/passes/optimization/optimize_1q_gates.py +384 -0
- qiskit/transpiler/passes/optimization/optimize_annotated.py +449 -0
- qiskit/transpiler/passes/optimization/optimize_clifford_t.py +68 -0
- qiskit/transpiler/passes/optimization/optimize_cliffords.py +89 -0
- qiskit/transpiler/passes/optimization/optimize_swap_before_measure.py +71 -0
- qiskit/transpiler/passes/optimization/remove_diagonal_gates_before_measure.py +41 -0
- qiskit/transpiler/passes/optimization/remove_final_reset.py +37 -0
- qiskit/transpiler/passes/optimization/remove_identity_equiv.py +70 -0
- qiskit/transpiler/passes/optimization/remove_reset_in_zero_state.py +37 -0
- qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +50 -0
- qiskit/transpiler/passes/optimization/split_2q_unitaries.py +63 -0
- qiskit/transpiler/passes/optimization/template_matching/__init__.py +19 -0
- qiskit/transpiler/passes/optimization/template_matching/backward_match.py +749 -0
- qiskit/transpiler/passes/optimization/template_matching/forward_match.py +452 -0
- qiskit/transpiler/passes/optimization/template_matching/maximal_matches.py +77 -0
- qiskit/transpiler/passes/optimization/template_matching/template_matching.py +370 -0
- qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +633 -0
- qiskit/transpiler/passes/optimization/template_optimization.py +158 -0
- qiskit/transpiler/passes/routing/__init__.py +21 -0
- qiskit/transpiler/passes/routing/algorithms/__init__.py +33 -0
- qiskit/transpiler/passes/routing/algorithms/token_swapper.py +105 -0
- qiskit/transpiler/passes/routing/algorithms/types.py +46 -0
- qiskit/transpiler/passes/routing/algorithms/util.py +103 -0
- qiskit/transpiler/passes/routing/basic_swap.py +166 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/__init__.py +25 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_block.py +60 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +397 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/pauli_2q_evolution_commutation.py +145 -0
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +306 -0
- qiskit/transpiler/passes/routing/layout_transformation.py +119 -0
- qiskit/transpiler/passes/routing/lookahead_swap.py +390 -0
- qiskit/transpiler/passes/routing/sabre_swap.py +465 -0
- qiskit/transpiler/passes/routing/star_prerouting.py +433 -0
- qiskit/transpiler/passes/routing/utils.py +35 -0
- qiskit/transpiler/passes/scheduling/__init__.py +21 -0
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +79 -0
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +70 -0
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +251 -0
- qiskit/transpiler/passes/scheduling/padding/__init__.py +17 -0
- qiskit/transpiler/passes/scheduling/padding/base_padding.py +284 -0
- qiskit/transpiler/passes/scheduling/padding/context_aware_dynamical_decoupling.py +876 -0
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +415 -0
- qiskit/transpiler/passes/scheduling/padding/pad_delay.py +90 -0
- qiskit/transpiler/passes/scheduling/scheduling/__init__.py +17 -0
- qiskit/transpiler/passes/scheduling/scheduling/alap.py +93 -0
- qiskit/transpiler/passes/scheduling/scheduling/asap.py +100 -0
- qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +88 -0
- qiskit/transpiler/passes/scheduling/scheduling/set_io_latency.py +64 -0
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +237 -0
- qiskit/transpiler/passes/synthesis/__init__.py +21 -0
- qiskit/transpiler/passes/synthesis/aqc_plugin.py +153 -0
- qiskit/transpiler/passes/synthesis/clifford_unitary_synth_plugin.py +123 -0
- qiskit/transpiler/passes/synthesis/default_unitary_synth_plugin.py +653 -0
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +429 -0
- qiskit/transpiler/passes/synthesis/hls_plugins.py +2338 -0
- qiskit/transpiler/passes/synthesis/linear_functions_synthesis.py +41 -0
- qiskit/transpiler/passes/synthesis/plugin.py +738 -0
- qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +318 -0
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +425 -0
- qiskit/transpiler/passes/utils/__init__.py +32 -0
- qiskit/transpiler/passes/utils/barrier_before_final_measurements.py +41 -0
- qiskit/transpiler/passes/utils/check_gate_direction.py +60 -0
- qiskit/transpiler/passes/utils/check_map.py +78 -0
- qiskit/transpiler/passes/utils/contains_instruction.py +45 -0
- qiskit/transpiler/passes/utils/control_flow.py +61 -0
- qiskit/transpiler/passes/utils/dag_fixed_point.py +36 -0
- qiskit/transpiler/passes/utils/error.py +69 -0
- qiskit/transpiler/passes/utils/filter_op_nodes.py +66 -0
- qiskit/transpiler/passes/utils/fixed_point.py +48 -0
- qiskit/transpiler/passes/utils/gate_direction.py +93 -0
- qiskit/transpiler/passes/utils/gates_basis.py +51 -0
- qiskit/transpiler/passes/utils/merge_adjacent_barriers.py +163 -0
- qiskit/transpiler/passes/utils/minimum_point.py +118 -0
- qiskit/transpiler/passes/utils/remove_barriers.py +50 -0
- qiskit/transpiler/passes/utils/remove_final_measurements.py +121 -0
- qiskit/transpiler/passes/utils/unroll_forloops.py +81 -0
- qiskit/transpiler/passmanager.py +503 -0
- qiskit/transpiler/passmanager_config.py +154 -0
- qiskit/transpiler/preset_passmanagers/__init__.py +93 -0
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +1114 -0
- qiskit/transpiler/preset_passmanagers/common.py +773 -0
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +443 -0
- qiskit/transpiler/preset_passmanagers/level0.py +104 -0
- qiskit/transpiler/preset_passmanagers/level1.py +108 -0
- qiskit/transpiler/preset_passmanagers/level2.py +109 -0
- qiskit/transpiler/preset_passmanagers/level3.py +110 -0
- qiskit/transpiler/preset_passmanagers/plugin.py +346 -0
- qiskit/transpiler/target.py +905 -0
- qiskit/transpiler/timing_constraints.py +59 -0
- qiskit/user_config.py +266 -0
- qiskit/utils/__init__.py +90 -0
- qiskit/utils/classtools.py +146 -0
- qiskit/utils/deprecation.py +382 -0
- qiskit/utils/lazy_tester.py +363 -0
- qiskit/utils/optionals.py +355 -0
- qiskit/utils/parallel.py +318 -0
- qiskit/utils/units.py +146 -0
- qiskit/version.py +84 -0
- qiskit/visualization/__init__.py +290 -0
- qiskit/visualization/array.py +207 -0
- qiskit/visualization/bloch.py +778 -0
- qiskit/visualization/circuit/__init__.py +15 -0
- qiskit/visualization/circuit/_utils.py +677 -0
- qiskit/visualization/circuit/circuit_visualization.py +735 -0
- qiskit/visualization/circuit/latex.py +668 -0
- qiskit/visualization/circuit/matplotlib.py +2041 -0
- qiskit/visualization/circuit/qcstyle.py +130 -0
- qiskit/visualization/circuit/styles/__init__.py +13 -0
- qiskit/visualization/circuit/styles/bw.json +202 -0
- qiskit/visualization/circuit/styles/clifford.json +202 -0
- qiskit/visualization/circuit/styles/iqp-dark.json +214 -0
- qiskit/visualization/circuit/styles/iqp.json +214 -0
- qiskit/visualization/circuit/styles/textbook.json +202 -0
- qiskit/visualization/circuit/text.py +1849 -0
- qiskit/visualization/circuit_visualization.py +19 -0
- qiskit/visualization/counts_visualization.py +487 -0
- qiskit/visualization/dag/__init__.py +13 -0
- qiskit/visualization/dag/dagstyle.py +103 -0
- qiskit/visualization/dag/styles/__init__.py +13 -0
- qiskit/visualization/dag/styles/color.json +10 -0
- qiskit/visualization/dag/styles/plain.json +5 -0
- qiskit/visualization/dag_visualization.py +389 -0
- qiskit/visualization/exceptions.py +21 -0
- qiskit/visualization/gate_map.py +1424 -0
- qiskit/visualization/library.py +40 -0
- qiskit/visualization/pass_manager_visualization.py +312 -0
- qiskit/visualization/state_visualization.py +1546 -0
- qiskit/visualization/style.py +223 -0
- qiskit/visualization/timeline/__init__.py +21 -0
- qiskit/visualization/timeline/core.py +495 -0
- qiskit/visualization/timeline/drawings.py +260 -0
- qiskit/visualization/timeline/generators.py +506 -0
- qiskit/visualization/timeline/interface.py +444 -0
- qiskit/visualization/timeline/layouts.py +115 -0
- qiskit/visualization/timeline/plotters/__init__.py +16 -0
- qiskit/visualization/timeline/plotters/base_plotter.py +58 -0
- qiskit/visualization/timeline/plotters/matplotlib.py +195 -0
- qiskit/visualization/timeline/stylesheet.py +301 -0
- qiskit/visualization/timeline/types.py +148 -0
- qiskit/visualization/transition_visualization.py +369 -0
- qiskit/visualization/utils.py +49 -0
- qiskit-2.1.0rc1.dist-info/METADATA +221 -0
- qiskit-2.1.0rc1.dist-info/RECORD +699 -0
- qiskit-2.1.0rc1.dist-info/WHEEL +6 -0
- qiskit-2.1.0rc1.dist-info/entry_points.txt +88 -0
- qiskit-2.1.0rc1.dist-info/licenses/LICENSE.txt +203 -0
- qiskit-2.1.0rc1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1936 @@
|
|
1
|
+
# This code is part of Qiskit.
|
2
|
+
#
|
3
|
+
# (C) Copyright IBM 2017.
|
4
|
+
#
|
5
|
+
# This code is licensed under the Apache License, Version 2.0. You may
|
6
|
+
# obtain a copy of this license in the LICENSE.txt file in the root directory
|
7
|
+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
|
8
|
+
#
|
9
|
+
# Any modifications or derivative works of this code must retain this
|
10
|
+
# copyright notice, and modified files need to carry a notice indicating
|
11
|
+
# that they have been altered from the originals.
|
12
|
+
|
13
|
+
"""Standard gates."""
|
14
|
+
|
15
|
+
from __future__ import annotations
|
16
|
+
|
17
|
+
from math import pi
|
18
|
+
|
19
|
+
from qiskit.circuit import (
|
20
|
+
EquivalenceLibrary,
|
21
|
+
Parameter,
|
22
|
+
QuantumCircuit,
|
23
|
+
QuantumRegister,
|
24
|
+
Gate,
|
25
|
+
Qubit,
|
26
|
+
Clbit,
|
27
|
+
)
|
28
|
+
|
29
|
+
from . import (
|
30
|
+
HGate,
|
31
|
+
CHGate,
|
32
|
+
PhaseGate,
|
33
|
+
CPhaseGate,
|
34
|
+
RGate,
|
35
|
+
RCCXGate,
|
36
|
+
RXGate,
|
37
|
+
CRXGate,
|
38
|
+
RXXGate,
|
39
|
+
RYGate,
|
40
|
+
CRYGate,
|
41
|
+
RZGate,
|
42
|
+
CRZGate,
|
43
|
+
RZZGate,
|
44
|
+
RZXGate,
|
45
|
+
SGate,
|
46
|
+
SdgGate,
|
47
|
+
CSGate,
|
48
|
+
CSdgGate,
|
49
|
+
SwapGate,
|
50
|
+
CSwapGate,
|
51
|
+
iSwapGate,
|
52
|
+
SXGate,
|
53
|
+
SXdgGate,
|
54
|
+
CSXGate,
|
55
|
+
DCXGate,
|
56
|
+
TGate,
|
57
|
+
TdgGate,
|
58
|
+
UGate,
|
59
|
+
CUGate,
|
60
|
+
U1Gate,
|
61
|
+
CU1Gate,
|
62
|
+
U2Gate,
|
63
|
+
U3Gate,
|
64
|
+
CU3Gate,
|
65
|
+
XGate,
|
66
|
+
CXGate,
|
67
|
+
CCXGate,
|
68
|
+
YGate,
|
69
|
+
CYGate,
|
70
|
+
RYYGate,
|
71
|
+
ECRGate,
|
72
|
+
ZGate,
|
73
|
+
CZGate,
|
74
|
+
IGate,
|
75
|
+
CCZGate,
|
76
|
+
XXPlusYYGate,
|
77
|
+
XXMinusYYGate,
|
78
|
+
)
|
79
|
+
|
80
|
+
|
81
|
+
_sel = StandardEquivalenceLibrary = EquivalenceLibrary()
|
82
|
+
|
83
|
+
|
84
|
+
def _cnot_rxx_decompose(plus_ry: bool = True, plus_rxx: bool = True):
|
85
|
+
"""Decomposition of CNOT gate.
|
86
|
+
|
87
|
+
NOTE: this differs to CNOT by a global phase.
|
88
|
+
The matrix returned is given by exp(1j * pi/4) * CNOT
|
89
|
+
|
90
|
+
Args:
|
91
|
+
plus_ry (bool): positive initial RY rotation
|
92
|
+
plus_rxx (bool): positive RXX rotation.
|
93
|
+
|
94
|
+
Returns:
|
95
|
+
QuantumCircuit: The decomposed circuit for CNOT gate (up to
|
96
|
+
global phase).
|
97
|
+
"""
|
98
|
+
# Convert boolean args to +/- 1 signs
|
99
|
+
if plus_ry:
|
100
|
+
sgn_ry = 1
|
101
|
+
else:
|
102
|
+
sgn_ry = -1
|
103
|
+
if plus_rxx:
|
104
|
+
sgn_rxx = 1
|
105
|
+
else:
|
106
|
+
sgn_rxx = -1
|
107
|
+
circuit = QuantumCircuit(2, global_phase=-sgn_ry * sgn_rxx * pi / 4)
|
108
|
+
circuit.append(RYGate(sgn_ry * pi / 2), [0])
|
109
|
+
circuit.append(RXXGate(sgn_rxx * pi / 2), [0, 1])
|
110
|
+
circuit.append(RXGate(-sgn_rxx * pi / 2), [0])
|
111
|
+
circuit.append(RXGate(-sgn_rxx * sgn_ry * pi / 2), [1])
|
112
|
+
circuit.append(RYGate(-sgn_ry * pi / 2), [0])
|
113
|
+
return circuit
|
114
|
+
|
115
|
+
|
116
|
+
# Import existing gate definitions
|
117
|
+
|
118
|
+
# HGate
|
119
|
+
#
|
120
|
+
# ┌───┐ ┌───────────┐
|
121
|
+
# q: ┤ H ├ ≡ q: ┤ U(0, 0,π) ├
|
122
|
+
# └───┘ └───────────┘
|
123
|
+
q = QuantumRegister(1, "q")
|
124
|
+
def_h = QuantumCircuit(q)
|
125
|
+
def_h.append(UGate(pi / 2, 0, pi), [q[0]], [])
|
126
|
+
_sel.add_equivalence(HGate(), def_h)
|
127
|
+
|
128
|
+
# HGate
|
129
|
+
#
|
130
|
+
# ┌───┐ ┌─────────┐
|
131
|
+
# q: ┤ H ├ ≡ q: ┤ U2(0,π) ├
|
132
|
+
# └───┘ └─────────┘
|
133
|
+
q = QuantumRegister(1, "q")
|
134
|
+
def_h = QuantumCircuit(q)
|
135
|
+
def_h.append(U2Gate(0, pi), [q[0]], [])
|
136
|
+
_sel.add_equivalence(HGate(), def_h)
|
137
|
+
|
138
|
+
# CHGate
|
139
|
+
#
|
140
|
+
# q_0: ──■── q_0: ─────────────────■─────────────────────
|
141
|
+
# ┌─┴─┐ ≡ ┌───┐┌───┐┌───┐┌─┴─┐┌─────┐┌───┐┌─────┐
|
142
|
+
# q_1: ┤ H ├ q_1: ┤ S ├┤ H ├┤ T ├┤ X ├┤ Tdg ├┤ H ├┤ Sdg ├
|
143
|
+
# └───┘ └───┘└───┘└───┘└───┘└─────┘└───┘└─────┘
|
144
|
+
q = QuantumRegister(2, "q")
|
145
|
+
def_ch = QuantumCircuit(q)
|
146
|
+
for inst, qargs, cargs in [
|
147
|
+
(SGate(), [q[1]], []),
|
148
|
+
(HGate(), [q[1]], []),
|
149
|
+
(TGate(), [q[1]], []),
|
150
|
+
(CXGate(), [q[0], q[1]], []),
|
151
|
+
(TdgGate(), [q[1]], []),
|
152
|
+
(HGate(), [q[1]], []),
|
153
|
+
(SdgGate(), [q[1]], []),
|
154
|
+
]:
|
155
|
+
def_ch.append(inst, qargs, cargs)
|
156
|
+
_sel.add_equivalence(CHGate(), def_ch)
|
157
|
+
|
158
|
+
# PhaseGate
|
159
|
+
#
|
160
|
+
# ┌──────┐ ┌───────┐
|
161
|
+
# q: ┤ P(ϴ) ├ ≡ q: ┤ U1(ϴ) ├
|
162
|
+
# └──────┘ └───────┘
|
163
|
+
q = QuantumRegister(1, "q")
|
164
|
+
theta = Parameter("theta")
|
165
|
+
phase_to_u1 = QuantumCircuit(q)
|
166
|
+
phase_to_u1.append(U1Gate(theta), [0])
|
167
|
+
_sel.add_equivalence(PhaseGate(theta), phase_to_u1)
|
168
|
+
|
169
|
+
q = QuantumRegister(1, "q")
|
170
|
+
theta = Parameter("theta")
|
171
|
+
phase_to_u = QuantumCircuit(q)
|
172
|
+
phase_to_u.u(0, 0, theta, 0)
|
173
|
+
_sel.add_equivalence(PhaseGate(theta), phase_to_u)
|
174
|
+
|
175
|
+
# CPhaseGate
|
176
|
+
# ┌────────┐
|
177
|
+
# q_0: ─■──── q_0: ┤ P(ϴ/2) ├──■───────────────■────────────
|
178
|
+
# │P(ϴ) ≡ └────────┘┌─┴─┐┌─────────┐┌─┴─┐┌────────┐
|
179
|
+
# q_1: ─■──── q_1: ──────────┤ X ├┤ P(-ϴ/2) ├┤ X ├┤ P(ϴ/2) ├
|
180
|
+
# └───┘└─────────┘└───┘└────────┘
|
181
|
+
q = QuantumRegister(2, "q")
|
182
|
+
theta = Parameter("theta")
|
183
|
+
def_cphase = QuantumCircuit(q)
|
184
|
+
def_cphase.p(theta / 2, 0)
|
185
|
+
def_cphase.cx(0, 1)
|
186
|
+
def_cphase.p(-theta / 2, 1)
|
187
|
+
def_cphase.cx(0, 1)
|
188
|
+
def_cphase.p(theta / 2, 1)
|
189
|
+
_sel.add_equivalence(CPhaseGate(theta), def_cphase)
|
190
|
+
|
191
|
+
# CPhaseGate
|
192
|
+
#
|
193
|
+
# q_0: ─■──── q_0: ─■────
|
194
|
+
# │P(ϴ) ≡ │U1(ϴ)
|
195
|
+
# q_1: ─■──── q_1: ─■────
|
196
|
+
q = QuantumRegister(2, "q")
|
197
|
+
theta = Parameter("theta")
|
198
|
+
cphase_to_cu1 = QuantumCircuit(q)
|
199
|
+
cphase_to_cu1.append(CU1Gate(theta), [0, 1])
|
200
|
+
_sel.add_equivalence(CPhaseGate(theta), cphase_to_cu1)
|
201
|
+
|
202
|
+
# CPhaseGate
|
203
|
+
#
|
204
|
+
# global phase: ϴ/4
|
205
|
+
# ┌─────────┐
|
206
|
+
# q_0: ─■──── q_0: ─■─────────┤ Rz(ϴ/2) ├
|
207
|
+
# │P(ϴ) ≡ │ZZ(-ϴ/2) ├─────────┤
|
208
|
+
# q_1: ─■──── q_1: ─■─────────┤ Rz(ϴ/2) ├
|
209
|
+
# └─────────┘
|
210
|
+
theta = Parameter("theta")
|
211
|
+
cphase_to_rzz = QuantumCircuit(2, global_phase=theta / 4)
|
212
|
+
cphase_to_rzz.rzz(-theta / 2, 0, 1)
|
213
|
+
cphase_to_rzz.rz(theta / 2, 0)
|
214
|
+
cphase_to_rzz.rz(theta / 2, 1)
|
215
|
+
_sel.add_equivalence(CPhaseGate(theta), cphase_to_rzz)
|
216
|
+
|
217
|
+
# RGate
|
218
|
+
#
|
219
|
+
# ┌────────┐ ┌──────────────────────┐
|
220
|
+
# q: ┤ R(ϴ,φ) ├ ≡ q: ┤ U(ϴ,φ - π/2,π/2 - φ) ├
|
221
|
+
# └────────┘ └──────────────────────┘
|
222
|
+
q = QuantumRegister(1, "q")
|
223
|
+
theta = Parameter("theta")
|
224
|
+
phi = Parameter("phi")
|
225
|
+
def_r = QuantumCircuit(q)
|
226
|
+
def_r.append(UGate(theta, phi - pi / 2, -phi + pi / 2), [q[0]])
|
227
|
+
_sel.add_equivalence(RGate(theta, phi), def_r)
|
228
|
+
|
229
|
+
# IGate
|
230
|
+
q = QuantumRegister(1, "q")
|
231
|
+
def_id = QuantumCircuit(q)
|
232
|
+
def_id.append(UGate(0, 0, 0), [q[0]])
|
233
|
+
_sel.add_equivalence(IGate(), def_id)
|
234
|
+
|
235
|
+
q = QuantumRegister(1, "q")
|
236
|
+
def_id_rx = QuantumCircuit(q)
|
237
|
+
def_id_rx.append(RXGate(0), [q[0]])
|
238
|
+
_sel.add_equivalence(IGate(), def_id_rx)
|
239
|
+
|
240
|
+
q = QuantumRegister(1, "q")
|
241
|
+
def_id_ry = QuantumCircuit(q)
|
242
|
+
def_id_ry.append(RYGate(0), [q[0]])
|
243
|
+
_sel.add_equivalence(IGate(), def_id_ry)
|
244
|
+
|
245
|
+
q = QuantumRegister(1, "q")
|
246
|
+
def_id_rz = QuantumCircuit(q)
|
247
|
+
def_id_rz.append(RZGate(0), [q[0]])
|
248
|
+
_sel.add_equivalence(IGate(), def_id_rz)
|
249
|
+
|
250
|
+
# RCCXGate
|
251
|
+
#
|
252
|
+
# ┌───────┐
|
253
|
+
# q_0: ┤0 ├ q_0: ────────────────────────■────────────────────────
|
254
|
+
# │ │ │
|
255
|
+
# q_1: ┤1 Rccx ├ ≡ q_1: ────────────■───────────┼─────────■──────────────
|
256
|
+
# │ │ ┌───┐┌───┐┌─┴─┐┌─────┐┌─┴─┐┌───┐┌─┴─┐┌─────┐┌───┐
|
257
|
+
# q_2: ┤2 ├ q_2: ┤ H ├┤ T ├┤ X ├┤ Tdg ├┤ X ├┤ T ├┤ X ├┤ Tdg ├┤ H ├
|
258
|
+
# └───────┘ └───┘└───┘└───┘└─────┘└───┘└───┘└───┘└─────┘└───┘
|
259
|
+
q = QuantumRegister(3, "q")
|
260
|
+
def_rccx = QuantumCircuit(q)
|
261
|
+
for inst, qargs, cargs in [
|
262
|
+
(HGate(), [q[2]], []),
|
263
|
+
(TGate(), [q[2]], []),
|
264
|
+
(CXGate(), [q[1], q[2]], []),
|
265
|
+
(TdgGate(), [q[2]], []),
|
266
|
+
(CXGate(), [q[0], q[2]], []),
|
267
|
+
(TGate(), [q[2]], []),
|
268
|
+
(CXGate(), [q[1], q[2]], []),
|
269
|
+
(TdgGate(), [q[2]], []),
|
270
|
+
(HGate(), [q[2]], []),
|
271
|
+
]:
|
272
|
+
def_rccx.append(inst, qargs, cargs)
|
273
|
+
_sel.add_equivalence(RCCXGate(), def_rccx)
|
274
|
+
|
275
|
+
# RXGate
|
276
|
+
#
|
277
|
+
# ┌───────┐ ┌────────┐
|
278
|
+
# q: ┤ Rx(ϴ) ├ ≡ q: ┤ R(ϴ,0) ├
|
279
|
+
# └───────┘ └────────┘
|
280
|
+
q = QuantumRegister(1, "q")
|
281
|
+
theta = Parameter("theta")
|
282
|
+
def_rx = QuantumCircuit(q)
|
283
|
+
def_rx.append(RGate(theta, 0), [q[0]], [])
|
284
|
+
_sel.add_equivalence(RXGate(theta), def_rx)
|
285
|
+
|
286
|
+
# CRXGate
|
287
|
+
#
|
288
|
+
# q_0: ────■──── q_0: ─────────────■────────────────────■────────────────────
|
289
|
+
# ┌───┴───┐ ≡ ┌─────────┐┌─┴─┐┌──────────────┐┌─┴─┐┌────────────────┐
|
290
|
+
# q_1: ┤ Rx(ϴ) ├ q_1: ┤ U1(π/2) ├┤ X ├┤ U3(-ϴ/2,0,0) ├┤ X ├┤ U3(ϴ/2,-π/2,0) ├
|
291
|
+
# └───────┘ └─────────┘└───┘└──────────────┘└───┘└────────────────┘
|
292
|
+
q = QuantumRegister(2, "q")
|
293
|
+
theta = Parameter("theta")
|
294
|
+
def_crx = QuantumCircuit(q)
|
295
|
+
for inst, qargs, cargs in [
|
296
|
+
(SGate(), [q[1]], []),
|
297
|
+
(CXGate(), [q[0], q[1]], []),
|
298
|
+
(UGate(-theta / 2, 0, 0), [q[1]], []),
|
299
|
+
(CXGate(), [q[0], q[1]], []),
|
300
|
+
(UGate(theta / 2, -pi / 2, 0), [q[1]], []),
|
301
|
+
]:
|
302
|
+
def_crx.append(inst, qargs, cargs)
|
303
|
+
_sel.add_equivalence(CRXGate(theta), def_crx)
|
304
|
+
|
305
|
+
# CRXGate
|
306
|
+
#
|
307
|
+
# q_0: ────■──── q_0: ───────■────────────────■────────────────────
|
308
|
+
# ┌───┴───┐ ≡ ┌───┐┌─┴─┐┌──────────┐┌─┴─┐┌─────────┐┌─────┐
|
309
|
+
# q_1: ┤ Rx(ϴ) ├ q_1: ┤ S ├┤ X ├┤ Ry(-ϴ/2) ├┤ X ├┤ Ry(ϴ/2) ├┤ Sdg ├
|
310
|
+
# └───────┘ └───┘└───┘└──────────┘└───┘└─────────┘└─────┘
|
311
|
+
q = QuantumRegister(2, "q")
|
312
|
+
theta = Parameter("theta")
|
313
|
+
crx_to_srycx = QuantumCircuit(q)
|
314
|
+
for inst, qargs, cargs in [
|
315
|
+
(SGate(), [q[1]], []),
|
316
|
+
(CXGate(), [q[0], q[1]], []),
|
317
|
+
(RYGate(-theta / 2), [q[1]], []),
|
318
|
+
(CXGate(), [q[0], q[1]], []),
|
319
|
+
(RYGate(theta / 2), [q[1]], []),
|
320
|
+
(SdgGate(), [q[1]], []),
|
321
|
+
]:
|
322
|
+
crx_to_srycx.append(inst, qargs, cargs)
|
323
|
+
_sel.add_equivalence(CRXGate(theta), crx_to_srycx)
|
324
|
+
|
325
|
+
# CRX in terms of one RXX
|
326
|
+
# ┌───┐ ┌────────────┐┌───┐
|
327
|
+
# q_0: ────■──── q_0: ───┤ H ├───┤0 ├┤ H ├
|
328
|
+
# ┌───┴───┐ ≡ ┌──┴───┴──┐│ Rxx(-ϴ/2) │└───┘
|
329
|
+
# q_1: ┤ Rx(ϴ) ├ q_1: ┤ Rx(ϴ/2) ├┤1 ├─────
|
330
|
+
# └───────┘ └─────────┘└────────────┘
|
331
|
+
theta = Parameter("theta")
|
332
|
+
crx_to_rxx = QuantumCircuit(2)
|
333
|
+
crx_to_rxx.h(0)
|
334
|
+
crx_to_rxx.rx(theta / 2, 1)
|
335
|
+
crx_to_rxx.rxx(-theta / 2, 0, 1)
|
336
|
+
crx_to_rxx.h(0)
|
337
|
+
_sel.add_equivalence(CRXGate(theta), crx_to_rxx)
|
338
|
+
|
339
|
+
# CRX to CRZ
|
340
|
+
#
|
341
|
+
# q_0: ────■──── q_0: ─────────■─────────
|
342
|
+
# ┌───┴───┐ ≡ ┌───┐┌───┴───┐┌───┐
|
343
|
+
# q_1: ┤ Rx(ϴ) ├ q_1: ┤ H ├┤ Rz(ϴ) ├┤ H ├
|
344
|
+
# └───────┘ └───┘└───────┘└───┘
|
345
|
+
theta = Parameter("theta")
|
346
|
+
crx_to_crz = QuantumCircuit(2)
|
347
|
+
crx_to_crz.h(1)
|
348
|
+
crx_to_crz.crz(theta, 0, 1)
|
349
|
+
crx_to_crz.h(1)
|
350
|
+
_sel.add_equivalence(CRXGate(theta), crx_to_crz)
|
351
|
+
|
352
|
+
# RXXGate
|
353
|
+
#
|
354
|
+
# ┌─────────┐ ┌───┐ ┌───┐
|
355
|
+
# q_0: ┤0 ├ q_0: ┤ H ├──■─────────────■──┤ H ├
|
356
|
+
# │ Rxx(ϴ) │ ≡ ├───┤┌─┴─┐┌───────┐┌─┴─┐├───┤
|
357
|
+
# q_1: ┤1 ├ q_1: ┤ H ├┤ X ├┤ Rz(ϴ) ├┤ X ├┤ H ├
|
358
|
+
# └─────────┘ └───┘└───┘└───────┘└───┘└───┘
|
359
|
+
q = QuantumRegister(2, "q")
|
360
|
+
theta = Parameter("theta")
|
361
|
+
def_rxx = QuantumCircuit(q)
|
362
|
+
for inst, qargs, cargs in [
|
363
|
+
(HGate(), [q[0]], []),
|
364
|
+
(HGate(), [q[1]], []),
|
365
|
+
(CXGate(), [q[0], q[1]], []),
|
366
|
+
(RZGate(theta), [q[1]], []),
|
367
|
+
(CXGate(), [q[0], q[1]], []),
|
368
|
+
(HGate(), [q[1]], []),
|
369
|
+
(HGate(), [q[0]], []),
|
370
|
+
]:
|
371
|
+
def_rxx.append(inst, qargs, cargs)
|
372
|
+
_sel.add_equivalence(RXXGate(theta), def_rxx)
|
373
|
+
|
374
|
+
# RXX to RZX
|
375
|
+
# ┌─────────┐ ┌───┐┌─────────┐┌───┐
|
376
|
+
# q_0: ┤0 ├ q_0: ┤ H ├┤0 ├┤ H ├
|
377
|
+
# │ Rxx(ϴ) │ ≡ └───┘│ Rzx(ϴ) │└───┘
|
378
|
+
# q_1: ┤1 ├ q_1: ─────┤1 ├─────
|
379
|
+
# └─────────┘ └─────────┘
|
380
|
+
theta = Parameter("theta")
|
381
|
+
rxx_to_rzx = QuantumCircuit(2)
|
382
|
+
rxx_to_rzx.h(0)
|
383
|
+
rxx_to_rzx.rzx(theta, 0, 1)
|
384
|
+
rxx_to_rzx.h(0)
|
385
|
+
_sel.add_equivalence(RXXGate(theta), rxx_to_rzx)
|
386
|
+
|
387
|
+
|
388
|
+
# RXX to RZZ
|
389
|
+
q = QuantumRegister(2, "q")
|
390
|
+
theta = Parameter("theta")
|
391
|
+
rxx_to_rzz = QuantumCircuit(q)
|
392
|
+
for inst, qargs, cargs in [
|
393
|
+
(HGate(), [q[0]], []),
|
394
|
+
(HGate(), [q[1]], []),
|
395
|
+
(RZZGate(theta), [q[0], q[1]], []),
|
396
|
+
(HGate(), [q[0]], []),
|
397
|
+
(HGate(), [q[1]], []),
|
398
|
+
]:
|
399
|
+
rxx_to_rzz.append(inst, qargs, cargs)
|
400
|
+
_sel.add_equivalence(RXXGate(theta), rxx_to_rzz)
|
401
|
+
|
402
|
+
# RZXGate
|
403
|
+
#
|
404
|
+
# ┌─────────┐
|
405
|
+
# q_0: ┤0 ├ q_0: ───────■─────────────■───────
|
406
|
+
# │ Rzx(ϴ) │ ≡ ┌───┐┌─┴─┐┌───────┐┌─┴─┐┌───┐
|
407
|
+
# q_1: ┤1 ├ q_1: ┤ H ├┤ X ├┤ Rz(ϴ) ├┤ X ├┤ H ├
|
408
|
+
# └─────────┘ └───┘└───┘└───────┘└───┘└───┘
|
409
|
+
q = QuantumRegister(2, "q")
|
410
|
+
theta = Parameter("theta")
|
411
|
+
def_rzx = QuantumCircuit(q)
|
412
|
+
for inst, qargs, cargs in [
|
413
|
+
(HGate(), [q[1]], []),
|
414
|
+
(CXGate(), [q[0], q[1]], []),
|
415
|
+
(RZGate(theta), [q[1]], []),
|
416
|
+
(CXGate(), [q[0], q[1]], []),
|
417
|
+
(HGate(), [q[1]], []),
|
418
|
+
]:
|
419
|
+
def_rzx.append(inst, qargs, cargs)
|
420
|
+
_sel.add_equivalence(RZXGate(theta), def_rzx)
|
421
|
+
|
422
|
+
# RZXGate to RZZGate
|
423
|
+
# ┌─────────┐
|
424
|
+
# q_0: ┤0 ├ q_0: ──────■───────────
|
425
|
+
# │ Rzx(ϴ) │ ≡ ┌───┐ │ZZ(ϴ) ┌───┐
|
426
|
+
# q_1: ┤1 ├ q_1: ┤ H ├─■──────┤ H ├
|
427
|
+
# └─────────┘ └───┘ └───┘
|
428
|
+
theta = Parameter("theta")
|
429
|
+
rzx_to_rzz = QuantumCircuit(2)
|
430
|
+
rzx_to_rzz.h(1)
|
431
|
+
rzx_to_rzz.rzz(theta, 0, 1)
|
432
|
+
rzx_to_rzz.h(1)
|
433
|
+
_sel.add_equivalence(RZXGate(theta), rzx_to_rzz)
|
434
|
+
|
435
|
+
|
436
|
+
# RYGate
|
437
|
+
#
|
438
|
+
# ┌───────┐ ┌──────────┐
|
439
|
+
# q: ┤ Ry(ϴ) ├ ≡ q: ┤ R(ϴ,π/2) ├
|
440
|
+
# └───────┘ └──────────┘
|
441
|
+
q = QuantumRegister(1, "q")
|
442
|
+
theta = Parameter("theta")
|
443
|
+
def_ry = QuantumCircuit(q)
|
444
|
+
def_ry.append(RGate(theta, pi / 2), [q[0]], [])
|
445
|
+
_sel.add_equivalence(RYGate(theta), def_ry)
|
446
|
+
|
447
|
+
q = QuantumRegister(1, "q")
|
448
|
+
ry_to_rx = QuantumCircuit(q)
|
449
|
+
ry_to_rx.sdg(0)
|
450
|
+
ry_to_rx.rx(theta, 0)
|
451
|
+
ry_to_rx.s(0)
|
452
|
+
_sel.add_equivalence(RYGate(theta), ry_to_rx)
|
453
|
+
|
454
|
+
# CRYGate
|
455
|
+
#
|
456
|
+
# q_0: ────■──── q_0: ─────────────■────────────────■──
|
457
|
+
# ┌───┴───┐ ≡ ┌─────────┐┌─┴─┐┌──────────┐┌─┴─┐
|
458
|
+
# q_1: ┤ Ry(ϴ) ├ q_1: ┤ Ry(ϴ/2) ├┤ X ├┤ Ry(-ϴ/2) ├┤ X ├
|
459
|
+
# └───────┘ └─────────┘└───┘└──────────┘└───┘
|
460
|
+
q = QuantumRegister(2, "q")
|
461
|
+
theta = Parameter("theta")
|
462
|
+
def_cry = QuantumCircuit(q)
|
463
|
+
for inst, qargs, cargs in [
|
464
|
+
(RYGate(theta / 2), [q[1]], []),
|
465
|
+
(CXGate(), [q[0], q[1]], []),
|
466
|
+
(RYGate(-theta / 2), [q[1]], []),
|
467
|
+
(CXGate(), [q[0], q[1]], []),
|
468
|
+
]:
|
469
|
+
def_cry.append(inst, qargs, cargs)
|
470
|
+
_sel.add_equivalence(CRYGate(theta), def_cry)
|
471
|
+
|
472
|
+
# CRY to CRZ
|
473
|
+
#
|
474
|
+
# q_0: ────■──── q_0: ───────────────■────────────────
|
475
|
+
# ┌───┴───┐ ≡ ┌─────────┐┌───┴───┐┌──────────┐
|
476
|
+
# q_1: ┤ Ry(ϴ) ├ q_1: ┤ Rx(π/2) ├┤ Rz(ϴ) ├┤ Rx(-π/2) ├
|
477
|
+
# └───────┘ └─────────┘└───────┘└──────────┘
|
478
|
+
theta = Parameter("theta")
|
479
|
+
cry_to_crz = QuantumCircuit(2)
|
480
|
+
cry_to_crz.rx(pi / 2, 1)
|
481
|
+
cry_to_crz.crz(theta, 0, 1)
|
482
|
+
cry_to_crz.rx(-pi / 2, 1)
|
483
|
+
_sel.add_equivalence(CRYGate(theta), cry_to_crz)
|
484
|
+
|
485
|
+
# CRY to CRZ
|
486
|
+
#
|
487
|
+
# q_0: ────■──── q_0: ────────────────────■─────────────────────
|
488
|
+
# ┌───┴───┐ ≡ ┌───┐┌─────────┐┌───┴───┐┌──────────┐┌───┐
|
489
|
+
# q_1: ┤ Ry(ϴ) ├ q_1: ┤ H ├┤ Rz(π/2) ├┤ Rx(ϴ) ├┤ Rz(-π/2) ├┤ H ├
|
490
|
+
# └───────┘ └───┘└─────────┘└───────┘└──────────┘└───┘
|
491
|
+
theta = Parameter("theta")
|
492
|
+
cry_to_crx = QuantumCircuit(2)
|
493
|
+
cry_to_crx.h(1)
|
494
|
+
cry_to_crx.rz(pi / 2, 1)
|
495
|
+
cry_to_crx.crx(theta, 0, 1)
|
496
|
+
cry_to_crx.rz(-pi / 2, 1)
|
497
|
+
cry_to_crx.h(1)
|
498
|
+
_sel.add_equivalence(CRYGate(theta), cry_to_crx)
|
499
|
+
|
500
|
+
# CRY to RZZ
|
501
|
+
#
|
502
|
+
# q_0: ────■──── q_0: ────────────────────────■───────────────────
|
503
|
+
# ┌───┴───┐ ≡ ┌─────┐┌─────────┐┌───┐ │ZZ(-ϴ/2) ┌───┐┌───┐
|
504
|
+
# q_1: ┤ Ry(ϴ) ├ q_1: ┤ Sdg ├┤ Rx(ϴ/2) ├┤ H ├─■─────────┤ H ├┤ S ├
|
505
|
+
# └───────┘ └─────┘└─────────┘└───┘ └───┘└───┘
|
506
|
+
cry_to_rzz = QuantumCircuit(2)
|
507
|
+
cry_to_rzz.sdg(1)
|
508
|
+
cry_to_rzz.rx(theta / 2, 1)
|
509
|
+
cry_to_rzz.h(1)
|
510
|
+
cry_to_rzz.rzz(-theta / 2, 0, 1)
|
511
|
+
cry_to_rzz.h(1)
|
512
|
+
cry_to_rzz.s(1)
|
513
|
+
_sel.add_equivalence(CRYGate(theta), cry_to_rzz)
|
514
|
+
|
515
|
+
# RYYGate
|
516
|
+
#
|
517
|
+
# ┌─────────┐ ┌─────────┐ ┌──────────┐
|
518
|
+
# q_0: ┤0 ├ q_0: ┤ Rx(π/2) ├──■─────────────■──┤ Rx(-π/2) ├
|
519
|
+
# │ Ryy(ϴ) │ ≡ ├─────────┤┌─┴─┐┌───────┐┌─┴─┐├──────────┤
|
520
|
+
# q_1: ┤1 ├ q_1: ┤ Rx(π/2) ├┤ X ├┤ Rz(ϴ) ├┤ X ├┤ Rx(-π/2) ├
|
521
|
+
# └─────────┘ └─────────┘└───┘└───────┘└───┘└──────────┘
|
522
|
+
q = QuantumRegister(2, "q")
|
523
|
+
theta = Parameter("theta")
|
524
|
+
def_ryy = QuantumCircuit(q)
|
525
|
+
for inst, qargs, cargs in [
|
526
|
+
(RXGate(pi / 2), [q[0]], []),
|
527
|
+
(RXGate(pi / 2), [q[1]], []),
|
528
|
+
(CXGate(), [q[0], q[1]], []),
|
529
|
+
(RZGate(theta), [q[1]], []),
|
530
|
+
(CXGate(), [q[0], q[1]], []),
|
531
|
+
(RXGate(-pi / 2), [q[0]], []),
|
532
|
+
(RXGate(-pi / 2), [q[1]], []),
|
533
|
+
]:
|
534
|
+
def_ryy.append(inst, qargs, cargs)
|
535
|
+
_sel.add_equivalence(RYYGate(theta), def_ryy)
|
536
|
+
|
537
|
+
# RYYGate
|
538
|
+
#
|
539
|
+
# ┌─────────┐ ┌──────┐ ┌────┐
|
540
|
+
# q_0: ┤0 ├ q_0: ┤ √Xdg ├──■─────────────■──┤ √X ├
|
541
|
+
# │ Ryy(ϴ) │ ≡ ├──────┤┌─┴─┐┌───────┐┌─┴─┐├────┤
|
542
|
+
# q_1: ┤1 ├ q_1: ┤ √Xdg ├┤ X ├┤ Rz(ϴ) ├┤ X ├┤ √X ├
|
543
|
+
# └─────────┘ └──────┘└───┘└───────┘└───┘└────┘
|
544
|
+
q = QuantumRegister(2, "q")
|
545
|
+
theta = Parameter("theta")
|
546
|
+
def_ryy = QuantumCircuit(q)
|
547
|
+
for inst, qargs, cargs in [
|
548
|
+
(SXdgGate(), [q[0]], []),
|
549
|
+
(SXdgGate(), [q[1]], []),
|
550
|
+
(CXGate(), [q[0], q[1]], []),
|
551
|
+
(RZGate(theta), [q[1]], []),
|
552
|
+
(CXGate(), [q[0], q[1]], []),
|
553
|
+
(SXGate(), [q[0]], []),
|
554
|
+
(SXGate(), [q[1]], []),
|
555
|
+
]:
|
556
|
+
def_ryy.append(inst, qargs, cargs)
|
557
|
+
_sel.add_equivalence(RYYGate(theta), def_ryy)
|
558
|
+
|
559
|
+
# RYY to RZZ
|
560
|
+
q = QuantumRegister(2, "q")
|
561
|
+
theta = Parameter("theta")
|
562
|
+
ryy_to_rzz = QuantumCircuit(q)
|
563
|
+
for inst, qargs, cargs in [
|
564
|
+
(RXGate(pi / 2), [q[0]], []),
|
565
|
+
(RXGate(pi / 2), [q[1]], []),
|
566
|
+
(RZZGate(theta), [q[0], q[1]], []),
|
567
|
+
(RXGate(-pi / 2), [q[0]], []),
|
568
|
+
(RXGate(-pi / 2), [q[1]], []),
|
569
|
+
]:
|
570
|
+
ryy_to_rzz.append(inst, qargs, cargs)
|
571
|
+
_sel.add_equivalence(RYYGate(theta), ryy_to_rzz)
|
572
|
+
|
573
|
+
# RYY to RXX
|
574
|
+
q = QuantumRegister(2, "q")
|
575
|
+
theta = Parameter("theta")
|
576
|
+
ryy_to_rxx = QuantumCircuit(q)
|
577
|
+
for inst, qargs, cargs in [
|
578
|
+
(SdgGate(), [q[0]], []),
|
579
|
+
(SdgGate(), [q[1]], []),
|
580
|
+
(RXXGate(theta), [q[0], q[1]], []),
|
581
|
+
(SGate(), [q[0]], []),
|
582
|
+
(SGate(), [q[1]], []),
|
583
|
+
]:
|
584
|
+
ryy_to_rxx.append(inst, qargs, cargs)
|
585
|
+
_sel.add_equivalence(RYYGate(theta), ryy_to_rxx)
|
586
|
+
|
587
|
+
# RZGate
|
588
|
+
# global phase: -ϴ/2
|
589
|
+
# ┌───────┐ ┌──────┐
|
590
|
+
# q: ┤ Rz(ϴ) ├ ≡ q: ┤ P(ϴ) ├
|
591
|
+
# └───────┘ └──────┘
|
592
|
+
q = QuantumRegister(1, "q")
|
593
|
+
theta = Parameter("theta")
|
594
|
+
def_rz = QuantumCircuit(q, global_phase=-theta / 2)
|
595
|
+
def_rz.append(PhaseGate(theta), [q[0]], [])
|
596
|
+
_sel.add_equivalence(RZGate(theta), def_rz)
|
597
|
+
|
598
|
+
# RZGate
|
599
|
+
#
|
600
|
+
# ┌───────┐ ┌────┐┌────────┐┌──────┐
|
601
|
+
# q: ┤ Rz(ϴ) ├ ≡ q: ┤ √X ├┤ Ry(-ϴ) ├┤ √Xdg ├
|
602
|
+
# └───────┘ └────┘└────────┘└──────┘
|
603
|
+
q = QuantumRegister(1, "q")
|
604
|
+
rz_to_sxry = QuantumCircuit(q)
|
605
|
+
rz_to_sxry.sx(0)
|
606
|
+
rz_to_sxry.ry(-theta, 0)
|
607
|
+
rz_to_sxry.sxdg(0)
|
608
|
+
_sel.add_equivalence(RZGate(theta), rz_to_sxry)
|
609
|
+
|
610
|
+
q = QuantumRegister(1, "q")
|
611
|
+
rz_to_rx = QuantumCircuit(q)
|
612
|
+
rz_to_rx.h(0)
|
613
|
+
rz_to_rx.rx(theta, 0)
|
614
|
+
rz_to_rx.h(0)
|
615
|
+
_sel.add_equivalence(RZGate(theta), rz_to_rx)
|
616
|
+
|
617
|
+
# CRZGate
|
618
|
+
#
|
619
|
+
# q_0: ────■──── q_0: ─────────────■────────────────■──
|
620
|
+
# ┌───┴───┐ ≡ ┌─────────┐┌─┴─┐┌──────────┐┌─┴─┐
|
621
|
+
# q_1: ┤ Rz(ϴ) ├ q_1: ┤ Rz(ϴ/2) ├┤ X ├┤ Rz(-ϴ/2) ├┤ X ├
|
622
|
+
# └───────┘ └─────────┘└───┘└──────────┘└───┘
|
623
|
+
q = QuantumRegister(2, "q")
|
624
|
+
theta = Parameter("theta")
|
625
|
+
def_crz = QuantumCircuit(q)
|
626
|
+
for inst, qargs, cargs in [
|
627
|
+
(RZGate(theta / 2), [q[1]], []),
|
628
|
+
(CXGate(), [q[0], q[1]], []),
|
629
|
+
(RZGate(-theta / 2), [q[1]], []),
|
630
|
+
(CXGate(), [q[0], q[1]], []),
|
631
|
+
]:
|
632
|
+
def_crz.append(inst, qargs, cargs)
|
633
|
+
_sel.add_equivalence(CRZGate(theta), def_crz)
|
634
|
+
|
635
|
+
# CRZ to CRY
|
636
|
+
#
|
637
|
+
# q_0: ────■──── q_0: ────────────────■───────────────
|
638
|
+
# ┌───┴───┐ ≡ ┌──────────┐┌───┴───┐┌─────────┐
|
639
|
+
# q_1: ┤ Rz(ϴ) ├ q_1: ┤ Rx(-π/2) ├┤ Ry(ϴ) ├┤ Rx(π/2) ├
|
640
|
+
# └───────┘ └──────────┘└───────┘└─────────┘
|
641
|
+
theta = Parameter("theta")
|
642
|
+
crz_to_cry = QuantumCircuit(2)
|
643
|
+
crz_to_cry.rx(-pi / 2, 1)
|
644
|
+
crz_to_cry.cry(theta, 0, 1)
|
645
|
+
crz_to_cry.rx(pi / 2, 1)
|
646
|
+
_sel.add_equivalence(CRZGate(theta), crz_to_cry)
|
647
|
+
|
648
|
+
# CRZ to CRX
|
649
|
+
#
|
650
|
+
# q_0: ────■──── q_0: ─────────■─────────
|
651
|
+
# ┌───┴───┐ ≡ ┌───┐┌───┴───┐┌───┐
|
652
|
+
# q_1: ┤ Rz(ϴ) ├ q_1: ┤ H ├┤ Rx(ϴ) ├┤ H ├
|
653
|
+
# └───────┘ └───┘└───────┘└───┘
|
654
|
+
theta = Parameter("theta")
|
655
|
+
crz_to_crx = QuantumCircuit(2)
|
656
|
+
crz_to_crx.h(1)
|
657
|
+
crz_to_crx.crx(theta, 0, 1)
|
658
|
+
crz_to_crx.h(1)
|
659
|
+
_sel.add_equivalence(CRZGate(theta), crz_to_crx)
|
660
|
+
|
661
|
+
# CRZ to RZZ
|
662
|
+
#
|
663
|
+
# q_0: ────■──── q_0: ────────────■────────
|
664
|
+
# ┌───┴───┐ ≡ ┌─────────┐ │ZZ(-ϴ/2)
|
665
|
+
# q_1: ┤ Rz(ϴ) ├ q_1: ┤ Rz(ϴ/2) ├─■────────
|
666
|
+
# └───────┘ └─────────┘
|
667
|
+
theta = Parameter("theta")
|
668
|
+
crz_to_rzz = QuantumCircuit(2)
|
669
|
+
crz_to_rzz.rz(theta / 2, 1)
|
670
|
+
crz_to_rzz.rzz(-theta / 2, 0, 1)
|
671
|
+
_sel.add_equivalence(CRZGate(theta), crz_to_rzz)
|
672
|
+
|
673
|
+
# RZZGate
|
674
|
+
#
|
675
|
+
# q_0: ─■───── q_0: ──■─────────────■──
|
676
|
+
# │ZZ(ϴ) ≡ ┌─┴─┐┌───────┐┌─┴─┐
|
677
|
+
# q_1: ─■───── q_1: ┤ X ├┤ Rz(ϴ) ├┤ X ├
|
678
|
+
# └───┘└───────┘└───┘
|
679
|
+
q = QuantumRegister(2, "q")
|
680
|
+
theta = Parameter("theta")
|
681
|
+
def_rzz = QuantumCircuit(q)
|
682
|
+
for inst, qargs, cargs in [
|
683
|
+
(CXGate(), [q[0], q[1]], []),
|
684
|
+
(RZGate(theta), [q[1]], []),
|
685
|
+
(CXGate(), [q[0], q[1]], []),
|
686
|
+
]:
|
687
|
+
def_rzz.append(inst, qargs, cargs)
|
688
|
+
_sel.add_equivalence(RZZGate(theta), def_rzz)
|
689
|
+
|
690
|
+
# RZZ to RXX
|
691
|
+
q = QuantumRegister(2, "q")
|
692
|
+
theta = Parameter("theta")
|
693
|
+
rzz_to_rxx = QuantumCircuit(q)
|
694
|
+
for inst, qargs, cargs in [
|
695
|
+
(HGate(), [q[0]], []),
|
696
|
+
(HGate(), [q[1]], []),
|
697
|
+
(RXXGate(theta), [q[0], q[1]], []),
|
698
|
+
(HGate(), [q[0]], []),
|
699
|
+
(HGate(), [q[1]], []),
|
700
|
+
]:
|
701
|
+
rzz_to_rxx.append(inst, qargs, cargs)
|
702
|
+
_sel.add_equivalence(RZZGate(theta), rzz_to_rxx)
|
703
|
+
|
704
|
+
# RZZ to RZX
|
705
|
+
# ┌─────────┐
|
706
|
+
# q_0: ─■───── q_0: ─────┤0 ├─────
|
707
|
+
# │ZZ(ϴ) ≡ ┌───┐│ Rzx(ϴ) │┌───┐
|
708
|
+
# q_1: ─■───── q_1: ┤ H ├┤1 ├┤ H ├
|
709
|
+
# └───┘└─────────┘└───┘
|
710
|
+
theta = Parameter("theta")
|
711
|
+
rzz_to_rzx = QuantumCircuit(2)
|
712
|
+
rzz_to_rzx.h(1)
|
713
|
+
rzz_to_rzx.rzx(theta, 0, 1)
|
714
|
+
rzz_to_rzx.h(1)
|
715
|
+
_sel.add_equivalence(RZZGate(theta), rzz_to_rzx)
|
716
|
+
|
717
|
+
# RZZ to CPhase
|
718
|
+
#
|
719
|
+
# global phase: ϴ/2
|
720
|
+
# ┌───────┐
|
721
|
+
# q_0: ─■───── q_0: ─■────────┤ Rz(ϴ) ├
|
722
|
+
# │ZZ(ϴ) ≡ │P(-2*ϴ) ├───────┤
|
723
|
+
# q_1: ─■───── q_1: ─■────────┤ Rz(ϴ) ├
|
724
|
+
# └───────┘
|
725
|
+
theta = Parameter("theta")
|
726
|
+
rzz_to_cphase = QuantumCircuit(2, global_phase=theta / 2)
|
727
|
+
rzz_to_cphase.cp(-theta * 2, 0, 1)
|
728
|
+
rzz_to_cphase.rz(theta, 0)
|
729
|
+
rzz_to_cphase.rz(theta, 1)
|
730
|
+
_sel.add_equivalence(RZZGate(theta), rzz_to_cphase)
|
731
|
+
|
732
|
+
# RZZ to RYY
|
733
|
+
q = QuantumRegister(2, "q")
|
734
|
+
theta = Parameter("theta")
|
735
|
+
rzz_to_ryy = QuantumCircuit(q)
|
736
|
+
for inst, qargs, cargs in [
|
737
|
+
(RXGate(-pi / 2), [q[0]], []),
|
738
|
+
(RXGate(-pi / 2), [q[1]], []),
|
739
|
+
(RYYGate(theta), [q[0], q[1]], []),
|
740
|
+
(RXGate(pi / 2), [q[0]], []),
|
741
|
+
(RXGate(pi / 2), [q[1]], []),
|
742
|
+
]:
|
743
|
+
rzz_to_ryy.append(inst, qargs, cargs)
|
744
|
+
_sel.add_equivalence(RZZGate(theta), rzz_to_ryy)
|
745
|
+
|
746
|
+
# RZXGate
|
747
|
+
#
|
748
|
+
# ┌─────────┐
|
749
|
+
# q_0: ┤0 ├ q_0: ───────■─────────────■───────
|
750
|
+
# │ Rzx(ϴ) │ ≡ ┌───┐┌─┴─┐┌───────┐┌─┴─┐┌───┐
|
751
|
+
# q_1: ┤1 ├ q_1: ┤ H ├┤ X ├┤ Rz(ϴ) ├┤ X ├┤ H ├
|
752
|
+
# └─────────┘ └───┘└───┘└───────┘└───┘└───┘
|
753
|
+
q = QuantumRegister(2, "q")
|
754
|
+
theta = Parameter("theta")
|
755
|
+
def_rzx = QuantumCircuit(q)
|
756
|
+
for inst, qargs, cargs in [
|
757
|
+
(HGate(), [q[1]], []),
|
758
|
+
(CXGate(), [q[0], q[1]], []),
|
759
|
+
(RZGate(theta), [q[1]], []),
|
760
|
+
(CXGate(), [q[0], q[1]], []),
|
761
|
+
(HGate(), [q[1]], []),
|
762
|
+
]:
|
763
|
+
def_rzx.append(inst, qargs, cargs)
|
764
|
+
_sel.add_equivalence(RZXGate(theta), def_rzx)
|
765
|
+
|
766
|
+
# ECRGate
|
767
|
+
#
|
768
|
+
# ┌──────┐ ┌───────────┐┌───┐┌────────────┐
|
769
|
+
# q_0: ┤0 ├ q_0: ┤0 ├┤ X ├┤0 ├
|
770
|
+
# │ Ecr │ ≡ │ Rzx(π/4) │└───┘│ Rzx(-π/4) │
|
771
|
+
# q_1: ┤1 ├ q_1: ┤1 ├─────┤1 ├
|
772
|
+
# └──────┘ └───────────┘ └────────────┘
|
773
|
+
q = QuantumRegister(2, "q")
|
774
|
+
def_ecr = QuantumCircuit(q)
|
775
|
+
for inst, qargs, cargs in [
|
776
|
+
(RZXGate(pi / 4), [q[0], q[1]], []),
|
777
|
+
(XGate(), [q[0]], []),
|
778
|
+
(RZXGate(-pi / 4), [q[0], q[1]], []),
|
779
|
+
]:
|
780
|
+
def_ecr.append(inst, qargs, cargs)
|
781
|
+
_sel.add_equivalence(ECRGate(), def_ecr)
|
782
|
+
|
783
|
+
# ECRGate decomposed to Clifford gates (up to a global phase)
|
784
|
+
#
|
785
|
+
# global phase: 7π/4
|
786
|
+
# ┌──────┐ ┌───┐ ┌───┐
|
787
|
+
# q_0: ┤0 ├ q_0: ┤ S ├───■──┤ X ├
|
788
|
+
# │ Ecr │ ≡ ├───┴┐┌─┴─┐└───┘
|
789
|
+
# q_1: ┤1 ├ q_1: ┤ √X ├┤ X ├─────
|
790
|
+
# └──────┘ └────┘└───┘
|
791
|
+
|
792
|
+
q = QuantumRegister(2, "q")
|
793
|
+
def_ecr_cliff = QuantumCircuit(q, global_phase=-pi / 4)
|
794
|
+
for inst, qargs, cargs in [
|
795
|
+
(SGate(), [q[0]], []),
|
796
|
+
(SXGate(), [q[1]], []),
|
797
|
+
(CXGate(), [q[0], q[1]], []),
|
798
|
+
(XGate(), [q[0]], []),
|
799
|
+
]:
|
800
|
+
def_ecr_cliff.append(inst, qargs, cargs)
|
801
|
+
_sel.add_equivalence(ECRGate(), def_ecr_cliff)
|
802
|
+
|
803
|
+
# CXGate decomposed using an ECRGate and Clifford 1-qubit gates
|
804
|
+
# global phase: π/4
|
805
|
+
# q_0: ──■── ┌─────┐ ┌──────┐┌───┐
|
806
|
+
# ┌─┴─┐ ≡ q_0: ┤ Sdg ├─┤0 ├┤ X ├
|
807
|
+
# q_1: ┤ X ├ ├─────┴┐│ Ecr │└───┘
|
808
|
+
# └───┘ q_1: ┤ √Xdg ├┤1 ├─────
|
809
|
+
# └──────┘└──────┘
|
810
|
+
|
811
|
+
q = QuantumRegister(2, "q")
|
812
|
+
def_ecr_to_cx_cliff = QuantumCircuit(q, global_phase=pi / 4)
|
813
|
+
for inst, qargs, cargs in [
|
814
|
+
(SdgGate(), [q[0]], []),
|
815
|
+
(SXdgGate(), [q[1]], []),
|
816
|
+
(ECRGate(), [q[0], q[1]], []),
|
817
|
+
(XGate(), [q[0]], []),
|
818
|
+
]:
|
819
|
+
def_ecr_to_cx_cliff.append(inst, qargs, cargs)
|
820
|
+
_sel.add_equivalence(CXGate(), def_ecr_to_cx_cliff)
|
821
|
+
|
822
|
+
# SGate
|
823
|
+
#
|
824
|
+
# ┌───┐ ┌────────┐
|
825
|
+
# q: ┤ S ├ ≡ q: ┤ P(π/2) ├
|
826
|
+
# └───┘ └────────┘
|
827
|
+
q = QuantumRegister(1, "q")
|
828
|
+
def_s = QuantumCircuit(q)
|
829
|
+
def_s.append(PhaseGate(pi / 2), [q[0]], [])
|
830
|
+
_sel.add_equivalence(SGate(), def_s)
|
831
|
+
|
832
|
+
# SGate
|
833
|
+
#
|
834
|
+
# ┌───┐┌───┐
|
835
|
+
# q: ┤ T ├┤ T ├
|
836
|
+
# └───┘└───┘
|
837
|
+
q = QuantumRegister(1, "q")
|
838
|
+
def_s = QuantumCircuit(q)
|
839
|
+
def_s.append(TGate(), [q[0]], [])
|
840
|
+
def_s.append(TGate(), [q[0]], [])
|
841
|
+
_sel.add_equivalence(SGate(), def_s)
|
842
|
+
|
843
|
+
# SdgGate
|
844
|
+
#
|
845
|
+
# ┌─────┐ ┌─────────┐
|
846
|
+
# q: ┤ Sdg ├ ≡ q: ┤ P(-π/2) ├
|
847
|
+
# └─────┘ └─────────┘
|
848
|
+
q = QuantumRegister(1, "q")
|
849
|
+
def_sdg = QuantumCircuit(q)
|
850
|
+
def_sdg.append(PhaseGate(-pi / 2), [q[0]], [])
|
851
|
+
_sel.add_equivalence(SdgGate(), def_sdg)
|
852
|
+
|
853
|
+
# SdgGate
|
854
|
+
#
|
855
|
+
# ┌─────┐ ┌───┐┌───┐
|
856
|
+
# q: ┤ Sdg ├ ≡ q: ┤ S ├┤ Z ├
|
857
|
+
# └─────┘ └───┘└───┘
|
858
|
+
q = QuantumRegister(1, "q")
|
859
|
+
def_sdg = QuantumCircuit(q)
|
860
|
+
for inst, qargs, cargs in [
|
861
|
+
(SGate(), [q[0]], []),
|
862
|
+
(ZGate(), [q[0]], []),
|
863
|
+
]:
|
864
|
+
def_sdg.append(inst, qargs, cargs)
|
865
|
+
_sel.add_equivalence(SdgGate(), def_sdg)
|
866
|
+
|
867
|
+
# SdgGate
|
868
|
+
#
|
869
|
+
# ┌─────┐ ┌───┐┌───┐
|
870
|
+
# q: ┤ Sdg ├ ≡ q: ┤ Z ├┤ S ├
|
871
|
+
# └─────┘ └───┘└───┘
|
872
|
+
q = QuantumRegister(1, "q")
|
873
|
+
def_sdg = QuantumCircuit(q)
|
874
|
+
for inst, qargs, cargs in [
|
875
|
+
(ZGate(), [q[0]], []),
|
876
|
+
(SGate(), [q[0]], []),
|
877
|
+
]:
|
878
|
+
def_sdg.append(inst, qargs, cargs)
|
879
|
+
_sel.add_equivalence(SdgGate(), def_sdg)
|
880
|
+
|
881
|
+
# SdgGate
|
882
|
+
#
|
883
|
+
# ┌─────┐ ┌───┐┌───┐┌───┐
|
884
|
+
# q: ┤ Sdg ├ ≡ q: ┤ S ├┤ S ├┤ S ├
|
885
|
+
# └─────┘ └───┘└───┘└───┘
|
886
|
+
q = QuantumRegister(1, "q")
|
887
|
+
def_sdg = QuantumCircuit(q)
|
888
|
+
for inst, qargs, cargs in [
|
889
|
+
(SGate(), [q[0]], []),
|
890
|
+
(SGate(), [q[0]], []),
|
891
|
+
(SGate(), [q[0]], []),
|
892
|
+
]:
|
893
|
+
def_sdg.append(inst, qargs, cargs)
|
894
|
+
_sel.add_equivalence(SdgGate(), def_sdg)
|
895
|
+
|
896
|
+
# SdgGate
|
897
|
+
#
|
898
|
+
# ┌─────┐┌─────┐
|
899
|
+
# q: ┤ Tdg ├┤ Tdg ├
|
900
|
+
# └─────┘└─────┘
|
901
|
+
q = QuantumRegister(1, "q")
|
902
|
+
def_sdg = QuantumCircuit(q)
|
903
|
+
for inst, qargs, cargs in [
|
904
|
+
(TdgGate(), [q[0]], []),
|
905
|
+
(TdgGate(), [q[0]], []),
|
906
|
+
]:
|
907
|
+
def_sdg.append(inst, qargs, cargs)
|
908
|
+
_sel.add_equivalence(SdgGate(), def_sdg)
|
909
|
+
|
910
|
+
# CSGate
|
911
|
+
#
|
912
|
+
# ┌───┐
|
913
|
+
# q_0: ──■── q_0: ┤ T ├──■───────────■──
|
914
|
+
# ┌─┴─┐ ├───┤┌─┴─┐┌─────┐┌─┴─┐
|
915
|
+
# q_1: ┤ S ├ = q_1: ┤ T ├┤ X ├┤ Tdg ├┤ X ├
|
916
|
+
# └───┘ └───┘└───┘└─────┘└───┘
|
917
|
+
q = QuantumRegister(2, "q")
|
918
|
+
def_cs = QuantumCircuit(q)
|
919
|
+
def_cs.append(TGate(), [q[0]], [])
|
920
|
+
def_cs.append(TGate(), [q[1]], [])
|
921
|
+
def_cs.append(CXGate(), [q[0], q[1]], [])
|
922
|
+
def_cs.append(TdgGate(), [q[1]], [])
|
923
|
+
def_cs.append(CXGate(), [q[0], q[1]], [])
|
924
|
+
_sel.add_equivalence(CSGate(), def_cs)
|
925
|
+
|
926
|
+
# CSGate
|
927
|
+
#
|
928
|
+
# q_0: ──■── q_0: ───────■────────
|
929
|
+
# ┌─┴─┐ ┌───┐┌─┴──┐┌───┐
|
930
|
+
# q_1: ┤ S ├ = q_1: ┤ H ├┤ Sx ├┤ H ├
|
931
|
+
# └───┘ └───┘└────┘└───┘
|
932
|
+
q = QuantumRegister(2, "q")
|
933
|
+
def_cs_csx = QuantumCircuit(q)
|
934
|
+
def_cs_csx.append(HGate(), [q[1]], [])
|
935
|
+
def_cs_csx.append(CSXGate(), [q[0], q[1]], [])
|
936
|
+
def_cs_csx.append(HGate(), [q[1]], [])
|
937
|
+
_sel.add_equivalence(CSGate(), def_cs_csx)
|
938
|
+
|
939
|
+
# CSdgGate
|
940
|
+
#
|
941
|
+
# ┌─────┐
|
942
|
+
# q_0: ───■─── q_0: ──■─────────■──┤ Tdg ├
|
943
|
+
# ┌──┴──┐ ┌─┴─┐┌───┐┌─┴─┐├─────┤
|
944
|
+
# q_1: ┤ Sdg ├ = q_1: ┤ X ├┤ T ├┤ X ├┤ Tdg ├
|
945
|
+
# └─────┘ └───┘└───┘└───┘└─────┘
|
946
|
+
q = QuantumRegister(2, "q")
|
947
|
+
def_csdg = QuantumCircuit(q)
|
948
|
+
def_csdg.append(CXGate(), [q[0], q[1]], [])
|
949
|
+
def_csdg.append(TGate(), [q[1]], [])
|
950
|
+
def_csdg.append(CXGate(), [q[0], q[1]], [])
|
951
|
+
def_csdg.append(TdgGate(), [q[0]], [])
|
952
|
+
def_csdg.append(TdgGate(), [q[1]], [])
|
953
|
+
_sel.add_equivalence(CSdgGate(), def_csdg)
|
954
|
+
|
955
|
+
# CSdgGate
|
956
|
+
#
|
957
|
+
# q_0: ───■─── q_0: ───────■────■────────
|
958
|
+
# ┌──┴──┐ ┌───┐┌─┴─┐┌─┴──┐┌───┐
|
959
|
+
# q_1: ┤ Sdg ├ = q_1: ┤ H ├┤ X ├┤ Sx ├┤ H ├
|
960
|
+
# └─────┘ └───┘└───┘└────┘└───┘
|
961
|
+
q = QuantumRegister(2, "q")
|
962
|
+
def_csdg_csx = QuantumCircuit(q)
|
963
|
+
def_csdg_csx.append(HGate(), [q[1]], [])
|
964
|
+
def_csdg_csx.append(CXGate(), [q[0], q[1]], [])
|
965
|
+
def_csdg_csx.append(CSXGate(), [q[0], q[1]], [])
|
966
|
+
def_csdg_csx.append(HGate(), [q[1]], [])
|
967
|
+
_sel.add_equivalence(CSdgGate(), def_csdg_csx)
|
968
|
+
|
969
|
+
# SwapGate
|
970
|
+
# ┌───┐
|
971
|
+
# q_0: ─X─ q_0: ──■──┤ X ├──■──
|
972
|
+
# │ ≡ ┌─┴─┐└─┬─┘┌─┴─┐
|
973
|
+
# q_1: ─X─ q_1: ┤ X ├──■──┤ X ├
|
974
|
+
# └───┘ └───┘
|
975
|
+
q = QuantumRegister(2, "q")
|
976
|
+
def_swap = QuantumCircuit(q)
|
977
|
+
for inst, qargs, cargs in [
|
978
|
+
(CXGate(), [q[0], q[1]], []),
|
979
|
+
(CXGate(), [q[1], q[0]], []),
|
980
|
+
(CXGate(), [q[0], q[1]], []),
|
981
|
+
]:
|
982
|
+
def_swap.append(inst, qargs, cargs)
|
983
|
+
_sel.add_equivalence(SwapGate(), def_swap)
|
984
|
+
|
985
|
+
# SwapGate
|
986
|
+
#
|
987
|
+
# q_0: ─X─
|
988
|
+
# │ ≡
|
989
|
+
# q_1: ─X─
|
990
|
+
#
|
991
|
+
# ┌──────────┐┌──────┐ ┌────┐ ┌──────┐┌──────────┐┌──────┐
|
992
|
+
# q_0: ┤ Rz(-π/2) ├┤0 ├───┤ √X ├───┤1 ├┤ Rz(-π/2) ├┤0 ├
|
993
|
+
# └──┬────┬──┘│ Ecr │┌──┴────┴──┐│ Ecr │└──┬────┬──┘│ Ecr │
|
994
|
+
# q_1: ───┤ √X ├───┤1 ├┤ Rz(-π/2) ├┤0 ├───┤ √X ├───┤1 ├
|
995
|
+
# └────┘ └──────┘└──────────┘└──────┘ └────┘ └──────┘
|
996
|
+
#
|
997
|
+
q = QuantumRegister(2, "q")
|
998
|
+
def_swap_ecr = QuantumCircuit(q)
|
999
|
+
def_swap_ecr.rz(-pi / 2, 0)
|
1000
|
+
def_swap_ecr.sx(1)
|
1001
|
+
def_swap_ecr.ecr(0, 1)
|
1002
|
+
def_swap_ecr.rz(-pi / 2, 1)
|
1003
|
+
def_swap_ecr.sx(0)
|
1004
|
+
def_swap_ecr.ecr(1, 0)
|
1005
|
+
def_swap_ecr.rz(-pi / 2, 0)
|
1006
|
+
def_swap_ecr.sx(1)
|
1007
|
+
def_swap_ecr.ecr(0, 1)
|
1008
|
+
_sel.add_equivalence(SwapGate(), def_swap_ecr)
|
1009
|
+
|
1010
|
+
# SwapGate
|
1011
|
+
#
|
1012
|
+
# q_0: ─X─
|
1013
|
+
# │ ≡
|
1014
|
+
# q_1: ─X─
|
1015
|
+
#
|
1016
|
+
# global phase: 3π/2
|
1017
|
+
# ┌────┐ ┌────┐ ┌────┐
|
1018
|
+
# q_0: ┤ √X ├─■─┤ √X ├─■─┤ √X ├─■─
|
1019
|
+
# ├────┤ │ ├────┤ │ ├────┤ │
|
1020
|
+
# q_1: ┤ √X ├─■─┤ √X ├─■─┤ √X ├─■─
|
1021
|
+
# └────┘ └────┘ └────┘
|
1022
|
+
q = QuantumRegister(2, "q")
|
1023
|
+
def_swap_cz = QuantumCircuit(q, global_phase=-pi / 2)
|
1024
|
+
def_swap_cz.sx(0)
|
1025
|
+
def_swap_cz.sx(1)
|
1026
|
+
def_swap_cz.cz(0, 1)
|
1027
|
+
def_swap_cz.sx(0)
|
1028
|
+
def_swap_cz.sx(1)
|
1029
|
+
def_swap_cz.cz(0, 1)
|
1030
|
+
def_swap_cz.sx(0)
|
1031
|
+
def_swap_cz.sx(1)
|
1032
|
+
def_swap_cz.cz(0, 1)
|
1033
|
+
_sel.add_equivalence(SwapGate(), def_swap_cz)
|
1034
|
+
|
1035
|
+
# iSwapGate
|
1036
|
+
#
|
1037
|
+
# ┌────────┐ ┌───┐┌───┐ ┌───┐
|
1038
|
+
# q_0: ┤0 ├ q_0: ┤ S ├┤ H ├──■──┤ X ├─────
|
1039
|
+
# │ Iswap │ ≡ ├───┤└───┘┌─┴─┐└─┬─┘┌───┐
|
1040
|
+
# q_1: ┤1 ├ q_1: ┤ S ├─────┤ X ├──■──┤ H ├
|
1041
|
+
# └────────┘ └───┘ └───┘ └───┘
|
1042
|
+
q = QuantumRegister(2, "q")
|
1043
|
+
def_iswap = QuantumCircuit(q)
|
1044
|
+
for inst, qargs, cargs in [
|
1045
|
+
(SGate(), [q[0]], []),
|
1046
|
+
(SGate(), [q[1]], []),
|
1047
|
+
(HGate(), [q[0]], []),
|
1048
|
+
(CXGate(), [q[0], q[1]], []),
|
1049
|
+
(CXGate(), [q[1], q[0]], []),
|
1050
|
+
(HGate(), [q[1]], []),
|
1051
|
+
]:
|
1052
|
+
def_iswap.append(inst, qargs, cargs)
|
1053
|
+
_sel.add_equivalence(iSwapGate(), def_iswap)
|
1054
|
+
|
1055
|
+
# SXGate
|
1056
|
+
# global phase: π/4
|
1057
|
+
# ┌────┐ ┌─────┐┌───┐┌─────┐
|
1058
|
+
# q: ┤ √X ├ ≡ q: ┤ Sdg ├┤ H ├┤ Sdg ├
|
1059
|
+
# └────┘ └─────┘└───┘└─────┘
|
1060
|
+
q = QuantumRegister(1, "q")
|
1061
|
+
def_sx = QuantumCircuit(q, global_phase=pi / 4)
|
1062
|
+
for inst, qargs, cargs in [(SdgGate(), [q[0]], []), (HGate(), [q[0]], []), (SdgGate(), [q[0]], [])]:
|
1063
|
+
def_sx.append(inst, qargs, cargs)
|
1064
|
+
_sel.add_equivalence(SXGate(), def_sx)
|
1065
|
+
|
1066
|
+
# HGate decomposed into SXGate and SGate
|
1067
|
+
# global phase: -π/4
|
1068
|
+
# ┌───┐ ┌───┐┌────┐┌───┐
|
1069
|
+
# q: ┤ H ├ ≡ q: ┤ S ├┤ √X ├┤ S ├
|
1070
|
+
# └───┘ └───┘└────┘└───┘
|
1071
|
+
q = QuantumRegister(1, "q")
|
1072
|
+
def_h_to_sx = QuantumCircuit(q, global_phase=-pi / 4)
|
1073
|
+
for inst, qargs, cargs in [(SGate(), [q[0]], []), (SXGate(), [q[0]], []), (SGate(), [q[0]], [])]:
|
1074
|
+
def_h_to_sx.append(inst, qargs, cargs)
|
1075
|
+
_sel.add_equivalence(HGate(), def_h_to_sx)
|
1076
|
+
|
1077
|
+
# SXGate
|
1078
|
+
# global phase: π/4
|
1079
|
+
# ┌────┐ ┌─────────┐
|
1080
|
+
# q: ┤ √X ├ ≡ q: ┤ Rx(π/2) ├
|
1081
|
+
# └────┘ └─────────┘
|
1082
|
+
q = QuantumRegister(1, "q")
|
1083
|
+
sx_to_rx = QuantumCircuit(q, global_phase=pi / 4)
|
1084
|
+
sx_to_rx.rx(pi / 2, 0)
|
1085
|
+
_sel.add_equivalence(SXGate(), sx_to_rx)
|
1086
|
+
|
1087
|
+
# SXdgGate
|
1088
|
+
# global phase: 7π/4
|
1089
|
+
# ┌──────┐ ┌───┐┌───┐┌───┐
|
1090
|
+
# q: ┤ √Xdg ├ ≡ q: ┤ S ├┤ H ├┤ S ├
|
1091
|
+
# └──────┘ └───┘└───┘└───┘
|
1092
|
+
q = QuantumRegister(1, "q")
|
1093
|
+
def_sxdg = QuantumCircuit(q, global_phase=-pi / 4)
|
1094
|
+
for inst, qargs, cargs in [(SGate(), [q[0]], []), (HGate(), [q[0]], []), (SGate(), [q[0]], [])]:
|
1095
|
+
def_sxdg.append(inst, qargs, cargs)
|
1096
|
+
_sel.add_equivalence(SXdgGate(), def_sxdg)
|
1097
|
+
|
1098
|
+
# HGate decomposed into SXdgGate and SdgGate
|
1099
|
+
# global phase: π/4
|
1100
|
+
# ┌───┐ ┌─────┐┌──────┐┌─────┐
|
1101
|
+
# q: ┤ H ├ ≡ q: ┤ Sdg ├┤ √Xdg ├┤ Sdg ├
|
1102
|
+
# └───┘ └─────┘└──────┘└─────┘
|
1103
|
+
q = QuantumRegister(1, "q")
|
1104
|
+
def_h_to_sxdg = QuantumCircuit(q, global_phase=pi / 4)
|
1105
|
+
for inst, qargs, cargs in [
|
1106
|
+
(SdgGate(), [q[0]], []),
|
1107
|
+
(SXdgGate(), [q[0]], []),
|
1108
|
+
(SdgGate(), [q[0]], []),
|
1109
|
+
]:
|
1110
|
+
def_h_to_sxdg.append(inst, qargs, cargs)
|
1111
|
+
_sel.add_equivalence(HGate(), def_h_to_sxdg)
|
1112
|
+
|
1113
|
+
# SXdgGate
|
1114
|
+
# global phase: 7π/4
|
1115
|
+
# ┌──────┐ ┌──────────┐
|
1116
|
+
# q: ┤ √Xdg ├ ≡ q: ┤ Rx(-π/2) ├
|
1117
|
+
# └──────┘ └──────────┘
|
1118
|
+
q = QuantumRegister(1, "q")
|
1119
|
+
sxdg_to_rx = QuantumCircuit(q, global_phase=-pi / 4)
|
1120
|
+
sxdg_to_rx.rx(-pi / 2, 0)
|
1121
|
+
_sel.add_equivalence(SXdgGate(), sxdg_to_rx)
|
1122
|
+
|
1123
|
+
# CSXGate
|
1124
|
+
#
|
1125
|
+
# q_0: ──■─── q_0: ───────■───────
|
1126
|
+
# ┌─┴──┐ ≡ ┌───┐┌─┴─┐┌───┐
|
1127
|
+
# q_1: ┤ Sx ├ q_1: ┤ H ├┤ S ├┤ H ├
|
1128
|
+
# └────┘ └───┘└───┘└───┘
|
1129
|
+
q = QuantumRegister(2, "q")
|
1130
|
+
def_csx = QuantumCircuit(q)
|
1131
|
+
for inst, qargs, cargs in [
|
1132
|
+
(HGate(), [q[1]], []),
|
1133
|
+
(CSGate(), [q[0], q[1]], []),
|
1134
|
+
(HGate(), [q[1]], []),
|
1135
|
+
]:
|
1136
|
+
def_csx.append(inst, qargs, cargs)
|
1137
|
+
_sel.add_equivalence(CSXGate(), def_csx)
|
1138
|
+
|
1139
|
+
# CSXGate
|
1140
|
+
# global phase: π/8
|
1141
|
+
# ┌───┐┌───────────┐ ┌─────┐ ┌───┐
|
1142
|
+
# q_0: ──■─── q_0: ┤ X ├┤0 ├─┤ Tdg ├──┤ X ├
|
1143
|
+
# ┌─┴──┐ ≡ └───┘│ Rzx(π/4) │┌┴─────┴─┐└───┘
|
1144
|
+
# q_1: ┤ Sx ├ q_1: ─────┤1 ├┤ sx^0.5 ├─────
|
1145
|
+
# └────┘ └───────────┘└────────┘
|
1146
|
+
q = QuantumRegister(2, "q")
|
1147
|
+
csx_to_zx45 = QuantumCircuit(q, global_phase=pi / 4)
|
1148
|
+
for inst, qargs, cargs in [
|
1149
|
+
(XGate(), [q[0]], []),
|
1150
|
+
(RZXGate(pi / 4), [q[0], q[1]], []),
|
1151
|
+
(TdgGate(), [q[0]], []),
|
1152
|
+
(XGate(), [q[0]], []),
|
1153
|
+
(RXGate(pi / 4), [q[1]], []),
|
1154
|
+
]:
|
1155
|
+
csx_to_zx45.append(inst, qargs, cargs)
|
1156
|
+
_sel.add_equivalence(CSXGate(), csx_to_zx45)
|
1157
|
+
|
1158
|
+
|
1159
|
+
# DCXGate
|
1160
|
+
#
|
1161
|
+
# ┌──────┐ ┌───┐
|
1162
|
+
# q_0: ┤0 ├ q_0: ──■──┤ X ├
|
1163
|
+
# │ Dcx │ ≡ ┌─┴─┐└─┬─┘
|
1164
|
+
# q_1: ┤1 ├ q_1: ┤ X ├──■──
|
1165
|
+
# └──────┘ └───┘
|
1166
|
+
q = QuantumRegister(2, "q")
|
1167
|
+
def_dcx = QuantumCircuit(q)
|
1168
|
+
for inst, qargs, cargs in [(CXGate(), [q[0], q[1]], []), (CXGate(), [q[1], q[0]], [])]:
|
1169
|
+
def_dcx.append(inst, qargs, cargs)
|
1170
|
+
_sel.add_equivalence(DCXGate(), def_dcx)
|
1171
|
+
|
1172
|
+
# DCXGate
|
1173
|
+
#
|
1174
|
+
# ┌──────┐ ┌───┐ ┌─────┐┌────────┐
|
1175
|
+
# q_0: ┤0 ├ q_0: ─┤ H ├─┤ Sdg ├┤0 ├─────
|
1176
|
+
# │ Dcx │ ≡ ┌┴───┴┐└─────┘│ Iswap │┌───┐
|
1177
|
+
# q_1: ┤1 ├ q_1: ┤ Sdg ├───────┤1 ├┤ H ├
|
1178
|
+
# └──────┘ └─────┘ └────────┘└───┘
|
1179
|
+
q = QuantumRegister(2, "q")
|
1180
|
+
dcx_to_iswap = QuantumCircuit(q)
|
1181
|
+
for inst, qargs, cargs in [
|
1182
|
+
(HGate(), [q[0]], []),
|
1183
|
+
(SdgGate(), [q[0]], []),
|
1184
|
+
(SdgGate(), [q[1]], []),
|
1185
|
+
(iSwapGate(), [q[0], q[1]], []),
|
1186
|
+
(HGate(), [q[1]], []),
|
1187
|
+
]:
|
1188
|
+
dcx_to_iswap.append(inst, qargs, cargs)
|
1189
|
+
_sel.add_equivalence(DCXGate(), dcx_to_iswap)
|
1190
|
+
|
1191
|
+
# CSwapGate
|
1192
|
+
#
|
1193
|
+
# q_0: ─■─ q_0: ───────■───────
|
1194
|
+
# │ ┌───┐ │ ┌───┐
|
1195
|
+
# q_1: ─X─ ≡ q_1: ┤ X ├──■──┤ X ├
|
1196
|
+
# │ └─┬─┘┌─┴─┐└─┬─┘
|
1197
|
+
# q_2: ─X─ q_2: ──■──┤ X ├──■──
|
1198
|
+
# └───┘
|
1199
|
+
q = QuantumRegister(3, "q")
|
1200
|
+
def_cswap = QuantumCircuit(q)
|
1201
|
+
for inst, qargs, cargs in [
|
1202
|
+
(CXGate(), [q[2], q[1]], []),
|
1203
|
+
(CCXGate(), [q[0], q[1], q[2]], []),
|
1204
|
+
(CXGate(), [q[2], q[1]], []),
|
1205
|
+
]:
|
1206
|
+
def_cswap.append(inst, qargs, cargs)
|
1207
|
+
_sel.add_equivalence(CSwapGate(), def_cswap)
|
1208
|
+
|
1209
|
+
# TGate
|
1210
|
+
#
|
1211
|
+
# ┌───┐ ┌────────┐
|
1212
|
+
# q: ┤ T ├ ≡ q: ┤ P(π/4) ├
|
1213
|
+
# └───┘ └────────┘
|
1214
|
+
q = QuantumRegister(1, "q")
|
1215
|
+
def_t = QuantumCircuit(q)
|
1216
|
+
def_t.append(PhaseGate(pi / 4), [q[0]], [])
|
1217
|
+
_sel.add_equivalence(TGate(), def_t)
|
1218
|
+
|
1219
|
+
# TGate
|
1220
|
+
#
|
1221
|
+
# ┌─────┐┌─────┐┌─────┐┌─────┐┌─────┐┌─────┐┌─────┐
|
1222
|
+
# q: ┤ Tdg ├┤ Tdg ├┤ Tdg ├┤ Tdg ├┤ Tdg ├┤ Tdg ├┤ Tdg ├
|
1223
|
+
# └─────┘└─────┘└─────┘└─────┘└─────┘└─────┘└─────┘
|
1224
|
+
q = QuantumRegister(1, "q")
|
1225
|
+
def_t = QuantumCircuit(q)
|
1226
|
+
for _ in range(7):
|
1227
|
+
def_t.append(TdgGate(), [q[0]], [])
|
1228
|
+
_sel.add_equivalence(TGate(), def_t)
|
1229
|
+
|
1230
|
+
# TdgGate
|
1231
|
+
#
|
1232
|
+
# ┌─────┐ ┌─────────┐
|
1233
|
+
# q: ┤ Tdg ├ ≡ q: ┤ P(-π/4) ├
|
1234
|
+
# └─────┘ └─────────┘
|
1235
|
+
q = QuantumRegister(1, "q")
|
1236
|
+
def_tdg = QuantumCircuit(q)
|
1237
|
+
def_tdg.append(PhaseGate(-pi / 4), [q[0]], [])
|
1238
|
+
_sel.add_equivalence(TdgGate(), def_tdg)
|
1239
|
+
|
1240
|
+
# TdgGate
|
1241
|
+
#
|
1242
|
+
# ┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐
|
1243
|
+
# q: ┤ T ├┤ T ├┤ T ├┤ T ├┤ T ├┤ T ├┤ T ├
|
1244
|
+
# └───┘└───┘└───┘└───┘└───┘└───┘└───┘
|
1245
|
+
q = QuantumRegister(1, "q")
|
1246
|
+
def_tdg = QuantumCircuit(q)
|
1247
|
+
for _ in range(7):
|
1248
|
+
def_tdg.append(TGate(), [q[0]], [])
|
1249
|
+
_sel.add_equivalence(TdgGate(), def_tdg)
|
1250
|
+
|
1251
|
+
# UGate
|
1252
|
+
#
|
1253
|
+
# ┌──────────┐ ┌───────────┐
|
1254
|
+
# q: ┤ U(θ,ϕ,λ) ├ ≡ q: ┤ U3(θ,ϕ,λ) ├
|
1255
|
+
# └──────────┘ └───────────┘
|
1256
|
+
q = QuantumRegister(1, "q")
|
1257
|
+
theta = Parameter("theta")
|
1258
|
+
phi = Parameter("phi")
|
1259
|
+
lam = Parameter("lam")
|
1260
|
+
u_to_u3 = QuantumCircuit(q)
|
1261
|
+
u_to_u3.append(U3Gate(theta, phi, lam), [0])
|
1262
|
+
_sel.add_equivalence(UGate(theta, phi, lam), u_to_u3)
|
1263
|
+
|
1264
|
+
# CUGate
|
1265
|
+
# ┌──────┐ ┌──────────────┐ »
|
1266
|
+
# q_0: ──────■─────── q_0: ────┤ P(γ) ├────┤ P(λ/2 + ϕ/2) ├──■──»
|
1267
|
+
# ┌─────┴──────┐ ≡ ┌───┴──────┴───┐└──────────────┘┌─┴─┐»
|
1268
|
+
# q_1: ┤ U(θ,ϕ,λ,γ) ├ q_1: ┤ P(λ/2 - ϕ/2) ├────────────────┤ X ├»
|
1269
|
+
# └────────────┘ └──────────────┘ └───┘»
|
1270
|
+
# «
|
1271
|
+
# «q_0: ──────────────────────────■────────────────
|
1272
|
+
# « ┌──────────────────────┐┌─┴─┐┌────────────┐
|
1273
|
+
# «q_1: ┤ U(-θ/2,ϕ,-λ/2 - ϕ/2) ├┤ X ├┤ U(θ/2,ϕ,0) ├
|
1274
|
+
# « └──────────────────────┘└───┘└────────────┘
|
1275
|
+
q = QuantumRegister(2, "q")
|
1276
|
+
theta = Parameter("theta")
|
1277
|
+
phi = Parameter("phi")
|
1278
|
+
lam = Parameter("lam")
|
1279
|
+
gamma = Parameter("gamma")
|
1280
|
+
def_cu = QuantumCircuit(q)
|
1281
|
+
def_cu.p(gamma, 0)
|
1282
|
+
def_cu.p((lam + phi) / 2, 0)
|
1283
|
+
def_cu.p((lam - phi) / 2, 1)
|
1284
|
+
def_cu.cx(0, 1)
|
1285
|
+
def_cu.u(-theta / 2, 0, -(phi + lam) / 2, 1)
|
1286
|
+
def_cu.cx(0, 1)
|
1287
|
+
def_cu.u(theta / 2, phi, 0, 1)
|
1288
|
+
_sel.add_equivalence(CUGate(theta, phi, lam, gamma), def_cu)
|
1289
|
+
|
1290
|
+
# CUGate
|
1291
|
+
# ┌──────┐
|
1292
|
+
# q_0: ──────■─────── q_0: ┤ P(γ) ├──────■──────
|
1293
|
+
# ┌─────┴──────┐ ≡ └──────┘┌─────┴─────┐
|
1294
|
+
# q_1: ┤ U(θ,ϕ,λ,γ) ├ q_1: ────────┤ U3(θ,ϕ,λ) ├
|
1295
|
+
# └────────────┘ └───────────┘
|
1296
|
+
q = QuantumRegister(2, "q")
|
1297
|
+
theta = Parameter("theta")
|
1298
|
+
phi = Parameter("phi")
|
1299
|
+
lam = Parameter("lam")
|
1300
|
+
gamma = Parameter("gamma")
|
1301
|
+
cu_to_cu3 = QuantumCircuit(q)
|
1302
|
+
cu_to_cu3.p(gamma, 0)
|
1303
|
+
cu_to_cu3.append(CU3Gate(theta, phi, lam), [0, 1])
|
1304
|
+
_sel.add_equivalence(CUGate(theta, phi, lam, gamma), cu_to_cu3)
|
1305
|
+
|
1306
|
+
# U1Gate
|
1307
|
+
#
|
1308
|
+
# ┌───────┐ ┌───────────┐
|
1309
|
+
# q: ┤ U1(θ) ├ ≡ q: ┤ U3(0,0,θ) ├
|
1310
|
+
# └───────┘ └───────────┘
|
1311
|
+
q = QuantumRegister(1, "q")
|
1312
|
+
theta = Parameter("theta")
|
1313
|
+
def_u1 = QuantumCircuit(q)
|
1314
|
+
def_u1.append(U3Gate(0, 0, theta), [q[0]], [])
|
1315
|
+
_sel.add_equivalence(U1Gate(theta), def_u1)
|
1316
|
+
|
1317
|
+
# U1Gate
|
1318
|
+
#
|
1319
|
+
# ┌───────┐ ┌──────┐
|
1320
|
+
# q: ┤ U1(θ) ├ ≡ q: ┤ P(0) ├
|
1321
|
+
# └───────┘ └──────┘
|
1322
|
+
q = QuantumRegister(1, "q")
|
1323
|
+
theta = Parameter("theta")
|
1324
|
+
u1_to_phase = QuantumCircuit(q)
|
1325
|
+
u1_to_phase.p(theta, 0)
|
1326
|
+
_sel.add_equivalence(U1Gate(theta), u1_to_phase)
|
1327
|
+
|
1328
|
+
# U1Gate
|
1329
|
+
# global phase: θ/2
|
1330
|
+
# ┌───────┐ ┌───────┐
|
1331
|
+
# q: ┤ U1(θ) ├ ≡ q: ┤ Rz(θ) ├
|
1332
|
+
# └───────┘ └───────┘
|
1333
|
+
q = QuantumRegister(1, "q")
|
1334
|
+
theta = Parameter("theta")
|
1335
|
+
u1_to_rz = QuantumCircuit(q, global_phase=theta / 2)
|
1336
|
+
u1_to_rz.append(RZGate(theta), [q[0]], [])
|
1337
|
+
_sel.add_equivalence(U1Gate(theta), u1_to_rz)
|
1338
|
+
|
1339
|
+
# CU1Gate
|
1340
|
+
# ┌────────┐
|
1341
|
+
# q_0: ─■───── q_0: ┤ P(θ/2) ├──■───────────────■────────────
|
1342
|
+
# │U1(θ) ≡ └────────┘┌─┴─┐┌─────────┐┌─┴─┐┌────────┐
|
1343
|
+
# q_1: ─■───── q_1: ──────────┤ X ├┤ P(-θ/2) ├┤ X ├┤ P(θ/2) ├
|
1344
|
+
# └───┘└─────────┘└───┘└────────┘
|
1345
|
+
q = QuantumRegister(2, "q")
|
1346
|
+
theta = Parameter("theta")
|
1347
|
+
def_cu1 = QuantumCircuit(q)
|
1348
|
+
for inst, qargs, cargs in [
|
1349
|
+
(PhaseGate(theta / 2), [q[0]], []),
|
1350
|
+
(CXGate(), [q[0], q[1]], []),
|
1351
|
+
(PhaseGate(-theta / 2), [q[1]], []),
|
1352
|
+
(CXGate(), [q[0], q[1]], []),
|
1353
|
+
(PhaseGate(theta / 2), [q[1]], []),
|
1354
|
+
]:
|
1355
|
+
def_cu1.append(inst, qargs, cargs)
|
1356
|
+
_sel.add_equivalence(CU1Gate(theta), def_cu1)
|
1357
|
+
|
1358
|
+
# U2Gate
|
1359
|
+
#
|
1360
|
+
# ┌─────────┐ ┌────────────┐
|
1361
|
+
# q: ┤ U2(ϕ,λ) ├ ≡ q: ┤ U(π/2,ϕ,λ) ├
|
1362
|
+
# └─────────┘ └────────────┘
|
1363
|
+
q = QuantumRegister(1, "q")
|
1364
|
+
phi = Parameter("phi")
|
1365
|
+
lam = Parameter("lam")
|
1366
|
+
def_u2 = QuantumCircuit(q)
|
1367
|
+
def_u2.append(UGate(pi / 2, phi, lam), [q[0]], [])
|
1368
|
+
_sel.add_equivalence(U2Gate(phi, lam), def_u2)
|
1369
|
+
|
1370
|
+
# U2Gate
|
1371
|
+
# global phase: 7π/4
|
1372
|
+
# ┌─────────┐ ┌─────────────┐┌────┐┌─────────────┐
|
1373
|
+
# q: ┤ U2(ϕ,λ) ├ ≡ q: ┤ U1(λ - π/2) ├┤ √X ├┤ U1(ϕ + π/2) ├
|
1374
|
+
# └─────────┘ └─────────────┘└────┘└─────────────┘
|
1375
|
+
q = QuantumRegister(1, "q")
|
1376
|
+
phi = Parameter("phi")
|
1377
|
+
lam = Parameter("lam")
|
1378
|
+
u2_to_u1sx = QuantumCircuit(q, global_phase=-pi / 4)
|
1379
|
+
u2_to_u1sx.append(U1Gate(lam - pi / 2), [0])
|
1380
|
+
u2_to_u1sx.sx(0)
|
1381
|
+
u2_to_u1sx.append(U1Gate(phi + pi / 2), [0])
|
1382
|
+
_sel.add_equivalence(U2Gate(phi, lam), u2_to_u1sx)
|
1383
|
+
|
1384
|
+
# U3Gate
|
1385
|
+
# global phase: λ/2 + ϕ/2 - π/2
|
1386
|
+
# ┌───────────┐ ┌───────┐┌────┐┌───────────┐┌────┐┌────────────┐
|
1387
|
+
# q: ┤ U3(θ,ϕ,λ) ├ ≡ q: ┤ Rz(λ) ├┤ √X ├┤ Rz(θ + π) ├┤ √X ├┤ Rz(ϕ + 3π) ├
|
1388
|
+
# └───────────┘ └───────┘└────┘└───────────┘└────┘└────────────┘
|
1389
|
+
q = QuantumRegister(1, "q")
|
1390
|
+
theta = Parameter("theta")
|
1391
|
+
phi = Parameter("phi")
|
1392
|
+
lam = Parameter("lam")
|
1393
|
+
u3_qasm_def = QuantumCircuit(q, global_phase=(lam + phi - pi) / 2)
|
1394
|
+
u3_qasm_def.rz(lam, 0)
|
1395
|
+
u3_qasm_def.sx(0)
|
1396
|
+
u3_qasm_def.rz(theta + pi, 0)
|
1397
|
+
u3_qasm_def.sx(0)
|
1398
|
+
u3_qasm_def.rz(phi + 3 * pi, 0)
|
1399
|
+
_sel.add_equivalence(U3Gate(theta, phi, lam), u3_qasm_def)
|
1400
|
+
|
1401
|
+
# U3Gate
|
1402
|
+
#
|
1403
|
+
# ┌───────────┐ ┌──────────┐
|
1404
|
+
# q: ┤ U3(θ,ϕ,λ) ├ ≡ q: ┤ U(θ,ϕ,λ) ├
|
1405
|
+
# └───────────┘ └──────────┘
|
1406
|
+
q = QuantumRegister(1, "q")
|
1407
|
+
theta = Parameter("theta")
|
1408
|
+
phi = Parameter("phi")
|
1409
|
+
lam = Parameter("lam")
|
1410
|
+
u3_to_u = QuantumCircuit(q)
|
1411
|
+
u3_to_u.u(theta, phi, lam, 0)
|
1412
|
+
_sel.add_equivalence(U3Gate(theta, phi, lam), u3_to_u)
|
1413
|
+
|
1414
|
+
# CU3Gate
|
1415
|
+
# ┌──────────────┐ »
|
1416
|
+
# q_0: ──────■────── q_0: ┤ P(λ/2 + ϕ/2) ├──■────────────────────────────■──»
|
1417
|
+
# ┌─────┴─────┐ ≡ ├──────────────┤┌─┴─┐┌──────────────────────┐┌─┴─┐»
|
1418
|
+
# q_1: ┤ U3(θ,ϕ,λ) ├ q_1: ┤ P(λ/2 - ϕ/2) ├┤ X ├┤ U(-θ/2,0,-λ/2 - ϕ/2) ├┤ X ├»
|
1419
|
+
# └───────────┘ └──────────────┘└───┘└──────────────────────┘└───┘»
|
1420
|
+
# «
|
1421
|
+
# «q_0: ──────────────
|
1422
|
+
# « ┌────────────┐
|
1423
|
+
# «q_1: ┤ P(θ/2,ϕ,0) ├
|
1424
|
+
# « └────────────┘
|
1425
|
+
q = QuantumRegister(2, "q")
|
1426
|
+
theta = Parameter("theta")
|
1427
|
+
phi = Parameter("phi")
|
1428
|
+
lam = Parameter("lam")
|
1429
|
+
def_cu3 = QuantumCircuit(q)
|
1430
|
+
for inst, qargs, cargs in [
|
1431
|
+
(PhaseGate((lam + phi) / 2), [q[0]], []),
|
1432
|
+
(PhaseGate((lam - phi) / 2), [q[1]], []),
|
1433
|
+
(CXGate(), [q[0], q[1]], []),
|
1434
|
+
(UGate(-theta / 2, 0, -(phi + lam) / 2), [q[1]], []),
|
1435
|
+
(CXGate(), [q[0], q[1]], []),
|
1436
|
+
(UGate(theta / 2, phi, 0), [q[1]], []),
|
1437
|
+
]:
|
1438
|
+
def_cu3.append(inst, qargs, cargs)
|
1439
|
+
_sel.add_equivalence(CU3Gate(theta, phi, lam), def_cu3)
|
1440
|
+
|
1441
|
+
q = QuantumRegister(2, "q")
|
1442
|
+
theta = Parameter("theta")
|
1443
|
+
phi = Parameter("phi")
|
1444
|
+
lam = Parameter("lam")
|
1445
|
+
cu3_to_cu = QuantumCircuit(q)
|
1446
|
+
cu3_to_cu.cu(theta, phi, lam, 0, 0, 1)
|
1447
|
+
_sel.add_equivalence(CU3Gate(theta, phi, lam), cu3_to_cu)
|
1448
|
+
|
1449
|
+
# XGate
|
1450
|
+
#
|
1451
|
+
# ┌───┐ ┌──────────┐
|
1452
|
+
# q: ┤ X ├ ≡ q: ┤ U(π,0,π) ├
|
1453
|
+
# └───┘ └──────────┘
|
1454
|
+
q = QuantumRegister(1, "q")
|
1455
|
+
def_x = QuantumCircuit(q)
|
1456
|
+
def_x.append(UGate(pi, 0, pi), [q[0]], [])
|
1457
|
+
_sel.add_equivalence(XGate(), def_x)
|
1458
|
+
|
1459
|
+
# XGate
|
1460
|
+
#
|
1461
|
+
# ┌───┐ ┌───┐┌───┐┌───┐┌───┐
|
1462
|
+
# q: ┤ X ├ ≡ q: ┤ H ├┤ S ├┤ S ├┤ H ├
|
1463
|
+
# └───┘ └───┘└───┘└───┘└───┘
|
1464
|
+
q = QuantumRegister(1, "q")
|
1465
|
+
def_x = QuantumCircuit(q)
|
1466
|
+
for inst, qargs, cargs in [
|
1467
|
+
(HGate(), [q[0]], []),
|
1468
|
+
(SGate(), [q[0]], []),
|
1469
|
+
(SGate(), [q[0]], []),
|
1470
|
+
(HGate(), [q[0]], []),
|
1471
|
+
]:
|
1472
|
+
def_x.append(inst, qargs, cargs)
|
1473
|
+
_sel.add_equivalence(XGate(), def_x)
|
1474
|
+
|
1475
|
+
# XGate
|
1476
|
+
# global phase: π/2
|
1477
|
+
# ┌───┐ ┌───┐┌───┐
|
1478
|
+
# q: ┤ X ├ ≡ q: ┤ Y ├┤ Z ├
|
1479
|
+
# └───┘ └───┘└───┘
|
1480
|
+
def_x = QuantumCircuit(1, global_phase=pi / 2)
|
1481
|
+
def_x.y(0)
|
1482
|
+
def_x.z(0)
|
1483
|
+
_sel.add_equivalence(XGate(), def_x)
|
1484
|
+
|
1485
|
+
# CXGate
|
1486
|
+
|
1487
|
+
for pos_ry in [False, True]:
|
1488
|
+
for pos_rxx in [False, True]:
|
1489
|
+
cx_to_rxx = _cnot_rxx_decompose(pos_ry, pos_rxx)
|
1490
|
+
_sel.add_equivalence(CXGate(), cx_to_rxx)
|
1491
|
+
|
1492
|
+
# CXGate
|
1493
|
+
#
|
1494
|
+
# q_0: ──■── q_0: ──────■──────
|
1495
|
+
# ┌─┴─┐ ≡ ┌───┐ │ ┌───┐
|
1496
|
+
# q_1: ┤ X ├ q_1: ┤ H ├─■─┤ H ├
|
1497
|
+
# └───┘ └───┘ └───┘
|
1498
|
+
q = QuantumRegister(2, "q")
|
1499
|
+
cx_to_cz = QuantumCircuit(q)
|
1500
|
+
for inst, qargs, cargs in [
|
1501
|
+
(HGate(), [q[1]], []),
|
1502
|
+
(CZGate(), [q[0], q[1]], []),
|
1503
|
+
(HGate(), [q[1]], []),
|
1504
|
+
]:
|
1505
|
+
cx_to_cz.append(inst, qargs, cargs)
|
1506
|
+
_sel.add_equivalence(CXGate(), cx_to_cz)
|
1507
|
+
|
1508
|
+
# CXGate
|
1509
|
+
# global phase: 3π/4
|
1510
|
+
# ┌───┐ ┌────────┐┌───┐ ┌────────┐┌───┐┌───┐
|
1511
|
+
# q_0: ──■── q_0: ┤ H ├─────┤0 ├┤ X ├─────┤0 ├┤ H ├┤ S ├─────
|
1512
|
+
# ┌─┴─┐ ≡ ├───┤┌───┐│ Iswap │├───┤┌───┐│ Iswap │├───┤├───┤┌───┐
|
1513
|
+
# q_1: ┤ X ├ q_1: ┤ X ├┤ H ├┤1 ├┤ X ├┤ H ├┤1 ├┤ S ├┤ X ├┤ H ├
|
1514
|
+
# └───┘ └───┘└───┘└────────┘└───┘└───┘└────────┘└───┘└───┘└───┘
|
1515
|
+
q = QuantumRegister(2, "q")
|
1516
|
+
cx_to_iswap = QuantumCircuit(q, global_phase=3 * pi / 4)
|
1517
|
+
for inst, qargs, cargs in [
|
1518
|
+
(HGate(), [q[0]], []),
|
1519
|
+
(XGate(), [q[1]], []),
|
1520
|
+
(HGate(), [q[1]], []),
|
1521
|
+
(iSwapGate(), [q[0], q[1]], []),
|
1522
|
+
(XGate(), [q[0]], []),
|
1523
|
+
(XGate(), [q[1]], []),
|
1524
|
+
(HGate(), [q[1]], []),
|
1525
|
+
(iSwapGate(), [q[0], q[1]], []),
|
1526
|
+
(HGate(), [q[0]], []),
|
1527
|
+
(SGate(), [q[0]], []),
|
1528
|
+
(SGate(), [q[1]], []),
|
1529
|
+
(XGate(), [q[1]], []),
|
1530
|
+
(HGate(), [q[1]], []),
|
1531
|
+
]:
|
1532
|
+
cx_to_iswap.append(inst, qargs, cargs)
|
1533
|
+
_sel.add_equivalence(CXGate(), cx_to_iswap)
|
1534
|
+
|
1535
|
+
# CXGate
|
1536
|
+
# global phase: 7π/4
|
1537
|
+
# ┌──────────┐┌───────┐┌──────┐
|
1538
|
+
# q_0: ──■── q_0: ┤ Rz(-π/2) ├┤ Ry(π) ├┤0 ├
|
1539
|
+
# ┌─┴─┐ ≡ ├─────────┬┘└───────┘│ Ecr │
|
1540
|
+
# q_1: ┤ X ├ q_1: ┤ Rx(π/2) ├──────────┤1 ├
|
1541
|
+
# └───┘ └─────────┘ └──────┘
|
1542
|
+
q = QuantumRegister(2, "q")
|
1543
|
+
cx_to_ecr = QuantumCircuit(q, global_phase=-pi / 4)
|
1544
|
+
for inst, qargs, cargs in [
|
1545
|
+
(RZGate(-pi / 2), [q[0]], []),
|
1546
|
+
(RYGate(pi), [q[0]], []),
|
1547
|
+
(RXGate(pi / 2), [q[1]], []),
|
1548
|
+
(ECRGate(), [q[0], q[1]], []),
|
1549
|
+
]:
|
1550
|
+
cx_to_ecr.append(inst, qargs, cargs)
|
1551
|
+
_sel.add_equivalence(CXGate(), cx_to_ecr)
|
1552
|
+
|
1553
|
+
# CXGate
|
1554
|
+
# q_0: ──■── q_0: ───────────────■───────────────────
|
1555
|
+
# ┌─┴─┐ ≡ ┌────────────┐ │P(π) ┌────────────┐
|
1556
|
+
# q_1: ┤ X ├ q_1: ┤ U(π/2,0,π) ├─■─────┤ U(π/2,0,π) ├
|
1557
|
+
# └───┘ └────────────┘ └────────────┘
|
1558
|
+
q = QuantumRegister(2, "q")
|
1559
|
+
cx_to_cp = QuantumCircuit(q)
|
1560
|
+
for inst, qargs, cargs in [
|
1561
|
+
(UGate(pi / 2, 0, pi), [q[1]], []),
|
1562
|
+
(CPhaseGate(pi), [q[0], q[1]], []),
|
1563
|
+
(UGate(pi / 2, 0, pi), [q[1]], []),
|
1564
|
+
]:
|
1565
|
+
cx_to_cp.append(inst, qargs, cargs)
|
1566
|
+
_sel.add_equivalence(CXGate(), cx_to_cp)
|
1567
|
+
|
1568
|
+
# CXGate
|
1569
|
+
# ┌────────────┐
|
1570
|
+
# q_0: ──■── q_0: ┤ U(0,0,π/2) ├────■──────────────────
|
1571
|
+
# ┌─┴─┐ ≡ ├────────────┤┌───┴───┐┌────────────┐
|
1572
|
+
# q_1: ┤ X ├ q_1: ┤ U(π/2,0,π) ├┤ Rz(π) ├┤ U(π/2,0,π) ├
|
1573
|
+
# └───┘ └────────────┘└───────┘└────────────┘
|
1574
|
+
q = QuantumRegister(2, "q")
|
1575
|
+
cx_to_crz = QuantumCircuit(q)
|
1576
|
+
for inst, qargs, cargs in [
|
1577
|
+
(UGate(pi / 2, 0, pi), [q[1]], []),
|
1578
|
+
(UGate(0, 0, pi / 2), [q[0]], []),
|
1579
|
+
(CRZGate(pi), [q[0], q[1]], []),
|
1580
|
+
(UGate(pi / 2, 0, pi), [q[1]], []),
|
1581
|
+
]:
|
1582
|
+
cx_to_crz.append(inst, qargs, cargs)
|
1583
|
+
_sel.add_equivalence(CXGate(), cx_to_crz)
|
1584
|
+
|
1585
|
+
# CXGate
|
1586
|
+
# global phase: π/4
|
1587
|
+
# ┌───────────┐┌─────┐
|
1588
|
+
# q_0: ──■── q_0: ┤0 ├┤ Sdg ├─
|
1589
|
+
# ┌─┴─┐ ≡ │ Rzx(π/2) │├─────┴┐
|
1590
|
+
# q_1: ┤ X ├ q_1: ┤1 ├┤ √Xdg ├
|
1591
|
+
# └───┘ └───────────┘└──────┘
|
1592
|
+
q = QuantumRegister(2, "q")
|
1593
|
+
cx_to_zx90 = QuantumCircuit(q, global_phase=pi / 4)
|
1594
|
+
for inst, qargs, cargs in [
|
1595
|
+
(RZXGate(pi / 2), [q[0], q[1]], []),
|
1596
|
+
(SdgGate(), [q[0]], []),
|
1597
|
+
(SXdgGate(), [q[1]], []),
|
1598
|
+
]:
|
1599
|
+
cx_to_zx90.append(inst, qargs, cargs)
|
1600
|
+
_sel.add_equivalence(CXGate(), cx_to_zx90)
|
1601
|
+
|
1602
|
+
# CCXGate
|
1603
|
+
# ┌───┐
|
1604
|
+
# q_0: ──■── q_0: ───────────────────■─────────────────────■────■───┤ T ├───■──
|
1605
|
+
# │ │ ┌───┐ │ ┌─┴─┐┌┴───┴┐┌─┴─┐
|
1606
|
+
# q_1: ──■── ≡ q_1: ───────■───────────┼─────────■───┤ T ├───┼──┤ X ├┤ Tdg ├┤ X ├
|
1607
|
+
# ┌─┴─┐ ┌───┐┌─┴─┐┌─────┐┌─┴─┐┌───┐┌─┴─┐┌┴───┴┐┌─┴─┐├───┤└┬───┬┘└───┘
|
1608
|
+
# q_2: ┤ X ├ q_2: ┤ H ├┤ X ├┤ Tdg ├┤ X ├┤ T ├┤ X ├┤ Tdg ├┤ X ├┤ T ├─┤ H ├──────
|
1609
|
+
# └───┘ └───┘└───┘└─────┘└───┘└───┘└───┘└─────┘└───┘└───┘ └───┘
|
1610
|
+
q = QuantumRegister(3, "q")
|
1611
|
+
def_ccx = QuantumCircuit(q)
|
1612
|
+
for inst, qargs, cargs in [
|
1613
|
+
(HGate(), [q[2]], []),
|
1614
|
+
(CXGate(), [q[1], q[2]], []),
|
1615
|
+
(TdgGate(), [q[2]], []),
|
1616
|
+
(CXGate(), [q[0], q[2]], []),
|
1617
|
+
(TGate(), [q[2]], []),
|
1618
|
+
(CXGate(), [q[1], q[2]], []),
|
1619
|
+
(TdgGate(), [q[2]], []),
|
1620
|
+
(CXGate(), [q[0], q[2]], []),
|
1621
|
+
(TGate(), [q[1]], []),
|
1622
|
+
(TGate(), [q[2]], []),
|
1623
|
+
(HGate(), [q[2]], []),
|
1624
|
+
(CXGate(), [q[0], q[1]], []),
|
1625
|
+
(TGate(), [q[0]], []),
|
1626
|
+
(TdgGate(), [q[1]], []),
|
1627
|
+
(CXGate(), [q[0], q[1]], []),
|
1628
|
+
]:
|
1629
|
+
def_ccx.append(inst, qargs, cargs)
|
1630
|
+
_sel.add_equivalence(CCXGate(), def_ccx)
|
1631
|
+
|
1632
|
+
# CCXGate
|
1633
|
+
#
|
1634
|
+
# q_0: ──■── q_0: ────────■─────────────────■────■───
|
1635
|
+
# │ ┌─┴─┐┌─────┐ ┌─┴─┐ │
|
1636
|
+
# q_1: ──■── ≡ q_1: ──■───┤ X ├┤ Sdg ├──■───┤ X ├──┼───
|
1637
|
+
# ┌─┴─┐ ┌─┴──┐├───┤└─────┘┌─┴──┐├───┤┌─┴──┐
|
1638
|
+
# q_2: ┤ X ├ q_2: ┤ Sx ├┤ Z ├───────┤ Sx ├┤ Z ├┤ Sx ├
|
1639
|
+
# └───┘ └────┘└───┘ └────┘└───┘└────┘
|
1640
|
+
q = QuantumRegister(3, "q")
|
1641
|
+
ccx_to_cx_csx = QuantumCircuit(q)
|
1642
|
+
for inst, qargs, cargs in [
|
1643
|
+
(CSXGate(), [q[1], q[2]], []),
|
1644
|
+
(CXGate(), [q[0], q[1]], []),
|
1645
|
+
(ZGate(), [q[2]], []),
|
1646
|
+
(SdgGate(), [q[1]], []),
|
1647
|
+
(CSXGate(), [q[1], q[2]], []),
|
1648
|
+
(ZGate(), [q[2]], []),
|
1649
|
+
(CXGate(), [q[0], q[1]], []),
|
1650
|
+
(CSXGate(), [q[0], q[2]], []),
|
1651
|
+
]:
|
1652
|
+
ccx_to_cx_csx.append(inst, qargs, cargs)
|
1653
|
+
_sel.add_equivalence(CCXGate(), ccx_to_cx_csx)
|
1654
|
+
|
1655
|
+
# YGate
|
1656
|
+
#
|
1657
|
+
# ┌───┐ ┌──────────────┐
|
1658
|
+
# q: ┤ Y ├ ≡ q: ┤ U(π,π/2,π/2) ├
|
1659
|
+
# └───┘ └──────────────┘
|
1660
|
+
q = QuantumRegister(1, "q")
|
1661
|
+
def_y = QuantumCircuit(q)
|
1662
|
+
def_y.append(UGate(pi, pi / 2, pi / 2), [q[0]], [])
|
1663
|
+
_sel.add_equivalence(YGate(), def_y)
|
1664
|
+
|
1665
|
+
# YGate
|
1666
|
+
# global phase: 3π/2
|
1667
|
+
# ┌───┐ ┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐
|
1668
|
+
# q: ┤ Y ├ ≡ q: ┤ H ├┤ S ├┤ S ├┤ H ├┤ S ├┤ S ├
|
1669
|
+
# └───┘ └───┘└───┘└───┘└───┘└───┘└───┘
|
1670
|
+
q = QuantumRegister(1, "q")
|
1671
|
+
def_y = QuantumCircuit(q)
|
1672
|
+
def_y.global_phase = 3 * pi / 2
|
1673
|
+
for inst, qargs, cargs in [
|
1674
|
+
(HGate(), [q[0]], []),
|
1675
|
+
(SGate(), [q[0]], []),
|
1676
|
+
(SGate(), [q[0]], []),
|
1677
|
+
(HGate(), [q[0]], []),
|
1678
|
+
(SGate(), [q[0]], []),
|
1679
|
+
(SGate(), [q[0]], []),
|
1680
|
+
]:
|
1681
|
+
def_y.append(inst, qargs, cargs)
|
1682
|
+
_sel.add_equivalence(YGate(), def_y)
|
1683
|
+
|
1684
|
+
# YGate
|
1685
|
+
# global phase: π/2
|
1686
|
+
# ┌───┐ ┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐
|
1687
|
+
# q: ┤ Y ├ ≡ q: ┤ S ├┤ S ├┤ H ├┤ S ├┤ S ├┤ H ├
|
1688
|
+
# └───┘ └───┘└───┘└───┘└───┘└───┘└───┘
|
1689
|
+
q = QuantumRegister(1, "q")
|
1690
|
+
def_y = QuantumCircuit(q)
|
1691
|
+
def_y.global_phase = pi / 2
|
1692
|
+
for inst, qargs, cargs in [
|
1693
|
+
(SGate(), [q[0]], []),
|
1694
|
+
(SGate(), [q[0]], []),
|
1695
|
+
(HGate(), [q[0]], []),
|
1696
|
+
(SGate(), [q[0]], []),
|
1697
|
+
(SGate(), [q[0]], []),
|
1698
|
+
(HGate(), [q[0]], []),
|
1699
|
+
]:
|
1700
|
+
def_y.append(inst, qargs, cargs)
|
1701
|
+
_sel.add_equivalence(YGate(), def_y)
|
1702
|
+
|
1703
|
+
# YGate
|
1704
|
+
# global phase: π/2
|
1705
|
+
# ┌───┐ ┌───┐┌───┐
|
1706
|
+
# q: ┤ Y ├ ≡ q: ┤ Z ├┤ X ├
|
1707
|
+
# └───┘ └───┘└───┘
|
1708
|
+
def_y = QuantumCircuit(1, global_phase=pi / 2)
|
1709
|
+
def_y.z(0)
|
1710
|
+
def_y.x(0)
|
1711
|
+
_sel.add_equivalence(YGate(), def_y)
|
1712
|
+
|
1713
|
+
# CYGate
|
1714
|
+
#
|
1715
|
+
# q_0: ──■── q_0: ─────────■───────
|
1716
|
+
# ┌─┴─┐ ≡ ┌─────┐┌─┴─┐┌───┐
|
1717
|
+
# q_1: ┤ Y ├ q_1: ┤ Sdg ├┤ X ├┤ S ├
|
1718
|
+
# └───┘ └─────┘└───┘└───┘
|
1719
|
+
q = QuantumRegister(2, "q")
|
1720
|
+
def_cy = QuantumCircuit(q)
|
1721
|
+
for inst, qargs, cargs in [
|
1722
|
+
(SdgGate(), [q[1]], []),
|
1723
|
+
(CXGate(), [q[0], q[1]], []),
|
1724
|
+
(SGate(), [q[1]], []),
|
1725
|
+
]:
|
1726
|
+
def_cy.append(inst, qargs, cargs)
|
1727
|
+
_sel.add_equivalence(CYGate(), def_cy)
|
1728
|
+
|
1729
|
+
# ZGate
|
1730
|
+
#
|
1731
|
+
# ┌───┐ ┌──────┐
|
1732
|
+
# q: ┤ Z ├ ≡ q: ┤ P(π) ├
|
1733
|
+
# └───┘ └──────┘
|
1734
|
+
q = QuantumRegister(1, "q")
|
1735
|
+
def_z = QuantumCircuit(q)
|
1736
|
+
def_z.append(PhaseGate(pi), [q[0]], [])
|
1737
|
+
_sel.add_equivalence(ZGate(), def_z)
|
1738
|
+
|
1739
|
+
# ZGate
|
1740
|
+
#
|
1741
|
+
# ┌───┐ ┌───┐┌───┐
|
1742
|
+
# q: ┤ Z ├ ≡ q: ┤ S ├┤ S ├
|
1743
|
+
# └───┘ └───┘└───┘
|
1744
|
+
q = QuantumRegister(1, "q")
|
1745
|
+
def_z = QuantumCircuit(q)
|
1746
|
+
for inst, qargs, cargs in [
|
1747
|
+
(SGate(), [q[0]], []),
|
1748
|
+
(SGate(), [q[0]], []),
|
1749
|
+
]:
|
1750
|
+
def_z.append(inst, qargs, cargs)
|
1751
|
+
_sel.add_equivalence(ZGate(), def_z)
|
1752
|
+
|
1753
|
+
# ZGate
|
1754
|
+
# global phase: π/2
|
1755
|
+
# ┌───┐ ┌───┐┌───┐
|
1756
|
+
# q: ┤ Z ├ ≡ q: ┤ X ├┤ Y ├
|
1757
|
+
# └───┘ └───┘└───┘
|
1758
|
+
def_z = QuantumCircuit(1, global_phase=pi / 2)
|
1759
|
+
def_z.x(0)
|
1760
|
+
def_z.y(0)
|
1761
|
+
_sel.add_equivalence(ZGate(), def_z)
|
1762
|
+
|
1763
|
+
# CZGate
|
1764
|
+
#
|
1765
|
+
# q_0: ─■─ q_0: ───────■───────
|
1766
|
+
# │ ≡ ┌───┐┌─┴─┐┌───┐
|
1767
|
+
# q_1: ─■─ q_1: ┤ H ├┤ X ├┤ H ├
|
1768
|
+
# └───┘└───┘└───┘
|
1769
|
+
q = QuantumRegister(2, "q")
|
1770
|
+
def_cz = QuantumCircuit(q)
|
1771
|
+
for inst, qargs, cargs in [
|
1772
|
+
(HGate(), [q[1]], []),
|
1773
|
+
(CXGate(), [q[0], q[1]], []),
|
1774
|
+
(HGate(), [q[1]], []),
|
1775
|
+
]:
|
1776
|
+
def_cz.append(inst, qargs, cargs)
|
1777
|
+
_sel.add_equivalence(CZGate(), def_cz)
|
1778
|
+
|
1779
|
+
# CCZGate
|
1780
|
+
#
|
1781
|
+
# q_0: ─■─ q_0: ───────■───────
|
1782
|
+
# │ │
|
1783
|
+
# q_1: ─■─ = q_1: ───────■───────
|
1784
|
+
# │ ┌───┐┌─┴─┐┌───┐
|
1785
|
+
# q_2: ─■─ q_2: ┤ H ├┤ X ├┤ H ├
|
1786
|
+
# └───┘└───┘└───┘
|
1787
|
+
q = QuantumRegister(3, "q")
|
1788
|
+
def_ccz = QuantumCircuit(q)
|
1789
|
+
for inst, qargs, cargs in [
|
1790
|
+
(HGate(), [q[2]], []),
|
1791
|
+
(CCXGate(), [q[0], q[1], q[2]], []),
|
1792
|
+
(HGate(), [q[2]], []),
|
1793
|
+
]:
|
1794
|
+
def_ccz.append(inst, qargs, cargs)
|
1795
|
+
_sel.add_equivalence(CCZGate(), def_ccz)
|
1796
|
+
|
1797
|
+
# XGate
|
1798
|
+
# global phase: π/2
|
1799
|
+
# ┌───┐ ┌───────┐
|
1800
|
+
# q: ┤ X ├ ≡ q: ┤ Rx(π) ├
|
1801
|
+
# └───┘ └───────┘
|
1802
|
+
q = QuantumRegister(1, "q")
|
1803
|
+
x_to_rx = QuantumCircuit(q)
|
1804
|
+
x_to_rx.append(RXGate(theta=pi), [q[0]])
|
1805
|
+
x_to_rx.global_phase = pi / 2
|
1806
|
+
_sel.add_equivalence(XGate(), x_to_rx)
|
1807
|
+
|
1808
|
+
# YGate
|
1809
|
+
# global phase: π/2
|
1810
|
+
# ┌───┐ ┌───────┐
|
1811
|
+
# q: ┤ Y ├ ≡ q: ┤ Ry(π) ├
|
1812
|
+
# └───┘ └───────┘
|
1813
|
+
q = QuantumRegister(1, "q")
|
1814
|
+
y_to_ry = QuantumCircuit(q)
|
1815
|
+
y_to_ry.append(RYGate(theta=pi), [q[0]])
|
1816
|
+
y_to_ry.global_phase = pi / 2
|
1817
|
+
_sel.add_equivalence(YGate(), y_to_ry)
|
1818
|
+
|
1819
|
+
# HGate
|
1820
|
+
# global phase: π/2
|
1821
|
+
# ┌───┐ ┌─────────┐┌───────┐
|
1822
|
+
# q: ┤ H ├ ≡ q: ┤ Ry(π/2) ├┤ Rx(π) ├
|
1823
|
+
# └───┘ └─────────┘└───────┘
|
1824
|
+
q = QuantumRegister(1, "q")
|
1825
|
+
h_to_rxry = QuantumCircuit(q)
|
1826
|
+
h_to_rxry.append(RYGate(theta=pi / 2), [q[0]])
|
1827
|
+
h_to_rxry.append(RXGate(theta=pi), [q[0]])
|
1828
|
+
h_to_rxry.global_phase = pi / 2
|
1829
|
+
_sel.add_equivalence(HGate(), h_to_rxry)
|
1830
|
+
|
1831
|
+
# HGate
|
1832
|
+
# global phase: π/2
|
1833
|
+
# ┌───┐ ┌────────────┐┌────────┐
|
1834
|
+
# q: ┤ H ├ ≡ q: ┤ R(π/2,π/2) ├┤ R(π,0) ├
|
1835
|
+
# └───┘ └────────────┘└────────┘
|
1836
|
+
q = QuantumRegister(1, "q")
|
1837
|
+
h_to_rr = QuantumCircuit(q)
|
1838
|
+
h_to_rr.append(RGate(theta=pi / 2, phi=pi / 2), [q[0]])
|
1839
|
+
h_to_rr.append(RGate(theta=pi, phi=0), [q[0]])
|
1840
|
+
h_to_rr.global_phase = pi / 2
|
1841
|
+
_sel.add_equivalence(HGate(), h_to_rr)
|
1842
|
+
|
1843
|
+
# XXPlusYYGate
|
1844
|
+
# ┌───────────────┐
|
1845
|
+
# ┤0 ├
|
1846
|
+
# │ {XX+YY}(θ,β) │
|
1847
|
+
# ┤1 ├
|
1848
|
+
# └───────────────┘
|
1849
|
+
# ┌───────┐ ┌───┐ ┌───┐┌────────────┐┌───┐ ┌─────┐ ┌────────────┐
|
1850
|
+
# ─┤ Rz(β) ├──┤ S ├────────────┤ X ├┤ Ry(-0.5*θ) ├┤ X ├──┤ Sdg ├───┤ Rz(-1.0*β) ├───────────
|
1851
|
+
# ≡ ┌┴───────┴─┐├───┴┐┌─────────┐└─┬─┘├────────────┤└─┬─┘┌─┴─────┴──┐└──┬──────┬──┘┌─────────┐
|
1852
|
+
# ┤ Rz(-π/2) ├┤ √X ├┤ Rz(π/2) ├──■──┤ Ry(-0.5*θ) ├──■──┤ Rz(-π/2) ├───┤ √Xdg ├───┤ Rz(π/2) ├
|
1853
|
+
# └──────────┘└────┘└─────────┘ └────────────┘ └──────────┘ └──────┘ └─────────┘
|
1854
|
+
q = QuantumRegister(2, "q")
|
1855
|
+
xxplusyy = QuantumCircuit(q)
|
1856
|
+
beta = Parameter("beta")
|
1857
|
+
theta = Parameter("theta")
|
1858
|
+
rules: list[tuple[Gate, list[Qubit], list[Clbit]]] = [
|
1859
|
+
(RZGate(beta), [q[0]], []),
|
1860
|
+
(RZGate(-pi / 2), [q[1]], []),
|
1861
|
+
(SXGate(), [q[1]], []),
|
1862
|
+
(RZGate(pi / 2), [q[1]], []),
|
1863
|
+
(SGate(), [q[0]], []),
|
1864
|
+
(CXGate(), [q[1], q[0]], []),
|
1865
|
+
(RYGate(-theta / 2), [q[1]], []),
|
1866
|
+
(RYGate(-theta / 2), [q[0]], []),
|
1867
|
+
(CXGate(), [q[1], q[0]], []),
|
1868
|
+
(SdgGate(), [q[0]], []),
|
1869
|
+
(RZGate(-pi / 2), [q[1]], []),
|
1870
|
+
(SXdgGate(), [q[1]], []),
|
1871
|
+
(RZGate(pi / 2), [q[1]], []),
|
1872
|
+
(RZGate(-beta), [q[0]], []),
|
1873
|
+
]
|
1874
|
+
for instr, qargs, cargs in rules:
|
1875
|
+
xxplusyy._append(instr, qargs, cargs)
|
1876
|
+
_sel.add_equivalence(XXPlusYYGate(theta, beta), xxplusyy)
|
1877
|
+
|
1878
|
+
# XXPlusYYGate
|
1879
|
+
# ┌───────────────┐
|
1880
|
+
# ┤0 ├
|
1881
|
+
# │ {XX+YY}(θ,β) │
|
1882
|
+
# ┤1 ├
|
1883
|
+
# └───────────────┘
|
1884
|
+
# ┌───────┐┌─────────────┐┌─────────────┐┌────────┐
|
1885
|
+
# ┤ Rz(β) ├┤0 ├┤0 ├┤ Rz(-β) ├
|
1886
|
+
# ≡ └───────┘│ Rxx(0.5*θ) ││ Ryy(0.5*θ) │└────────┘
|
1887
|
+
# ─────────┤1 ├┤1 ├──────────
|
1888
|
+
# └─────────────┘└─────────────┘
|
1889
|
+
q = QuantumRegister(2, "q")
|
1890
|
+
xxplusyy = QuantumCircuit(q)
|
1891
|
+
beta = Parameter("beta")
|
1892
|
+
theta = Parameter("theta")
|
1893
|
+
rules: list[tuple[Gate, list[Qubit], list[Clbit]]] = [
|
1894
|
+
(RZGate(beta), [q[0]], []),
|
1895
|
+
(RXXGate(0.5 * theta), [q[0], q[1]], []),
|
1896
|
+
(RYYGate(0.5 * theta), [q[0], q[1]], []),
|
1897
|
+
(RZGate(-beta), [q[0]], []),
|
1898
|
+
]
|
1899
|
+
for instr, qargs, cargs in rules:
|
1900
|
+
xxplusyy._append(instr, qargs, cargs)
|
1901
|
+
_sel.add_equivalence(XXPlusYYGate(theta, beta), xxplusyy)
|
1902
|
+
|
1903
|
+
# XXMinusYYGate
|
1904
|
+
# ┌───────────────┐
|
1905
|
+
# ┤0 ├
|
1906
|
+
# │ {XX-YY}(θ,β) │
|
1907
|
+
# ┤1 ├
|
1908
|
+
# └───────────────┘
|
1909
|
+
# ┌──────────┐ ┌────┐┌─────────┐ ┌─────────┐ ┌──────────┐ ┌──────┐┌─────────┐
|
1910
|
+
# ─┤ Rz(-π/2) ├─┤ √X ├┤ Rz(π/2) ├──■───┤ Ry(θ/2) ├────■──┤ Rz(-π/2) ├─┤ √Xdg ├┤ Rz(π/2) ├
|
1911
|
+
# ≡ ┌┴──────────┴┐├───┬┘└─────────┘┌─┴─┐┌┴─────────┴─┐┌─┴─┐└─┬─────┬──┘┌┴──────┤└─────────┘
|
1912
|
+
# ┤ Rz(-1.0*β) ├┤ S ├────────────┤ X ├┤ Ry(-0.5*θ) ├┤ X ├──┤ Sdg ├───┤ Rz(β) ├───────────
|
1913
|
+
# └────────────┘└───┘ └───┘└────────────┘└───┘ └─────┘ └───────┘
|
1914
|
+
q = QuantumRegister(2, "q")
|
1915
|
+
xxminusyy = QuantumCircuit(q)
|
1916
|
+
beta = Parameter("beta")
|
1917
|
+
theta = Parameter("theta")
|
1918
|
+
rules: list[tuple[Gate, list[Qubit], list[Clbit]]] = [
|
1919
|
+
(RZGate(-beta), [q[1]], []),
|
1920
|
+
(RZGate(-pi / 2), [q[0]], []),
|
1921
|
+
(SXGate(), [q[0]], []),
|
1922
|
+
(RZGate(pi / 2), [q[0]], []),
|
1923
|
+
(SGate(), [q[1]], []),
|
1924
|
+
(CXGate(), [q[0], q[1]], []),
|
1925
|
+
(RYGate(theta / 2), [q[0]], []),
|
1926
|
+
(RYGate(-theta / 2), [q[1]], []),
|
1927
|
+
(CXGate(), [q[0], q[1]], []),
|
1928
|
+
(SdgGate(), [q[1]], []),
|
1929
|
+
(RZGate(-pi / 2), [q[0]], []),
|
1930
|
+
(SXdgGate(), [q[0]], []),
|
1931
|
+
(RZGate(pi / 2), [q[0]], []),
|
1932
|
+
(RZGate(beta), [q[1]], []),
|
1933
|
+
]
|
1934
|
+
for instr, qargs, cargs in rules:
|
1935
|
+
xxminusyy._append(instr, qargs, cargs)
|
1936
|
+
_sel.add_equivalence(XXMinusYYGate(theta, beta), xxminusyy)
|