Qrack  1.7
General classical-emulating-quantum development framework
Functions
Basic quantum gate primitives

Functions

virtual void Qrack::QEngineCPU::ApplySingleBit (const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void Qrack::QEngineCPU::CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Doubly-controlled not. More...
 
virtual void Qrack::QEngineCPU::AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 "Anti-doubly-controlled not" - Apply "not" if control bits are both zero, do not apply if either control bit is one. More...
 
virtual void Qrack::QEngineCPU::CNOT (bitLenInt control, bitLenInt target)
 Controlled not. More...
 
virtual void Qrack::QEngineCPU::AntiCNOT (bitLenInt control, bitLenInt target)
 "Anti-controlled not" - Apply "not" if control bit is zero, do not apply if control bit is one. More...
 
virtual void Qrack::QEngineCPU::H (bitLenInt qubitIndex)
 Hadamard gate. More...
 
virtual bool Qrack::QEngineCPU::M (bitLenInt qubitIndex)
 Measurement gate. More...
 
virtual void Qrack::QEngineCPU::X (bitLenInt qubitIndex)
 NOT gate, which is also Pauli x matrix. More...
 
virtual void Qrack::QEngineCPU::Y (bitLenInt qubitIndex)
 Apply Pauli Y matrix to bit. More...
 
virtual void Qrack::QEngineCPU::Z (bitLenInt qubitIndex)
 Apply Pauli Z matrix to bit. More...
 
virtual void Qrack::QEngineCPU::CY (bitLenInt control, bitLenInt target)
 Apply controlled Pauli Y matrix to bit. More...
 
virtual void Qrack::QEngineCPU::CZ (bitLenInt control, bitLenInt target)
 Apply controlled Pauli Z matrix to bit. More...
 
virtual void Qrack::QInterface::ApplySingleBit (const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)=0
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void Qrack::QInterface::CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)=0
 Doubly-controlled NOT gate. More...
 
virtual void Qrack::QInterface::AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Anti doubly-controlled NOT gate. More...
 
virtual void Qrack::QInterface::CNOT (bitLenInt control, bitLenInt target)=0
 Controlled NOT gate. More...
 
virtual void Qrack::QInterface::AntiCNOT (bitLenInt control, bitLenInt target)
 Anti controlled NOT gate. More...
 
virtual void Qrack::QInterface::H (bitLenInt qubitIndex)=0
 Hadamard gate. More...
 
virtual bool Qrack::QInterface::M (bitLenInt qubitIndex)=0
 Measurement gate. More...
 
virtual void Qrack::QInterface::X (bitLenInt qubitIndex)=0
 X gate. More...
 
virtual void Qrack::QInterface::Y (bitLenInt qubitIndex)=0
 Y gate. More...
 
virtual void Qrack::QInterface::Z (bitLenInt qubitIndex)=0
 Z gate. More...
 
virtual void Qrack::QInterface::CY (bitLenInt control, bitLenInt target)=0
 Controlled Y gate. More...
 
virtual void Qrack::QInterface::CZ (bitLenInt control, bitLenInt target)=0
 Controlled Z gate. More...
 
virtual void Qrack::QUnit::ApplySingleBit (const complex *mtrx, bool doCalcNorm, bitLenInt qubit)
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void Qrack::QUnit::CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Doubly-controlled NOT gate. More...
 
virtual void Qrack::QUnit::AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Anti doubly-controlled NOT gate. More...
 
virtual void Qrack::QUnit::CNOT (bitLenInt control, bitLenInt target)
 Controlled NOT gate. More...
 
virtual void Qrack::QUnit::AntiCNOT (bitLenInt control, bitLenInt target)
 Anti controlled NOT gate. More...
 
virtual void Qrack::QUnit::H (bitLenInt qubit)
 Hadamard gate. More...
 
virtual bool Qrack::QUnit::M (bitLenInt qubit)
 Measure a bit. More...
 
virtual void Qrack::QUnit::X (bitLenInt qubit)
 X gate. More...
 
virtual void Qrack::QUnit::Y (bitLenInt qubit)
 Y gate. More...
 
virtual void Qrack::QUnit::Z (bitLenInt qubit)
 Z gate. More...
 
virtual void Qrack::QUnit::CY (bitLenInt control, bitLenInt target)
 Controlled Y gate. More...
 
virtual void Qrack::QUnit::CZ (bitLenInt control, bitLenInt target)
 Controlled Z gate. More...
 

Detailed Description

Function Documentation

void Qrack::QUnit::AntiCCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
virtual

Anti doubly-controlled NOT gate.

