#include <qgtypes.h>
Public Member Functions | |
Qureg (int size=0) | |
The size of the Qureg (number of qubits, NOT amplitudes) must be given. | |
unsigned int | size () const |
Returns the size of the Qureg (number of qubits, NOT amplitudes). | |
std::vector< QuSubReg > | getSubRegs (const QubitList &qubits) |
Returns a vector of QuSubReg objects, that is, references to the amplitudes referenced by the QubitList. | |
std::vector< double > | getProbabilities (const QubitList &qubits) |
Returns a list of probabilities for measuring the given qubits, in binary order as given in the QubitList. | |
void | collapse (const QubitList &qubits, int value) |
Collapses the given qubits to the value given (which can be thought as a binary value corresponding to the given QubitList). | |
void | normalize () |
Normalize the Qureg, so that all probabilities sum to 1. | |
Complex & | operator[] (const unsigned int) throw (Error) |
Returns a reference to the addressed amplitude. | |
Friends | |
std::ostream & | operator<< (std::ostream &, Qureg) |
This class represents a quantum register and provides manipulation functions. If you need to access a part of the Qureg as addressed by a number of qubits (in arbitrary order), use getSubRegs(QubitList). You can address individual amplitudes by using [].
Definition at line 115 of file qgtypes.h.
|
Collapses the given qubits to the value given (which can be thought as a binary value corresponding to the given QubitList). No normalization is done by now, although this might change in later versions of QGame++ to provide a more physically accurate behavior. Definition at line 206 of file qgtypes.cpp. References getSubRegs(), and normalize(). |
|
Returns a vector of QuSubReg objects, that is, references to the amplitudes referenced by the QubitList. Each QuSubReg object contains references to the amplitudes of the qubits referenced by the given QubitList, with the first qubit number added to the list being the least signicant. The QuSubReg objects are in binary order as addressed by the remaining qubits not in the QubitList, with the rightmost of these qubits being the least significant. For example, having a 3 qubit Qureg and a QubitList containing 1 (this means, the middle qubit should be manipulated), you would get four QuSubReg objects: { |000>, |010> } , { |001>, |011> }, { |100>, |110> }, { |101>, |111> } Definition at line 153 of file qgtypes.cpp. References qgame::QubitList::append(), qgame::QubitList::size(), and qgame::QuSubReg::sub. Referenced by collapse(), and getProbabilities(). |