Quantum Registers¶
QCGPU provides a class to represent the register, qcgpu.State
. The
register class stores (on the OpenCL device) a state vector. This state
vector is a chunk of memory, the size of which is:
This means you would need just 2kb of memory to have a 5 qubit register, a 30 qubit register would take up 9gb of memory.
This is something to be aware of, as the state vector must fit in the memory of the device you wish to use.
Using the State
class¶
To create a new register, you can use
import qcgpu
register = qcgpu.State(5)
This will create a 5 qubit register.
When you run this, you may be prompted to choose a device. This is normal, as you can have more than 1 device that supports OpenCL in your computer. Just choose the one you want.
Mathematical Description¶
This class represents a state vector \(\lvert \psi \rangle\) with
where \(n\) is the number of qubits, \(\alpha_j\) is the amplitude and the state is \(j\) runs overall \(2^n\) basis states.