If both controls are set to 0, the target bit is NOT-ed or X-ed.

Reimplemented from Qrack::QInterface.

void Qrack::QEngineCPU::AntiCCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
virtual

"Anti-doubly-controlled not" - Apply "not" if control bits are both zero, do not apply if either control bit is one.

Reimplemented from Qrack::QInterface.

void Qrack::QInterface::AntiCCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
virtual

Anti doubly-controlled NOT gate.

If both controls are set to 0, the target bit is NOT-ed or X-ed.

Reimplemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::AntiCNOT ( bitLenInt  control,
bitLenInt  target 
)
virtual

Anti controlled NOT gate.

If the control is set to 0, the target bit is NOT-ed or X-ed.

Reimplemented from Qrack::QInterface.

void Qrack::QEngineCPU::AntiCNOT ( bitLenInt  control,
bitLenInt  target 
)
virtual

"Anti-controlled not" - Apply "not" if control bit is zero, do not apply if control bit is one.

Reimplemented from Qrack::QInterface.

void Qrack::QInterface::AntiCNOT ( bitLenInt  control,
bitLenInt  target 
)
virtual

Anti controlled NOT gate.

If the control is set to 0, the target bit is NOT-ed or X-ed.

Reimplemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::ApplySingleBit ( const complex mtrx,
bool  doCalcNorm,
bitLenInt  qubitIndex 
)
virtual

Apply an arbitrary single bit unitary transformation.

If float rounding from the application of the matrix might change the state vector norm, "doCalcNorm" should be set to true.

Implements Qrack::QInterface.

void Qrack::QEngineCPU::ApplySingleBit ( const complex mtrx,
bool  doCalcNorm,
bitLenInt  qubitIndex 
)
virtual

Apply an arbitrary single bit unitary transformation.

If float rounding from the application of the matrix might change the state vector norm, "doCalcNorm" should be set to true.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::ApplySingleBit ( const complex mtrx,
bool  doCalcNorm,
bitLenInt  qubitIndex 
)
pure virtual

Apply an arbitrary single bit unitary transformation.

If float rounding from the application of the matrix might change the state vector norm, "doCalcNorm" should be set to true.

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::CCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
virtual

Doubly-controlled NOT gate.

If both controls are set to 1, the target bit is NOT-ed or X-ed.

Implements Qrack::QInterface.

void Qrack::QEngineCPU::CCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
virtual

Doubly-controlled not.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::CCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
pure virtual

Doubly-controlled NOT gate.

If both controls are set to 1, the target bit is NOT-ed or X-ed.

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::CNOT ( bitLenInt  control,
bitLenInt  target 
)
virtual

Controlled NOT gate.

If the control is set to 1, the target bit is NOT-ed or X-ed.

Implements Qrack::QInterface.

void Qrack::QEngineCPU::CNOT ( bitLenInt  control,
bitLenInt  target 
)
virtual

Controlled not.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::CNOT ( bitLenInt  control,
bitLenInt  target 
)
pure virtual

Controlled NOT gate.

If the control is set to 1, the target bit is NOT-ed or X-ed.

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::CY ( bitLenInt  control,
bitLenInt  target 
)
virtual

Controlled Y gate.

If the "control" bit is set to 1, then the Pauli "Y" operator is applied to "target."

Implements Qrack::QInterface.

void Qrack::QEngineCPU::CY ( bitLenInt  control,
bitLenInt  target 
)
virtual

Apply controlled Pauli Y matrix to bit.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::CY ( bitLenInt  control,
bitLenInt  target 
)
pure virtual

Controlled Y gate.

If the "control" bit is set to 1, then the Pauli "Y" operator is applied to "target."

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::CZ ( bitLenInt  control,
bitLenInt  target 
)
virtual

Controlled Z gate.

If the "control" bit is set to 1, then the Pauli "Z" operator is applied to "target."

Implements Qrack::QInterface.

void Qrack::QEngineCPU::CZ ( bitLenInt  control,
bitLenInt  target 
)
virtual

Apply controlled Pauli Z matrix to bit.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::CZ ( bitLenInt  control,
bitLenInt  target 
)
pure virtual

Controlled Z gate.

If the "control" bit is set to 1, then the Pauli "Z" operator is applied to "target."

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::H ( bitLenInt  qubitIndex)
virtual

Hadamard gate.

Applies a Hadamard gate on qubit at "qubitIndex."

Implements Qrack::QInterface.

void Qrack::QEngineCPU::H ( bitLenInt  qubitIndex)
virtual

Hadamard gate.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::H ( bitLenInt  qubitIndex)
pure virtual

Hadamard gate.

