QuantumRegister module

This module creates the Quantum Register and the Qubits.

class QuantumRegister.QuantumRegister(n)

Bases: object

Initializes the quantum register of length n. Creates a list of default qubits in state 0 and initializes the wavevector which describes the register.

Parameters

n – (int) length of register

initialize()

Sets the statevector according to the current state of qubits

measure()

Attempts to measure the current statevector in terms of individual qubits

setQbits(qbits, vals)

Sets the initial values of the qubits if required, although it is preferred to use gates for this step. Automatically normalizes the Qbit

Parameters
  • qbits – (list) qubts to be set

  • vals – (list) The values that the qubits should be set to. Each entry containing two values

setStateVec(newVec)

Allows the user to set the state vector to a new vector. Automatically normalises the vector.

Parameters

newVec – (list) The new vector to become the state vector

class QuantumRegister.Qubit

Bases: object

Creates a qubit using sparse matrices.

get0()

Gets the 0 state

get1()

Gets the 1 state

normalize()

Normalizes all the elements.