-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathstatevector_initialstate.py
More file actions
33 lines (26 loc) · 957 Bytes
/
statevector_initialstate.py
File metadata and controls
33 lines (26 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit import Parameter
from .base_initialstate import InitialState
class StateVector(InitialState):
"""
State vector initial state. For custom initial states.
Subclass of the `InitialState` class.
Attributes:
statevector (list): The statevector to initialize the circuit with.
Methods:
create_circuit(): Creates a circuit that creates the initial statevector.
"""
def __init__(self, statevector) -> None:
"""
Args:
statevector (list): The statevector to initialize the circuit with.
"""
super().__init__()
self.statevector = statevector
def create_circuit(self):
"""
Creates a circuit that makes the initial statevector
"""
q = QuantumRegister(self.N_qubits)
self.circuit = QuantumCircuit(q)
self.circuit.initialize(self.statevector, q)