Applies a Hadamard gate on qubit at "qubitIndex."

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

bool Qrack::QUnit::M ( bitLenInt  qubit)
virtual

Measure a bit.

Implements Qrack::QInterface.

bool Qrack::QEngineCPU::M ( bitLenInt  qubitIndex)
virtual

Measurement gate.

Implements Qrack::QInterface.

virtual bool Qrack::QInterface::M ( bitLenInt  qubitIndex)
pure virtual

Measurement gate.

Measures the qubit at "qubitIndex" and returns either "true" or "false." (This "gate" breaks unitarity.)

All physical evolution of a quantum state should be "unitary," except measurement. Measurement of a qubit "collapses" the quantum state into either only permutation states consistent with a |0> state for the bit, or else only permutation states consistent with a |1> state for the bit. Measurement also effectively multiplies the overall quantum state vector of the system by a random phase factor, equiprobable over all possible phase angles.

Effectively, when a bit measurement is emulated, Qrack calculates the norm of all permutation state components, to find their respective probabilities. The probabilities of all states in which the measured bit is "0" can be summed to give the probability of the bit being "0," and separately the probabilities of all states in which the measured bit is "1" can be summed to give the probability of the bit being "1." To simulate measurement, a random float between 0 and 1 is compared to the sum of the probability of all permutation states in which the bit is equal to "1". Depending on whether the random float is higher or lower than the probability, the qubit is determined to be either |0> or |1>, (up to phase). If the bit is determined to be |1>, then all permutation eigenstates in which the bit would be equal to |0> have their probability set to zero, and vice versa if the bit is determined to be |0>. Then, all remaining permutation states with nonzero probability are linearly rescaled so that the total probability of all permutation states is again "normalized" to exactly 100% or 1, (within double precision rounding error). Physically, the act of measurement should introduce an overall random phase factor on the state vector, which is emulated by generating another constantly distributed random float to select a phase angle between 0 and 2 * Pi.

Measurement breaks unitary evolution of state. All quantum gates except measurement should generally act as a unitary matrix on a permutation state vector. (Note that Boolean comparison convenience methods in Qrack such as "AND," "OR," and "XOR" employ the measurement operation in the act of first clearing output bits before filling them with the result of comparison, and these convenience methods therefore break unitary evolution of state, but in a physically realistic way. Comparable unitary operations would be performed with a combination of X and CCNOT gates, also called "Toffoli" gates, but the output bits would have to be assumed to be in a known fixed state, like all |0>, ahead of time to produce unitary logical comparison operations.)

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::X ( bitLenInt  qubitIndex)
virtual

X gate.

Applies the Pauli "X" operator to the qubit at "qubitIndex." The Pauli "X" operator is equivalent to a logical "NOT."

Implements Qrack::QInterface.

void Qrack::QEngineCPU::X ( bitLenInt  qubitIndex)
virtual

NOT gate, which is also Pauli x matrix.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::X ( bitLenInt  qubitIndex)
pure virtual

X gate.

Applies the Pauli "X" operator to the qubit at "qubitIndex." The Pauli "X" operator is equivalent to a logical "NOT."

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::Y ( bitLenInt  qubitIndex)
virtual

Y gate.

Applies the Pauli "Y" operator to the qubit at "qubitIndex." The Pauli "Y" operator is similar to a logical "NOT" with permutation phase effects.

Implements Qrack::QInterface.

void Qrack::QEngineCPU::Y ( bitLenInt  qubitIndex)
virtual

Apply Pauli Y matrix to bit.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::Y ( bitLenInt  qubitIndex)
pure virtual

Y gate.

Applies the Pauli "Y" operator to the qubit at "qubitIndex." The Pauli "Y" operator is similar to a logical "NOT" with permutation phase effects.

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.

void Qrack::QUnit::Z ( bitLenInt  qubitIndex)
virtual

Z gate.

Applies the Pauli "Z" operator to the qubit at "qubitIndex." The Pauli "Z" operator reverses the phase of |1> and leaves |0> unchanged.

Implements Qrack::QInterface.

void Qrack::QEngineCPU::Z ( bitLenInt  qubitIndex)
virtual

Apply Pauli Z matrix to bit.

Implements Qrack::QInterface.

virtual void Qrack::QInterface::Z ( bitLenInt  qubitIndex)
pure virtual

Z gate.

Applies the Pauli "Z" operator to the qubit at "qubitIndex." The Pauli "Z" operator reverses the phase of |1> and leaves |0> unchanged.

Implemented in Qrack::QEngineOCLMulti, Qrack::QEngineCPU, and Qrack::QUnit.