quri_parts.circuit.circuit_linear_mapped module#
- class quri_parts.circuit.circuit_linear_mapped.LinearMappedUnboundParametricQuantumCircuitBase(*args, **kwargs)#
Bases:
UnboundParametricQuantumCircuitProtocol
,ABC
A base class for parametric quantum circuits where parameters of parametric gates are given by linear functions of circuit parameters.
- property qubit_count: int#
Number of qubits involved in the circuit.
- property cbit_count: int#
Number of classical bits involved in the circuit.
- property parameter_count: int#
- property depth: int#
Returns circuit depth.
- property gates: Sequence[QuantumGate | ParametricQuantumGate]#
Returns the gate sequence of the circuit.
- property has_trivial_parameter_mapping: bool#
Returns if the input parameters are used for parametric gates without any conversions.
Note that some parametric circuit, e.g.
LinearMappedUnboundParametricQuantumCircuit
, can have non-trivial mapping of the parameters.
- property param_mapping: LinearParameterMapping#
Returns the parameter mapping of the circuit.
- primitive_circuit() ImmutableUnboundParametricQuantumCircuit #
Returns the parametric circuit where each gate has an independent parameter.
Note that some parametric circuit, e.g.
LinearMappedUnboundParametricQuantumCircuit
, can have non-trivial mapping of the parameters. In this “primitive circuit”, however, gate parameters are treated as independent, even if those in the original circuit depend on the same parameters. For example, if the parametric circuit is defined as:\[\begin{align} U_1(f(\theta_1, \theta_2)) U_2(g(\theta_1, \theta_2)) \end{align}\]the primitive circuit should be as the following:
\[\begin{align} U_1(\psi_1) U_2(\psi_2) \end{align}\]where U1, U2 are rotation gates and f, g are parameter mappings.
- get_mutable_copy() LinearMappedUnboundParametricQuantumCircuit #
Returns a copy of itself that can be modified.
Use this method when you want to get a new circuit based on an existing circuit but don’t want to modify it.
- combine(gates: NonParametricQuantumCircuit | Sequence[QuantumGate] | UnboundParametricQuantumCircuitProtocol) LinearMappedUnboundParametricQuantumCircuit #
- bind_parameters(params: Sequence[float]) ImmutableBoundParametricQuantumCircuit #
Returns a new circuit with the parameters assigned concrete values.
This method does not modify self but returns a newly created circuit.
- class quri_parts.circuit.circuit_linear_mapped.LinearMappedUnboundParametricQuantumCircuit(qubit_count: int, cbit_count: int = 0)#
Bases:
LinearMappedUnboundParametricQuantumCircuitBase
,MutableUnboundParametricQuantumCircuitProtocol
A mutable parametric quantum circuit where parameters of parametric gates are given by linear functions of circuit parameters.
- add_parameters(*names: str) Sequence[Parameter] #
Add new parameters for the circuit.
Newly created parameters are returned as a sequence. Before adding a parametric gate to the circuit, all used parameters should be added by this method or
add_parameter()
.
- add_parameter(name: str) Parameter #
Add a new parameter for the circuit.
Before adding a parametric gate to the circuit, all used parameters should be added by this method or
add_parametesr()
.
- add_gate(gate: QuantumGate, gate_index: int | None = None) None #
Add a (non-parametric) quantum gate to the circuit.
- add_ParametricRX_gate(qubit_index: int, angle: Parameter | Mapping[Parameter, float]) None #
Add a parametric RX gate to the circuit.
- add_ParametricRY_gate(qubit_index: int, angle: Parameter | Mapping[Parameter, float]) None #
Add a parametric RY gate to the circuit.
- add_ParametricRZ_gate(qubit_index: int, angle: Parameter | Mapping[Parameter, float]) None #
Add a parametric RZ gate to the circuit.
- add_ParametricPauliRotation_gate(qubit_indices: Sequence[int], pauli_ids: Sequence[int], angle: Parameter | Mapping[Parameter, float]) None #
Add a parametric Pauli rotation gate to the circuit.
- extend(gates: NonParametricQuantumCircuit | Sequence[QuantumGate] | UnboundParametricQuantumCircuitProtocol) None #
Extend the parametric circuit with given gates or a linear mapped unbound parametric circuit.
If the two linear mapped parametric circuit share the same parameters, they are treated as the same parameters, in contrast to the case of
UnboundParametricQuantumCircuit
.
- freeze() ImmutableLinearMappedUnboundParametricQuantumCircuit #
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.
- class quri_parts.circuit.circuit_linear_mapped.ImmutableLinearMappedUnboundParametricQuantumCircuit(circuit: LinearMappedUnboundParametricQuantumCircuitBase)#
Bases:
LinearMappedUnboundParametricQuantumCircuitBase
An immutable parametric quantum circuit where parameters of parametric gates are given by linear functions of circuit parameters.
- freeze() ImmutableLinearMappedUnboundParametricQuantumCircuit #
Returns a “freezed” version of itself.
The “freezed” version is an immutable object and can be reused safely without copying.