qiskit.aqua.components.initial_states.Custom¶

class
Custom
(num_qubits, state='zero', state_vector=None, circuit=None)[Quellcode]¶ The custom initial state.
A custom initial state can be created with this component. It allows a state to be defined in the form of custom probability distribution with the state_vector, or by providing a desired circuit to set the state.
Also state can be used having a few predefined initial states for convenience:
‚zero‘: configures the state vector with the zero probability distribution, and is effectively equivalent to the
Zero
initial state.‚uniform‘: This setting configures the state vector with the uniform probability distribution. All the qubits are set in superposition, each of them being initialized with a Hadamard gate, which means that a measurement will have equal probabilities to become \(1\) or \(0\).
‚random‘: This setting assigns the elements of the state vector according to a random probability distribution.
The custom initial state will be set from the circuit, the state_vector, or state, in that order. For state_vector the provided custom probability distribution will be internally normalized so the total probability represented is \(1.0\).
 Parameter
num_qubits (
int
) – Number of qubits, has a minimum value of 1.state (
str
) – Use a predefined state of (‚zero‘  ‚uniform‘  ‚random‘)state_vector (
Union
[ndarray
,StateFn
,None
]) – An optional vector ofcomplex
orfloat
representing the state as a probability distribution which will be normalized to a total probability of 1 when initializing the qubits. The length of the vector must be \(2^q\), where \(q\) is the num_qubits value. When provided takes precedence over state.circuit (
Optional
[QuantumCircuit
]) – A quantum circuit for the desired initial state. When provided takes precedence over both state_vector and state.
 Verursacht
AquaError – invalid input

__init__
(num_qubits, state='zero', state_vector=None, circuit=None)[Quellcode]¶  Parameter
num_qubits (
int
) – Number of qubits, has a minimum value of 1.state (
str
) – Use a predefined state of (‚zero‘  ‚uniform‘  ‚random‘)state_vector (
Union
[ndarray
,StateFn
,None
]) – An optional vector ofcomplex
orfloat
representing the state as a probability distribution which will be normalized to a total probability of 1 when initializing the qubits. The length of the vector must be \(2^q\), where \(q\) is the num_qubits value. When provided takes precedence over state.circuit (
Optional
[QuantumCircuit
]) – A quantum circuit for the desired initial state. When provided takes precedence over both state_vector and state.
 Verursacht
AquaError – invalid input
Methods
__init__
(num_qubits[, state, state_vector, …]) type num_qubits
int
construct_circuit
([mode, register])Construct the statevector of desired initial state.
Attributes

property
bitstr
¶

construct_circuit
(mode='circuit', register=None)[Quellcode]¶ Construct the statevector of desired initial state.
 Parameter
mode – vector or circuit. The vector mode produces the vector. While the circuit constructs the quantum circuit corresponding that vector.
register – qubits for circuit construction.
 Rückgabe
statevector.
 Rückgabetyp
QuantumCircuit or numpy.ndarray
 Verursacht
AquaError – when mode is not ‚vector‘ or ‚circuit‘.