class QState

Model of a quantum state/register

Concepts/Code by: Yan Pritzker, John Belkner, Rafal Podeszwa
Members

Public
QState () : Default constructor. (Create one qubit)
QState (int size) : Coefficients not specified. Set up Walsh-Hadamard state (1/sqrt(size)).
QState (int size, const Complex c[]) : Constructor with initialization to complex amplitude array.
~QState () : Default destructor.
void SetState (const Complex c[]) : Set state to specified coefficients.
void PrintSTD () const : Display outcomes and coefficients [does not disturb state]
void Print () const : New version of above. (uses streams) [DOES NOT COLLAPSE]
void Dump (char filename[]) const : Dump state to file. (Oemer-like Format) [does not disturb state]
void Read (char filename[]) : Read state from file. [convenience function]
int Outcomes () const : Returns total number of outcomes.
int Qubits () const : Returns total number of bits.
operator long () : Implicit conversion operator causes destructive measure.
Complex& operator[] (int index) : Access to coefficients.

Friends
friend ostream& operator<< (ostream&, const QState&) : Same as above.
friend void Reset (QState &q) : Reset to base state |00...0>.
friend long Measure (QState &q) : Destructive register measure.
friend short Measure (QState &q, int i) : Destructive bit measure.
friend int MeasureSet (QState &q, unsigned long bits) : Destructive measure of a set of bits.
friend double norm (const QState &q) : Sum of normalized amplitudes.




    friend long Measure(
    QState &q)
    Destructive register measure.

    Note that the collapsing functions do not return another state, as suggested by Peter Belkner, but rather destroy the *this state. This is more physically correct because when we look at a quantum state in real life, we don't get 'another' state, but rather the state we are looking at collapses. After the collapse all the coefficients are set to 0 except for that of the state that the register collapsed to.



Return To Index