qiskit 1.1.2__cp38-abi3-macosx_10_9_universal2.whl → 1.2.0rc1__cp38-abi3-macosx_10_9_universal2.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 -1
- qiskit/__init__.py +27 -24
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/_numpy_compat.py +1 -1
- qiskit/assembler/assemble_circuits.py +107 -64
- qiskit/assembler/assemble_schedules.py +5 -12
- qiskit/assembler/disassemble.py +10 -1
- qiskit/circuit/__init__.py +1 -1
- qiskit/circuit/_classical_resource_map.py +5 -5
- qiskit/circuit/_utils.py +0 -13
- qiskit/circuit/add_control.py +1 -1
- qiskit/circuit/annotated_operation.py +23 -1
- qiskit/circuit/classical/expr/expr.py +4 -4
- qiskit/circuit/classical/expr/visitors.py +1 -1
- qiskit/circuit/classical/types/__init__.py +1 -1
- qiskit/circuit/classical/types/types.py +2 -2
- qiskit/circuit/classicalfunction/boolean_expression.py +1 -1
- qiskit/circuit/classicalfunction/classical_function_visitor.py +5 -5
- qiskit/circuit/classicalfunction/utils.py +1 -1
- qiskit/circuit/classicalregister.py +1 -1
- qiskit/circuit/commutation_checker.py +83 -35
- qiskit/circuit/controlflow/_builder_utils.py +1 -1
- qiskit/circuit/controlflow/builder.py +10 -6
- qiskit/circuit/controlflow/if_else.py +2 -2
- qiskit/circuit/controlflow/switch_case.py +1 -1
- qiskit/circuit/delay.py +1 -1
- qiskit/circuit/duration.py +2 -2
- qiskit/circuit/equivalence.py +5 -7
- qiskit/circuit/gate.py +11 -8
- qiskit/circuit/instruction.py +31 -13
- qiskit/circuit/instructionset.py +2 -5
- qiskit/circuit/library/__init__.py +2 -1
- qiskit/circuit/library/arithmetic/linear_amplitude_function.py +1 -1
- qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +1 -1
- qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +3 -3
- qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +1 -1
- qiskit/circuit/library/basis_change/__init__.py +1 -1
- qiskit/circuit/library/basis_change/qft.py +40 -6
- qiskit/circuit/library/blueprintcircuit.py +3 -5
- qiskit/circuit/library/data_preparation/__init__.py +9 -2
- qiskit/circuit/library/data_preparation/initializer.py +8 -0
- qiskit/circuit/library/data_preparation/state_preparation.py +98 -178
- qiskit/circuit/library/generalized_gates/isometry.py +8 -8
- qiskit/circuit/library/generalized_gates/linear_function.py +3 -2
- qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +4 -4
- qiskit/circuit/library/generalized_gates/permutation.py +8 -9
- qiskit/circuit/library/generalized_gates/uc.py +3 -3
- qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +2 -2
- qiskit/circuit/library/generalized_gates/unitary.py +13 -11
- qiskit/circuit/library/graph_state.py +1 -1
- qiskit/circuit/library/hamiltonian_gate.py +1 -2
- qiskit/circuit/library/hidden_linear_function.py +1 -1
- qiskit/circuit/library/n_local/evolved_operator_ansatz.py +3 -2
- qiskit/circuit/library/n_local/n_local.py +4 -5
- qiskit/circuit/library/n_local/pauli_two_design.py +1 -1
- qiskit/circuit/library/n_local/qaoa_ansatz.py +6 -8
- qiskit/circuit/library/n_local/two_local.py +1 -1
- qiskit/circuit/library/overlap.py +11 -5
- qiskit/circuit/library/pauli_evolution.py +7 -3
- qiskit/circuit/library/standard_gates/dcx.py +3 -0
- qiskit/circuit/library/standard_gates/ecr.py +3 -0
- qiskit/circuit/library/standard_gates/global_phase.py +3 -0
- qiskit/circuit/library/standard_gates/h.py +13 -5
- qiskit/circuit/library/standard_gates/i.py +3 -0
- qiskit/circuit/library/standard_gates/iswap.py +3 -0
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +19 -10
- qiskit/circuit/library/standard_gates/p.py +14 -9
- qiskit/circuit/library/standard_gates/r.py +3 -0
- qiskit/circuit/library/standard_gates/rx.py +21 -6
- qiskit/circuit/library/standard_gates/rxx.py +40 -1
- qiskit/circuit/library/standard_gates/ry.py +21 -6
- qiskit/circuit/library/standard_gates/ryy.py +40 -1
- qiskit/circuit/library/standard_gates/rz.py +22 -6
- qiskit/circuit/library/standard_gates/rzx.py +40 -1
- qiskit/circuit/library/standard_gates/rzz.py +41 -2
- qiskit/circuit/library/standard_gates/s.py +77 -0
- qiskit/circuit/library/standard_gates/swap.py +12 -5
- qiskit/circuit/library/standard_gates/sx.py +14 -5
- qiskit/circuit/library/standard_gates/t.py +5 -0
- qiskit/circuit/library/standard_gates/u.py +22 -7
- qiskit/circuit/library/standard_gates/u1.py +8 -3
- qiskit/circuit/library/standard_gates/u2.py +3 -0
- qiskit/circuit/library/standard_gates/u3.py +22 -7
- qiskit/circuit/library/standard_gates/x.py +156 -92
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +40 -1
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +52 -11
- qiskit/circuit/library/standard_gates/y.py +6 -1
- qiskit/circuit/library/standard_gates/z.py +8 -1
- qiskit/circuit/operation.py +1 -1
- qiskit/circuit/parameter.py +9 -10
- qiskit/circuit/parameterexpression.py +16 -13
- qiskit/circuit/parametertable.py +1 -190
- qiskit/circuit/parametervector.py +1 -1
- qiskit/circuit/quantumcircuit.py +392 -384
- qiskit/circuit/quantumcircuitdata.py +3 -5
- qiskit/circuit/quantumregister.py +1 -1
- qiskit/circuit/random/__init__.py +1 -1
- qiskit/circuit/random/utils.py +175 -26
- qiskit/circuit/register.py +5 -7
- qiskit/circuit/singleton.py +3 -3
- qiskit/circuit/tools/pi_check.py +4 -4
- qiskit/compiler/assembler.py +95 -24
- qiskit/compiler/scheduler.py +2 -2
- qiskit/compiler/transpiler.py +41 -127
- qiskit/converters/circuit_to_dag.py +4 -6
- qiskit/converters/circuit_to_gate.py +4 -8
- qiskit/converters/circuit_to_instruction.py +5 -17
- qiskit/converters/dag_to_circuit.py +2 -6
- qiskit/dagcircuit/collect_blocks.py +2 -2
- qiskit/dagcircuit/dagcircuit.py +190 -187
- qiskit/dagcircuit/dagdependency.py +4 -4
- qiskit/dagcircuit/dagdependency_v2.py +4 -4
- qiskit/dagcircuit/dagdepnode.py +1 -1
- qiskit/dagcircuit/dagnode.py +66 -157
- qiskit/passmanager/flow_controllers.py +1 -1
- qiskit/passmanager/passmanager.py +3 -3
- qiskit/primitives/__init__.py +1 -5
- qiskit/primitives/backend_estimator.py +25 -15
- qiskit/primitives/backend_estimator_v2.py +31 -7
- qiskit/primitives/backend_sampler.py +21 -12
- qiskit/primitives/backend_sampler_v2.py +12 -3
- qiskit/primitives/base/base_estimator.py +31 -4
- qiskit/primitives/base/base_primitive.py +2 -2
- qiskit/primitives/base/base_result.py +2 -2
- qiskit/primitives/base/base_sampler.py +26 -2
- qiskit/primitives/base/estimator_result.py +2 -2
- qiskit/primitives/base/sampler_result.py +2 -2
- qiskit/primitives/containers/__init__.py +0 -1
- qiskit/primitives/containers/bindings_array.py +2 -2
- qiskit/primitives/containers/bit_array.py +108 -10
- qiskit/primitives/containers/shape.py +3 -3
- qiskit/primitives/estimator.py +9 -2
- qiskit/primitives/primitive_job.py +1 -1
- qiskit/primitives/sampler.py +10 -3
- qiskit/primitives/statevector_estimator.py +5 -3
- qiskit/primitives/statevector_sampler.py +11 -5
- qiskit/primitives/utils.py +16 -0
- qiskit/providers/backend.py +15 -6
- qiskit/providers/backend_compat.py +7 -4
- qiskit/providers/basic_provider/basic_provider_tools.py +1 -1
- qiskit/providers/basic_provider/basic_simulator.py +32 -24
- qiskit/providers/fake_provider/fake_backend.py +10 -3
- qiskit/providers/fake_provider/fake_openpulse_2q.py +154 -146
- qiskit/providers/fake_provider/fake_openpulse_3q.py +226 -217
- qiskit/providers/fake_provider/fake_qasm_backend.py +5 -1
- qiskit/providers/fake_provider/generic_backend_v2.py +80 -50
- qiskit/providers/models/__init__.py +11 -0
- qiskit/providers/models/backendconfiguration.py +50 -4
- qiskit/providers/models/backendproperties.py +13 -2
- qiskit/providers/models/pulsedefaults.py +10 -11
- qiskit/providers/options.py +13 -13
- qiskit/providers/providerutils.py +3 -1
- qiskit/pulse/configuration.py +8 -12
- qiskit/pulse/instruction_schedule_map.py +3 -5
- qiskit/pulse/instructions/acquire.py +7 -8
- qiskit/pulse/instructions/instruction.py +2 -3
- qiskit/pulse/library/samplers/decorators.py +5 -9
- qiskit/pulse/library/symbolic_pulses.py +4 -7
- qiskit/pulse/library/waveform.py +2 -5
- qiskit/pulse/macros.py +11 -6
- qiskit/pulse/parser.py +8 -10
- qiskit/pulse/schedule.py +9 -17
- qiskit/pulse/transforms/alignments.py +1 -3
- qiskit/pulse/utils.py +1 -2
- qiskit/qasm/libs/stdgates.inc +35 -28
- qiskit/qasm2/__init__.py +7 -7
- qiskit/qasm2/export.py +5 -9
- qiskit/qasm2/parse.py +1 -1
- qiskit/qasm3/ast.py +9 -25
- qiskit/qasm3/exporter.py +578 -481
- qiskit/qasm3/printer.py +7 -16
- qiskit/qobj/common.py +10 -0
- qiskit/qobj/converters/lo_config.py +9 -0
- qiskit/qobj/converters/pulse_instruction.py +13 -6
- qiskit/qobj/pulse_qobj.py +69 -15
- qiskit/qobj/qasm_qobj.py +72 -20
- qiskit/qobj/utils.py +9 -0
- qiskit/qpy/binary_io/circuits.py +8 -5
- qiskit/qpy/binary_io/schedules.py +1 -1
- qiskit/qpy/binary_io/value.py +3 -3
- qiskit/qpy/interface.py +3 -2
- qiskit/qpy/type_keys.py +2 -2
- qiskit/quantum_info/operators/channel/quantum_channel.py +3 -6
- qiskit/quantum_info/operators/channel/superop.py +2 -2
- qiskit/quantum_info/operators/channel/transformations.py +1 -1
- qiskit/quantum_info/operators/dihedral/dihedral.py +3 -4
- qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +1 -3
- qiskit/quantum_info/operators/dihedral/random.py +6 -3
- qiskit/quantum_info/operators/measures.py +2 -2
- qiskit/quantum_info/operators/op_shape.py +12 -20
- qiskit/quantum_info/operators/operator.py +14 -21
- qiskit/quantum_info/operators/predicates.py +1 -0
- qiskit/quantum_info/operators/symplectic/base_pauli.py +7 -11
- qiskit/quantum_info/operators/symplectic/clifford.py +1 -1
- qiskit/quantum_info/operators/symplectic/pauli.py +3 -3
- qiskit/quantum_info/operators/symplectic/pauli_list.py +9 -10
- qiskit/quantum_info/operators/symplectic/random.py +1 -1
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +14 -16
- qiskit/quantum_info/quaternion.py +1 -1
- qiskit/quantum_info/states/densitymatrix.py +5 -8
- qiskit/quantum_info/states/stabilizerstate.py +128 -37
- qiskit/quantum_info/states/statevector.py +4 -8
- qiskit/result/counts.py +2 -2
- qiskit/result/mitigation/correlated_readout_mitigator.py +2 -2
- qiskit/result/mitigation/local_readout_mitigator.py +2 -2
- qiskit/result/mitigation/utils.py +1 -3
- qiskit/result/models.py +17 -16
- qiskit/result/result.py +15 -20
- qiskit/scheduler/lowering.py +2 -2
- qiskit/synthesis/__init__.py +2 -1
- qiskit/synthesis/clifford/__init__.py +1 -1
- qiskit/synthesis/clifford/clifford_decompose_ag.py +2 -2
- qiskit/synthesis/clifford/clifford_decompose_bm.py +10 -240
- qiskit/synthesis/clifford/clifford_decompose_greedy.py +9 -303
- qiskit/synthesis/clifford/clifford_decompose_layers.py +25 -23
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +1 -1
- qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +1 -1
- qiskit/synthesis/discrete_basis/generate_basis_approximations.py +1 -1
- qiskit/synthesis/discrete_basis/solovay_kitaev.py +2 -2
- qiskit/synthesis/evolution/evolution_synthesis.py +4 -2
- qiskit/synthesis/evolution/lie_trotter.py +46 -19
- qiskit/synthesis/evolution/product_formula.py +111 -55
- qiskit/synthesis/evolution/qdrift.py +40 -10
- qiskit/synthesis/evolution/suzuki_trotter.py +43 -33
- qiskit/synthesis/linear/__init__.py +1 -0
- qiskit/synthesis/linear/cnot_synth.py +22 -96
- qiskit/synthesis/linear/linear_depth_lnn.py +8 -8
- qiskit/synthesis/linear/linear_matrix_utils.py +13 -161
- qiskit/synthesis/linear_phase/cnot_phase_synth.py +1 -1
- qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +3 -3
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +1 -1
- qiskit/synthesis/one_qubit/one_qubit_decompose.py +29 -29
- qiskit/synthesis/permutation/permutation_full.py +5 -29
- qiskit/synthesis/permutation/permutation_lnn.py +2 -24
- qiskit/synthesis/permutation/permutation_utils.py +2 -59
- qiskit/synthesis/qft/__init__.py +1 -0
- qiskit/synthesis/qft/qft_decompose_full.py +79 -0
- qiskit/synthesis/qft/qft_decompose_lnn.py +17 -9
- qiskit/synthesis/stabilizer/stabilizer_circuit.py +6 -6
- qiskit/synthesis/stabilizer/stabilizer_decompose.py +2 -2
- qiskit/synthesis/two_qubit/local_invariance.py +8 -38
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +48 -129
- qiskit/synthesis/unitary/aqc/cnot_structures.py +1 -1
- qiskit/synthesis/unitary/qsd.py +5 -3
- qiskit/transpiler/__init__.py +1 -0
- qiskit/transpiler/basepasses.py +1 -1
- qiskit/transpiler/coupling.py +3 -3
- qiskit/transpiler/instruction_durations.py +1 -2
- qiskit/transpiler/layout.py +3 -3
- qiskit/transpiler/passes/__init__.py +2 -0
- qiskit/transpiler/passes/basis/basis_translator.py +82 -63
- qiskit/transpiler/passes/basis/translate_parameterized.py +3 -5
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -1
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +10 -10
- qiskit/transpiler/passes/calibration/rx_builder.py +3 -3
- qiskit/transpiler/passes/calibration/rzx_builder.py +3 -3
- qiskit/transpiler/passes/layout/apply_layout.py +13 -3
- qiskit/transpiler/passes/layout/sabre_layout.py +10 -8
- qiskit/transpiler/passes/layout/sabre_pre_layout.py +4 -1
- qiskit/transpiler/passes/layout/set_layout.py +2 -2
- qiskit/transpiler/passes/layout/vf2_layout.py +1 -1
- qiskit/transpiler/passes/layout/vf2_utils.py +3 -3
- qiskit/transpiler/passes/optimization/__init__.py +1 -0
- qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +2 -2
- qiskit/transpiler/passes/optimization/commutation_analysis.py +7 -10
- qiskit/transpiler/passes/optimization/commutative_cancellation.py +35 -19
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +11 -8
- qiskit/transpiler/passes/optimization/inverse_cancellation.py +6 -6
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +64 -41
- qiskit/transpiler/passes/optimization/optimize_1q_gates.py +1 -1
- qiskit/transpiler/passes/optimization/split_2q_unitaries.py +83 -0
- qiskit/transpiler/passes/optimization/template_matching/backward_match.py +1 -1
- qiskit/transpiler/passes/optimization/template_matching/forward_match.py +2 -2
- qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +1 -1
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +3 -2
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +1 -1
- qiskit/transpiler/passes/routing/layout_transformation.py +2 -1
- qiskit/transpiler/passes/routing/sabre_swap.py +35 -26
- qiskit/transpiler/passes/routing/star_prerouting.py +80 -105
- qiskit/transpiler/passes/routing/stochastic_swap.py +1 -3
- qiskit/transpiler/passes/scheduling/alap.py +1 -2
- qiskit/transpiler/passes/scheduling/alignments/__init__.py +2 -2
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -1
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +1 -1
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +1 -1
- qiskit/transpiler/passes/scheduling/asap.py +1 -2
- qiskit/transpiler/passes/scheduling/base_scheduler.py +5 -5
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +3 -3
- qiskit/transpiler/passes/scheduling/padding/base_padding.py +1 -1
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +11 -11
- qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +7 -6
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +4 -3
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +211 -36
- qiskit/transpiler/passes/synthesis/plugin.py +2 -2
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +80 -40
- qiskit/transpiler/passes/utils/__init__.py +0 -1
- qiskit/transpiler/passes/utils/check_gate_direction.py +4 -4
- qiskit/transpiler/passes/utils/check_map.py +3 -6
- qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +3 -4
- qiskit/transpiler/passes/utils/error.py +2 -2
- qiskit/transpiler/passes/utils/fixed_point.py +3 -3
- qiskit/transpiler/passes/utils/gate_direction.py +1 -1
- qiskit/transpiler/passes/utils/gates_basis.py +1 -2
- qiskit/transpiler/passmanager.py +7 -6
- qiskit/transpiler/preset_passmanagers/__init__.py +4 -228
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +117 -18
- qiskit/transpiler/preset_passmanagers/common.py +3 -6
- qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +518 -0
- qiskit/transpiler/preset_passmanagers/level0.py +1 -1
- qiskit/transpiler/target.py +27 -8
- qiskit/user_config.py +29 -6
- qiskit/utils/classtools.py +3 -3
- qiskit/utils/deprecation.py +3 -2
- qiskit/utils/lazy_tester.py +2 -2
- qiskit/utils/optionals.py +8 -8
- qiskit/visualization/bloch.py +19 -67
- qiskit/visualization/circuit/_utils.py +34 -10
- qiskit/visualization/circuit/circuit_visualization.py +23 -16
- qiskit/visualization/circuit/latex.py +29 -27
- qiskit/visualization/circuit/matplotlib.py +4 -2
- qiskit/visualization/circuit/qcstyle.py +2 -2
- qiskit/visualization/circuit/text.py +9 -15
- qiskit/visualization/dag_visualization.py +5 -12
- qiskit/visualization/pulse_v2/core.py +1 -1
- qiskit/visualization/pulse_v2/events.py +1 -1
- qiskit/visualization/pulse_v2/generators/frame.py +3 -4
- qiskit/visualization/pulse_v2/generators/waveform.py +5 -9
- qiskit/visualization/pulse_v2/layouts.py +1 -5
- qiskit/visualization/pulse_v2/plotters/matplotlib.py +1 -2
- qiskit/visualization/state_visualization.py +5 -6
- qiskit/visualization/timeline/plotters/matplotlib.py +1 -2
- qiskit/visualization/transition_visualization.py +7 -2
- {qiskit-1.1.2.dist-info → qiskit-1.2.0rc1.dist-info}/METADATA +26 -26
- {qiskit-1.1.2.dist-info → qiskit-1.2.0rc1.dist-info}/RECORD +340 -338
- {qiskit-1.1.2.dist-info → qiskit-1.2.0rc1.dist-info}/WHEEL +1 -1
- {qiskit-1.1.2.dist-info → qiskit-1.2.0rc1.dist-info}/entry_points.txt +3 -0
- qiskit/transpiler/passes/utils/block_to_matrix.py +0 -47
- {qiskit-1.1.2.dist-info → qiskit-1.2.0rc1.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.1.2.dist-info → qiskit-1.2.0rc1.dist-info}/top_level.txt +0 -0
@@ -19,6 +19,7 @@ from qiskit.circuit.controlledgate import ControlledGate
|
|
19
19
|
from qiskit.circuit.singleton import SingletonGate, SingletonControlledGate, stdlib_singleton_key
|
20
20
|
from qiskit.circuit.quantumregister import QuantumRegister
|
21
21
|
from qiskit.circuit._utils import _ctrl_state_to_int, with_gate_array, with_controlled_gate_array
|
22
|
+
from qiskit._accelerate.circuit import StandardGate
|
22
23
|
|
23
24
|
_X_ARRAY = [[0, 1], [1, 0]]
|
24
25
|
_SX_ARRAY = [[0.5 + 0.5j, 0.5 - 0.5j], [0.5 - 0.5j, 0.5 + 0.5j]]
|
@@ -71,6 +72,8 @@ class XGate(SingletonGate):
|
|
71
72
|
|1\rangle \rightarrow |0\rangle
|
72
73
|
"""
|
73
74
|
|
75
|
+
_standard_gate = StandardGate.XGate
|
76
|
+
|
74
77
|
def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
|
75
78
|
"""Create new X gate."""
|
76
79
|
super().__init__("x", 1, [], label=label, duration=duration, unit=unit)
|
@@ -109,7 +112,7 @@ class XGate(SingletonGate):
|
|
109
112
|
label: An optional label for the gate [Default: ``None``]
|
110
113
|
ctrl_state: control state expressed as integer,
|
111
114
|
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
112
|
-
annotated: indicates whether the controlled gate
|
115
|
+
annotated: indicates whether the controlled gate should be implemented
|
113
116
|
as an annotated gate.
|
114
117
|
|
115
118
|
Returns:
|
@@ -213,6 +216,8 @@ class CXGate(SingletonControlledGate):
|
|
213
216
|
`|a, b\rangle \rightarrow |a, a \oplus b\rangle`
|
214
217
|
"""
|
215
218
|
|
219
|
+
_standard_gate = StandardGate.CXGate
|
220
|
+
|
216
221
|
def __init__(
|
217
222
|
self,
|
218
223
|
label: Optional[str] = None,
|
@@ -252,7 +257,7 @@ class CXGate(SingletonControlledGate):
|
|
252
257
|
label: An optional label for the gate [Default: ``None``]
|
253
258
|
ctrl_state: control state expressed as integer,
|
254
259
|
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
255
|
-
annotated: indicates whether the controlled gate
|
260
|
+
annotated: indicates whether the controlled gate should be implemented
|
256
261
|
as an annotated gate.
|
257
262
|
|
258
263
|
Returns:
|
@@ -363,6 +368,8 @@ class CCXGate(SingletonControlledGate):
|
|
363
368
|
|
364
369
|
"""
|
365
370
|
|
371
|
+
_standard_gate = StandardGate.CCXGate
|
372
|
+
|
366
373
|
def __init__(
|
367
374
|
self,
|
368
375
|
label: Optional[str] = None,
|
@@ -446,7 +453,7 @@ class CCXGate(SingletonControlledGate):
|
|
446
453
|
label: An optional label for the gate [Default: ``None``]
|
447
454
|
ctrl_state: control state expressed as integer,
|
448
455
|
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
449
|
-
annotated: indicates whether the controlled gate
|
456
|
+
annotated: indicates whether the controlled gate should be implemented
|
450
457
|
as an annotated gate.
|
451
458
|
|
452
459
|
Returns:
|
@@ -516,6 +523,8 @@ class RCCXGate(SingletonGate):
|
|
516
523
|
with the :meth:`~qiskit.circuit.QuantumCircuit.rccx` method.
|
517
524
|
"""
|
518
525
|
|
526
|
+
_standard_gate = StandardGate.RCCXGate
|
527
|
+
|
519
528
|
def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
|
520
529
|
"""Create a new simplified CCX gate."""
|
521
530
|
super().__init__("rccx", 3, [], label=label, duration=duration, unit=unit)
|
@@ -573,6 +582,8 @@ class C3SXGate(SingletonControlledGate):
|
|
573
582
|
[1] Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
|
574
583
|
"""
|
575
584
|
|
585
|
+
_standard_gate = StandardGate.C3SXGate
|
586
|
+
|
576
587
|
def __init__(
|
577
588
|
self,
|
578
589
|
label: Optional[str] = None,
|
@@ -677,6 +688,8 @@ class C3XGate(SingletonControlledGate):
|
|
677
688
|
This implementation uses :math:`\sqrt{T}` and 14 CNOT gates.
|
678
689
|
"""
|
679
690
|
|
691
|
+
_standard_gate = StandardGate.C3XGate
|
692
|
+
|
680
693
|
def __init__(
|
681
694
|
self,
|
682
695
|
label: Optional[str] = None,
|
@@ -788,7 +801,7 @@ class C3XGate(SingletonControlledGate):
|
|
788
801
|
label: An optional label for the gate [Default: ``None``]
|
789
802
|
ctrl_state: control state expressed as integer,
|
790
803
|
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
791
|
-
annotated: indicates whether the controlled gate
|
804
|
+
annotated: indicates whether the controlled gate should be implemented
|
792
805
|
as an annotated gate.
|
793
806
|
|
794
807
|
Returns:
|
@@ -864,6 +877,8 @@ class RC3XGate(SingletonGate):
|
|
864
877
|
with the :meth:`~qiskit.circuit.QuantumCircuit.rcccx` method.
|
865
878
|
"""
|
866
879
|
|
880
|
+
_standard_gate = StandardGate.RC3XGate
|
881
|
+
|
867
882
|
def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
|
868
883
|
"""Create a new RC3X gate."""
|
869
884
|
super().__init__("rcccx", 4, [], label=label, duration=duration, unit=unit)
|
@@ -937,8 +952,8 @@ class C4XGate(SingletonControlledGate):
|
|
937
952
|
of the relative phase version of c3x, the rc3x [2].
|
938
953
|
|
939
954
|
References:
|
940
|
-
|
941
|
-
|
955
|
+
1. Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
|
956
|
+
2. Maslov, 2015. https://arxiv.org/abs/1508.03273
|
942
957
|
"""
|
943
958
|
|
944
959
|
def __init__(
|
@@ -967,7 +982,7 @@ class C4XGate(SingletonControlledGate):
|
|
967
982
|
|
968
983
|
_singleton_lookup_key = stdlib_singleton_key(num_ctrl_qubits=4)
|
969
984
|
|
970
|
-
# seems like open controls not
|
985
|
+
# seems like open controls not happening?
|
971
986
|
def _define(self):
|
972
987
|
"""
|
973
988
|
gate c3sqrtx a,b,c,d
|
@@ -1032,7 +1047,7 @@ class C4XGate(SingletonControlledGate):
|
|
1032
1047
|
label: An optional label for the gate [Default: ``None``]
|
1033
1048
|
ctrl_state: control state expressed as integer,
|
1034
1049
|
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
1035
|
-
annotated: indicates whether the controlled gate
|
1050
|
+
annotated: indicates whether the controlled gate should be implemented
|
1036
1051
|
as an annotated gate.
|
1037
1052
|
|
1038
1053
|
Returns:
|
@@ -1207,7 +1222,7 @@ class MCXGate(ControlledGate):
|
|
1207
1222
|
label: An optional label for the gate [Default: ``None``]
|
1208
1223
|
ctrl_state: control state expressed as integer,
|
1209
1224
|
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
1210
|
-
annotated: indicates whether the controlled gate
|
1225
|
+
annotated: indicates whether the controlled gate should be implemented
|
1211
1226
|
as an annotated gate.
|
1212
1227
|
|
1213
1228
|
Returns:
|
@@ -1305,9 +1320,14 @@ class MCXGrayCode(MCXGate):
|
|
1305
1320
|
class MCXRecursive(MCXGate):
|
1306
1321
|
"""Implement the multi-controlled X gate using recursion.
|
1307
1322
|
|
1308
|
-
Using a single ancilla qubit, the multi-controlled X gate is
|
1309
|
-
four sub-registers
|
1310
|
-
|
1323
|
+
Using a single clean ancilla qubit, the multi-controlled X gate is split into
|
1324
|
+
four sub-registers, each one of them uses the V-chain method.
|
1325
|
+
|
1326
|
+
The method is based on Lemma 9 of [2], first shown in Lemma 7.3 of [1].
|
1327
|
+
|
1328
|
+
References:
|
1329
|
+
1. Barenco et al., 1995. https://arxiv.org/pdf/quant-ph/9503016.pdf
|
1330
|
+
2. Iten et al., 2015. https://arxiv.org/abs/1501.06911
|
1311
1331
|
"""
|
1312
1332
|
|
1313
1333
|
def __init__(
|
@@ -1363,32 +1383,35 @@ class MCXRecursive(MCXGate):
|
|
1363
1383
|
qc._append(C4XGate(), q[:], [])
|
1364
1384
|
self.definition = qc
|
1365
1385
|
else:
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1386
|
+
num_ctrl_qubits = len(q) - 1
|
1387
|
+
q_ancilla = q[-1]
|
1388
|
+
q_target = q[-2]
|
1389
|
+
middle = ceil(num_ctrl_qubits / 2)
|
1390
|
+
first_half = [*q[:middle]]
|
1391
|
+
second_half = [*q[middle : num_ctrl_qubits - 1], q_ancilla]
|
1392
|
+
|
1393
|
+
qc._append(
|
1394
|
+
MCXVChain(num_ctrl_qubits=len(first_half), dirty_ancillas=True),
|
1395
|
+
qargs=[*first_half, q_ancilla, *q[middle : middle + len(first_half) - 2]],
|
1396
|
+
cargs=[],
|
1397
|
+
)
|
1398
|
+
qc._append(
|
1399
|
+
MCXVChain(num_ctrl_qubits=len(second_half), dirty_ancillas=True),
|
1400
|
+
qargs=[*second_half, q_target, *q[: len(second_half) - 2]],
|
1401
|
+
cargs=[],
|
1402
|
+
)
|
1403
|
+
qc._append(
|
1404
|
+
MCXVChain(num_ctrl_qubits=len(first_half), dirty_ancillas=True),
|
1405
|
+
qargs=[*first_half, q_ancilla, *q[middle : middle + len(first_half) - 2]],
|
1406
|
+
cargs=[],
|
1407
|
+
)
|
1408
|
+
qc._append(
|
1409
|
+
MCXVChain(num_ctrl_qubits=len(second_half), dirty_ancillas=True),
|
1410
|
+
qargs=[*second_half, q_target, *q[: len(second_half) - 2]],
|
1411
|
+
cargs=[],
|
1412
|
+
)
|
1390
1413
|
|
1391
|
-
|
1414
|
+
self.definition = qc
|
1392
1415
|
|
1393
1416
|
|
1394
1417
|
class MCXVChain(MCXGate):
|
@@ -1404,6 +1427,8 @@ class MCXVChain(MCXGate):
|
|
1404
1427
|
duration=None,
|
1405
1428
|
unit="dt",
|
1406
1429
|
_base_label=None,
|
1430
|
+
relative_phase: bool = False, # pylint: disable=unused-argument
|
1431
|
+
action_only: bool = False, # pylint: disable=unused-argument
|
1407
1432
|
):
|
1408
1433
|
"""Create a new MCX instance.
|
1409
1434
|
|
@@ -1429,7 +1454,24 @@ class MCXVChain(MCXGate):
|
|
1429
1454
|
duration=None,
|
1430
1455
|
unit="dt",
|
1431
1456
|
_base_label=None,
|
1457
|
+
relative_phase: bool = False,
|
1458
|
+
action_only: bool = False,
|
1432
1459
|
):
|
1460
|
+
"""
|
1461
|
+
Args:
|
1462
|
+
dirty_ancillas: when set to ``True``, the method applies an optimized multicontrolled-X gate
|
1463
|
+
up to a relative phase using dirty ancillary qubits with the properties of lemmas 7 and 8
|
1464
|
+
from arXiv:1501.06911, with at most 8*k - 6 CNOT gates.
|
1465
|
+
For k within the range {1, ..., ceil(n/2)}. And for n representing the total number of
|
1466
|
+
qubits.
|
1467
|
+
relative_phase: when set to ``True``, the method applies the optimized multicontrolled-X gate
|
1468
|
+
up to a relative phase, in a way that, by lemma 7 of arXiv:1501.06911, the relative
|
1469
|
+
phases of the ``action part`` cancel out with the phases of the ``reset part``.
|
1470
|
+
|
1471
|
+
action_only: when set to ``True``, the method applies only the action part of lemma 8
|
1472
|
+
from arXiv:1501.06911.
|
1473
|
+
|
1474
|
+
"""
|
1433
1475
|
super().__init__(
|
1434
1476
|
num_ctrl_qubits,
|
1435
1477
|
label=label,
|
@@ -1440,6 +1482,9 @@ class MCXVChain(MCXGate):
|
|
1440
1482
|
unit=unit,
|
1441
1483
|
)
|
1442
1484
|
self._dirty_ancillas = dirty_ancillas
|
1485
|
+
self._relative_phase = relative_phase
|
1486
|
+
self._action_only = action_only
|
1487
|
+
super().__init__(num_ctrl_qubits, label=label, ctrl_state=ctrl_state, _name="mcx_vchain")
|
1443
1488
|
|
1444
1489
|
def inverse(self, annotated: bool = False):
|
1445
1490
|
"""Invert this gate. The MCX is its own inverse.
|
@@ -1457,6 +1502,8 @@ class MCXVChain(MCXGate):
|
|
1457
1502
|
num_ctrl_qubits=self.num_ctrl_qubits,
|
1458
1503
|
dirty_ancillas=self._dirty_ancillas,
|
1459
1504
|
ctrl_state=self.ctrl_state,
|
1505
|
+
relative_phase=self._relative_phase,
|
1506
|
+
action_only=self._action_only,
|
1460
1507
|
)
|
1461
1508
|
|
1462
1509
|
@staticmethod
|
@@ -1468,8 +1515,6 @@ class MCXVChain(MCXGate):
|
|
1468
1515
|
"""Define the MCX gate using a V-chain of CX gates."""
|
1469
1516
|
# pylint: disable=cyclic-import
|
1470
1517
|
from qiskit.circuit.quantumcircuit import QuantumCircuit
|
1471
|
-
from .u1 import U1Gate
|
1472
|
-
from .u2 import U2Gate
|
1473
1518
|
|
1474
1519
|
q = QuantumRegister(self.num_qubits, name="q")
|
1475
1520
|
qc = QuantumCircuit(q, name=self.name)
|
@@ -1477,64 +1522,83 @@ class MCXVChain(MCXGate):
|
|
1477
1522
|
q_target = q[self.num_ctrl_qubits]
|
1478
1523
|
q_ancillas = q[self.num_ctrl_qubits + 1 :]
|
1479
1524
|
|
1480
|
-
definition = []
|
1481
|
-
|
1482
1525
|
if self._dirty_ancillas:
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
(
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1526
|
+
if self.num_ctrl_qubits < 3:
|
1527
|
+
qc.mcx(q_controls, q_target)
|
1528
|
+
elif not self._relative_phase and self.num_ctrl_qubits == 3:
|
1529
|
+
qc._append(C3XGate(), [*q_controls, q_target], [])
|
1530
|
+
else:
|
1531
|
+
num_ancillas = self.num_ctrl_qubits - 2
|
1532
|
+
targets = [q_target] + q_ancillas[:num_ancillas][::-1]
|
1533
|
+
|
1534
|
+
for j in range(2):
|
1535
|
+
for i in range(self.num_ctrl_qubits): # action part
|
1536
|
+
if i < self.num_ctrl_qubits - 2:
|
1537
|
+
if targets[i] != q_target or self._relative_phase:
|
1538
|
+
# gate cancelling
|
1539
|
+
|
1540
|
+
# cancel rightmost gates of action part
|
1541
|
+
# with leftmost gates of reset part
|
1542
|
+
if self._relative_phase and targets[i] == q_target and j == 1:
|
1543
|
+
qc.cx(q_ancillas[num_ancillas - i - 1], targets[i])
|
1544
|
+
qc.t(targets[i])
|
1545
|
+
qc.cx(q_controls[self.num_ctrl_qubits - i - 1], targets[i])
|
1546
|
+
qc.tdg(targets[i])
|
1547
|
+
qc.h(targets[i])
|
1548
|
+
else:
|
1549
|
+
qc.h(targets[i])
|
1550
|
+
qc.t(targets[i])
|
1551
|
+
qc.cx(q_controls[self.num_ctrl_qubits - i - 1], targets[i])
|
1552
|
+
qc.tdg(targets[i])
|
1553
|
+
qc.cx(q_ancillas[num_ancillas - i - 1], targets[i])
|
1554
|
+
else:
|
1555
|
+
controls = [
|
1556
|
+
q_controls[self.num_ctrl_qubits - i - 1],
|
1557
|
+
q_ancillas[num_ancillas - i - 1],
|
1558
|
+
]
|
1559
|
+
|
1560
|
+
qc.ccx(controls[0], controls[1], targets[i])
|
1561
|
+
else:
|
1562
|
+
# implements an optimized toffoli operation
|
1563
|
+
# up to a diagonal gate, akin to lemma 6 of arXiv:1501.06911
|
1564
|
+
qc.h(targets[i])
|
1565
|
+
qc.t(targets[i])
|
1566
|
+
qc.cx(q_controls[self.num_ctrl_qubits - i - 2], targets[i])
|
1567
|
+
qc.tdg(targets[i])
|
1568
|
+
qc.cx(q_controls[self.num_ctrl_qubits - i - 1], targets[i])
|
1569
|
+
qc.t(targets[i])
|
1570
|
+
qc.cx(q_controls[self.num_ctrl_qubits - i - 2], targets[i])
|
1571
|
+
qc.tdg(targets[i])
|
1572
|
+
qc.h(targets[i])
|
1573
|
+
|
1574
|
+
break
|
1575
|
+
|
1576
|
+
for i in range(num_ancillas - 1): # reset part
|
1577
|
+
qc.cx(q_ancillas[i], q_ancillas[i + 1])
|
1578
|
+
qc.t(q_ancillas[i + 1])
|
1579
|
+
qc.cx(q_controls[2 + i], q_ancillas[i + 1])
|
1580
|
+
qc.tdg(q_ancillas[i + 1])
|
1581
|
+
qc.h(q_ancillas[i + 1])
|
1582
|
+
|
1583
|
+
if self._action_only:
|
1584
|
+
qc.ccx(q_controls[-1], q_ancillas[-1], q_target)
|
1585
|
+
|
1586
|
+
break
|
1587
|
+
else:
|
1588
|
+
qc.rccx(q_controls[0], q_controls[1], q_ancillas[0])
|
1589
|
+
i = 0
|
1590
|
+
for j in range(2, self.num_ctrl_qubits - 1):
|
1591
|
+
qc.rccx(q_controls[j], q_ancillas[i], q_ancillas[i + 1])
|
1497
1592
|
|
1498
|
-
|
1499
|
-
definition.append(
|
1500
|
-
(RCCXGate(), [q_controls[j], q_ancillas[i - 1], q_ancillas[i]], [])
|
1501
|
-
)
|
1502
|
-
i -= 1
|
1593
|
+
i += 1
|
1503
1594
|
|
1504
|
-
|
1505
|
-
i = 0
|
1506
|
-
for j in range(2, self.num_ctrl_qubits - 1):
|
1507
|
-
definition.append((RCCXGate(), [q_controls[j], q_ancillas[i], q_ancillas[i + 1]], []))
|
1508
|
-
i += 1
|
1595
|
+
qc.ccx(q_controls[-1], q_ancillas[i], q_target)
|
1509
1596
|
|
1510
|
-
|
1511
|
-
|
1512
|
-
(U1Gate(-numpy.pi / 4), [q_ancillas[i]], []),
|
1513
|
-
(CXGate(), [q_controls[-1], q_ancillas[i]], []),
|
1514
|
-
(U1Gate(numpy.pi / 4), [q_ancillas[i]], []),
|
1515
|
-
(CXGate(), [q_target, q_ancillas[i]], []),
|
1516
|
-
(U1Gate(-numpy.pi / 4), [q_ancillas[i]], []),
|
1517
|
-
(CXGate(), [q_controls[-1], q_ancillas[i]], []),
|
1518
|
-
(U1Gate(numpy.pi / 4), [q_ancillas[i]], []),
|
1519
|
-
(CXGate(), [q_target, q_ancillas[i]], []),
|
1520
|
-
(U2Gate(0, numpy.pi), [q_target], []),
|
1521
|
-
]
|
1522
|
-
for inst in ancilla_post_rule:
|
1523
|
-
definition.append(inst)
|
1524
|
-
else:
|
1525
|
-
definition.append((CCXGate(), [q_controls[-1], q_ancillas[i], q_target], []))
|
1597
|
+
for j in reversed(range(2, self.num_ctrl_qubits - 1)):
|
1598
|
+
qc.rccx(q_controls[j], q_ancillas[i - 1], q_ancillas[i])
|
1526
1599
|
|
1527
|
-
|
1528
|
-
definition.append((RCCXGate(), [q_controls[j], q_ancillas[i - 1], q_ancillas[i]], []))
|
1529
|
-
i -= 1
|
1530
|
-
definition.append((RCCXGate(), [q_controls[0], q_controls[1], q_ancillas[i]], []))
|
1600
|
+
i -= 1
|
1531
1601
|
|
1532
|
-
|
1533
|
-
for i, j in enumerate(list(range(2, self.num_ctrl_qubits - 1))):
|
1534
|
-
definition.append(
|
1535
|
-
(RCCXGate(), [q_controls[j], q_ancillas[i], q_ancillas[i + 1]], [])
|
1536
|
-
)
|
1602
|
+
qc.rccx(q_controls[0], q_controls[1], q_ancillas[i])
|
1537
1603
|
|
1538
|
-
for instr, qargs, cargs in definition:
|
1539
|
-
qc._append(instr, qargs, cargs)
|
1540
1604
|
self.definition = qc
|
@@ -11,6 +11,9 @@
|
|
11
11
|
# that they have been altered from the originals.
|
12
12
|
|
13
13
|
"""Two-qubit XX-YY gate."""
|
14
|
+
|
15
|
+
from __future__ import annotations
|
16
|
+
|
14
17
|
import math
|
15
18
|
from cmath import exp
|
16
19
|
from math import pi
|
@@ -24,9 +27,10 @@ from qiskit.circuit.library.standard_gates.rz import RZGate
|
|
24
27
|
from qiskit.circuit.library.standard_gates.s import SdgGate, SGate
|
25
28
|
from qiskit.circuit.library.standard_gates.sx import SXdgGate, SXGate
|
26
29
|
from qiskit.circuit.library.standard_gates.x import CXGate
|
27
|
-
from qiskit.circuit.parameterexpression import ParameterValueType
|
30
|
+
from qiskit.circuit.parameterexpression import ParameterValueType, ParameterExpression
|
28
31
|
from qiskit.circuit.quantumcircuit import QuantumCircuit
|
29
32
|
from qiskit.circuit.quantumregister import QuantumRegister
|
33
|
+
from qiskit._accelerate.circuit import StandardGate
|
30
34
|
|
31
35
|
|
32
36
|
class XXMinusYYGate(Gate):
|
@@ -91,6 +95,8 @@ class XXMinusYYGate(Gate):
|
|
91
95
|
\end{pmatrix}
|
92
96
|
"""
|
93
97
|
|
98
|
+
_standard_gate = StandardGate.XXMinusYYGate
|
99
|
+
|
94
100
|
def __init__(
|
95
101
|
self,
|
96
102
|
theta: ParameterValueType,
|
@@ -153,6 +159,39 @@ class XXMinusYYGate(Gate):
|
|
153
159
|
|
154
160
|
self.definition = circuit
|
155
161
|
|
162
|
+
def control(
|
163
|
+
self,
|
164
|
+
num_ctrl_qubits: int = 1,
|
165
|
+
label: str | None = None,
|
166
|
+
ctrl_state: str | int | None = None,
|
167
|
+
annotated: bool | None = None,
|
168
|
+
):
|
169
|
+
"""Return a (multi-)controlled-(XX-YY) gate.
|
170
|
+
|
171
|
+
Args:
|
172
|
+
num_ctrl_qubits: number of control qubits.
|
173
|
+
label: An optional label for the gate [Default: ``None``]
|
174
|
+
ctrl_state: control state expressed as integer,
|
175
|
+
string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
|
176
|
+
annotated: indicates whether the controlled gate should be implemented
|
177
|
+
as an annotated gate. If ``None``, this is set to ``True`` if
|
178
|
+
the gate contains free parameters, in which case it cannot
|
179
|
+
yet be synthesized.
|
180
|
+
|
181
|
+
Returns:
|
182
|
+
ControlledGate: controlled version of this gate.
|
183
|
+
"""
|
184
|
+
if annotated is None:
|
185
|
+
annotated = any(isinstance(p, ParameterExpression) for p in self.params)
|
186
|
+
|
187
|
+
gate = super().control(
|
188
|
+
num_ctrl_qubits=num_ctrl_qubits,
|
189
|
+
label=label,
|
190
|
+
ctrl_state=ctrl_state,
|
191
|
+
annotated=annotated,
|
192
|
+
)
|
193
|
+
return gate
|
194
|
+
|
156
195
|
def inverse(self, annotated: bool = False):
|
157
196
|
"""Inverse gate.
|
158
197
|
|
@@ -11,6 +11,9 @@
|
|
11
11
|
# that they have been altered from the originals.
|
12
12
|
|
13
13
|
"""Two-qubit XX+YY gate."""
|
14
|
+
|
15
|
+
from __future__ import annotations
|
16
|
+
|
14
17
|
import math
|
15
18
|
from cmath import exp
|
16
19
|
from math import pi
|
@@ -20,7 +23,8 @@ import numpy
|
|
20
23
|
|
21
24
|
from qiskit.circuit.gate import Gate
|
22
25
|
from qiskit.circuit.quantumregister import QuantumRegister
|
23
|
-
from qiskit.circuit.parameterexpression import ParameterValueType
|
26
|
+
from qiskit.circuit.parameterexpression import ParameterValueType, ParameterExpression
|
27
|
+
from qiskit._accelerate.circuit import StandardGate
|
24
28
|
|
25
29
|
|
26
30
|
class XXPlusYYGate(Gate):
|
@@ -71,20 +75,24 @@ class XXPlusYYGate(Gate):
|
|
71
75
|
q_1: ┤0 ├
|
72
76
|
└───────────────┘
|
73
77
|
|
74
|
-
|
78
|
+
.. math::
|
75
79
|
|
76
|
-
|
80
|
+
\newcommand{\rotationangle}{\frac{\theta}{2}}
|
77
81
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
R_{XX+YY}(\theta, \beta)\ q_0, q_1 =
|
83
|
+
RZ_1(-\beta) \cdot \exp\left(-i \frac{\theta}{2} \frac{XX+YY}{2}\right) \cdot RZ_1(\beta) =
|
84
|
+
\begin{pmatrix}
|
85
|
+
1 & 0 & 0 & 0 \\
|
86
|
+
0 & \cos\left(\rotationangle\right) &
|
87
|
+
-i\sin\left(\rotationangle\right)e^{i\beta} & 0 \\
|
88
|
+
0 & -i\sin\left(\rotationangle\right)e^{-i\beta} &
|
89
|
+
\cos\left(\rotationangle\right) & 0 \\
|
90
|
+
0 & 0 & 0 & 1
|
91
|
+
\end{pmatrix}
|
86
92
|
"""
|
87
93
|
|
94
|
+
_standard_gate = StandardGate.XXPlusYYGate
|
95
|
+
|
88
96
|
def __init__(
|
89
97
|
self,
|
90
98
|
theta: ParameterValueType,
|
@@ -155,6 +163,39 @@ class XXPlusYYGate(Gate):
|
|
155
163
|
|
156
164
|
self.definition = qc
|
157
165
|
|
166
|
+
def control(
|
167
|
+
self,
|
168
|
+
num_ctrl_qubits: int = 1,
|
169
|
+
label: str | None = None,
|
170
|
+
ctrl_state: str | int | None = None,
|
171
|
+
annotated: bool | None = None,
|
172
|
+
):
|
173
|
+
"""Return a (multi-)controlled-(XX+YY) gate.
|
174
|
+
|
175
|
+
Args:
|
176
|
+
num_ctrl_qubits: number of control qubits.
|
177
|
+
label: An optional label for the gate [Default: ``None``]
|
178
|
+
ctrl_state: control state expressed as integer,
|
179
|
+
string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
|
180
|
+
annotated: indicates whether the controlled gate should be implemented
|
181
|
+
as an annotated gate. If ``None``, this is set to ``True`` if
|
182
|
+
the gate contains free parameters, in which case it cannot
|
183
|
+
yet be synthesized.
|
184
|
+
|
185
|
+
Returns:
|
186
|
+
ControlledGate: controlled version of this gate.
|
187
|
+
"""
|
188
|
+
if annotated is None:
|
189
|
+
annotated = any(isinstance(p, ParameterExpression) for p in self.params)
|
190
|
+
|
191
|
+
gate = super().control(
|
192
|
+
num_ctrl_qubits=num_ctrl_qubits,
|
193
|
+
label=label,
|
194
|
+
ctrl_state=ctrl_state,
|
195
|
+
annotated=annotated,
|
196
|
+
)
|
197
|
+
return gate
|
198
|
+
|
158
199
|
def inverse(self, annotated: bool = False):
|
159
200
|
"""Return inverse XX+YY gate (i.e. with the negative rotation angle and same phase angle).
|
160
201
|
|
@@ -19,6 +19,7 @@ from typing import Optional, Union
|
|
19
19
|
from qiskit.circuit.singleton import SingletonGate, SingletonControlledGate, stdlib_singleton_key
|
20
20
|
from qiskit.circuit.quantumregister import QuantumRegister
|
21
21
|
from qiskit.circuit._utils import with_gate_array, with_controlled_gate_array
|
22
|
+
from qiskit._accelerate.circuit import StandardGate
|
22
23
|
|
23
24
|
_Y_ARRAY = [[0, -1j], [1j, 0]]
|
24
25
|
|
@@ -70,6 +71,8 @@ class YGate(SingletonGate):
|
|
70
71
|
|1\rangle \rightarrow -i|0\rangle
|
71
72
|
"""
|
72
73
|
|
74
|
+
_standard_gate = StandardGate.YGate
|
75
|
+
|
73
76
|
def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
|
74
77
|
"""Create new Y gate."""
|
75
78
|
super().__init__("y", 1, [], label=label, duration=duration, unit=unit)
|
@@ -105,7 +108,7 @@ class YGate(SingletonGate):
|
|
105
108
|
label: An optional label for the gate [Default: ``None``]
|
106
109
|
ctrl_state: control state expressed as integer,
|
107
110
|
string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
|
108
|
-
annotated: indicates whether the controlled gate
|
111
|
+
annotated: indicates whether the controlled gate should be implemented
|
109
112
|
as an annotated gate.
|
110
113
|
|
111
114
|
Returns:
|
@@ -197,6 +200,8 @@ class CYGate(SingletonControlledGate):
|
|
197
200
|
|
198
201
|
"""
|
199
202
|
|
203
|
+
_standard_gate = StandardGate.CYGate
|
204
|
+
|
200
205
|
def __init__(
|
201
206
|
self,
|
202
207
|
label: Optional[str] = None,
|
@@ -20,6 +20,7 @@ import numpy
|
|
20
20
|
from qiskit.circuit._utils import with_gate_array, with_controlled_gate_array
|
21
21
|
from qiskit.circuit.singleton import SingletonGate, SingletonControlledGate, stdlib_singleton_key
|
22
22
|
from qiskit.circuit.quantumregister import QuantumRegister
|
23
|
+
from qiskit._accelerate.circuit import StandardGate
|
23
24
|
|
24
25
|
from .p import PhaseGate
|
25
26
|
|
@@ -73,6 +74,8 @@ class ZGate(SingletonGate):
|
|
73
74
|
|1\rangle \rightarrow -|1\rangle
|
74
75
|
"""
|
75
76
|
|
77
|
+
_standard_gate = StandardGate.ZGate
|
78
|
+
|
76
79
|
def __init__(self, label: Optional[str] = None, *, duration=None, unit="dt"):
|
77
80
|
"""Create new Z gate."""
|
78
81
|
super().__init__("z", 1, [], label=label, duration=duration, unit=unit)
|
@@ -109,7 +112,7 @@ class ZGate(SingletonGate):
|
|
109
112
|
label: An optional label for the gate [Default: ``None``]
|
110
113
|
ctrl_state: control state expressed as integer,
|
111
114
|
string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
|
112
|
-
annotated: indicates whether the controlled gate
|
115
|
+
annotated: indicates whether the controlled gate should be implemented
|
113
116
|
as an annotated gate.
|
114
117
|
|
115
118
|
Returns:
|
@@ -181,6 +184,8 @@ class CZGate(SingletonControlledGate):
|
|
181
184
|
the target qubit if the control qubit is in the :math:`|1\rangle` state.
|
182
185
|
"""
|
183
186
|
|
187
|
+
_standard_gate = StandardGate.CZGate
|
188
|
+
|
184
189
|
def __init__(
|
185
190
|
self,
|
186
191
|
label: Optional[str] = None,
|
@@ -281,6 +286,8 @@ class CCZGate(SingletonControlledGate):
|
|
281
286
|
the target qubit if the control qubits are in the :math:`|11\rangle` state.
|
282
287
|
"""
|
283
288
|
|
289
|
+
_standard_gate = StandardGate.CCZGate
|
290
|
+
|
284
291
|
def __init__(
|
285
292
|
self,
|
286
293
|
label: Optional[str] = None,
|
qiskit/circuit/operation.py
CHANGED
@@ -25,7 +25,7 @@ class Operation(ABC):
|
|
25
25
|
:class:`~qiskit.circuit.Reset`, :class:`~qiskit.circuit.Barrier`,
|
26
26
|
:class:`~qiskit.circuit.Measure`, and operators such as :class:`~qiskit.quantum_info.Clifford`.
|
27
27
|
|
28
|
-
The main purpose is to
|
28
|
+
The main purpose is to allow abstract mathematical objects to be added directly onto
|
29
29
|
abstract circuits, and for the exact syntheses of these to be determined later, during
|
30
30
|
compilation.
|
31
31
|
|