State module¶
The State module is used to create objects representing quantum states.
-
class
State.
BasisStates
(dimension)¶ Bases:
object
creates the pure basis states with the given dimension.
- Parameters
dimension – (int) dimensions of vector space
-
class
State.
Qubit
(a, b)¶ Bases:
State.State
Subclass of the State class. Qubits are specifically 2 dimensional states. Builds the state vector.
- Parameters
a – (int) amplitude of basis state 0
b – (int) amplitude of basis state 1
-
class
State.
State
(matrix)¶ Bases:
object
General Method of creating objects that represent quantum states
- Parameters
matrix – (array) Matrix representing Quantum State
-
apply_gate
(gate)¶ Applies the gate given as argument to the quantum state After asserting that the dimensions of the state and gate match, calculates the dot product of the gate’s operator and the state’s vector, and saves the result as the new updated state vector.
- Parameters
gate – (array) gate of the circuit
-
measure
()¶ Measures the quantum state and collapses it to one of its basis states. Collapses the wavefunction to one of its basis states by using the probabilities from the the method of the probabilities function and the numpy random library.
- Returns
(int) index of collapsed state
-
probabilities
()¶ Calculates the amplitude of each basis state in an entangled state Goes through the amplitudes of each basis, multiplies it by its conjugate, and outputs a list of the basis states and their corresponding probabilities inside the state vector.
- Returns
(list) basis states and their probabilities inside the state vector