|
Distributed QUEST for GPU
|
The core of the QuEST Library. More...
#include <math.h>#include <stdio.h>#include <stdlib.h>#include <assert.h>#include "QuEST_precision.h"#include "QuEST.h"#include "QuEST_internal.h"#include "mt19937ar.h"#include <sys/param.h>#include <unistd.h>#include <sys/types.h>#include <sys/time.h>Go to the source code of this file.
Macros | |
| #define | DEBUG 0 |
Functions | |
| void | reportState (MultiQubit multiQubit) |
| Print the current state vector of probability amplitudes for a set of qubits to file. More... | |
| void | reportMultiQubitParams (MultiQubit multiQubit) |
| Report metainformation about a set of qubits: number of qubits, number of probability amplitudes. More... | |
| void | rotateAroundAxis (MultiQubit multiQubit, const int rotQubit, REAL angle, Vector axis) |
| Rotate a single qubit by a given angle around a given vector on the Bloch-sphere. More... | |
| void | rotateX (MultiQubit multiQubit, const int rotQubit, REAL angle) |
| Rotate a single qubit by a given angle around the X-axis of the Bloch-sphere. More... | |
| void | rotateY (MultiQubit multiQubit, const int rotQubit, REAL angle) |
| Rotate a single qubit by a given angle around the Y-axis of the Bloch-sphere. More... | |
| void | rotateZ (MultiQubit multiQubit, const int rotQubit, REAL angle) |
| Rotate a single qubit by a given angle around the Z-axis of the Bloch-sphere (also known as a phase shift gate). More... | |
| void | controlledRotateAroundAxis (MultiQubit multiQubit, const int controlQubit, const int targetQubit, REAL angle, Vector axis) |
| Applies a controlled rotation by a given angle around a given vector on the Bloch-sphere. More... | |
| void | controlledRotateX (MultiQubit multiQubit, const int controlQubit, const int targetQubit, REAL angle) |
| Applies a controlled rotation by a given angle around the X-axis of the Bloch-sphere. More... | |
| void | controlledRotateY (MultiQubit multiQubit, const int controlQubit, const int targetQubit, REAL angle) |
| Applies a controlled rotation by a given angle around the Y-axis of the Bloch-sphere. More... | |
| void | controlledRotateZ (MultiQubit multiQubit, const int controlQubit, const int targetQubit, REAL angle) |
| Applies a controlled rotation by a given angle around the Z-axis of the Bloch-sphere. More... | |
| void | sigmaZ (MultiQubit multiQubit, const int targetQubit) |
| Apply the single-qubit sigma-Z (also known as the Z, Pauli-Z or phase-flip) gate. More... | |
| void | sGate (MultiQubit multiQubit, const int targetQubit) |
| Apply the single-qubit S gate. More... | |
| void | tGate (MultiQubit multiQubit, const int targetQubit) |
| Apply the single-qubit T gate. More... | |
| int | validateMatrixIsUnitary (ComplexMatrix2 u) |
| int | validateAlphaBeta (Complex alpha, Complex beta) |
| int | validateUnitVector (REAL ux, REAL uy, REAL uz) |
| void | QuESTSeedRandomDefault () |
| Seed the Mersenne Twister used for random number generation in the QuEST environment with an example defualt seed. More... | |
| void | QuESTSeedRandom (unsigned long int *seedArray, int numSeeds) |
| numSeeds <= 64 More... | |
| unsigned long int | hashString (char *str) |
Variables | |
| const char * | errorCodes [] |
The core of the QuEST Library.
Definition in file QuEST.cpp.
| void controlledRotateAroundAxis | ( | MultiQubit | multiQubit, |
| const int | controlQubit, | ||
| const int | targetQubit, | ||
| REAL | angle, | ||
| Vector | axis | ||
| ) |
Applies a controlled rotation by a given angle around a given vector on the Bloch-sphere.
The vector must not be zero (else an error is thrown), but needn't be unit magnitude.
For angle
and axis vector
, applies
to states where the target qubit is 1 (
is the vector of Pauli matrices).
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | controlQubit | qubit with value 1 in the rotated states |
| [in] | targetQubit | qubit to rotate |
| [in] | angle | angle by which to rotate in radians |
| [in] | axis | vector around which to rotate (can be non-unit; will be normalised) |
| exitWithError | if either controlQubit or targetQubit are outside [0, multiQubit.numQubits) or are equal or if axis is the zero vector |
Definition at line 122 of file QuEST.cpp.
References controlledCompactUnitary(), Complex::imag, Complex::real, Vector::x, Vector::y, and Vector::z.
Referenced by controlledRotateX(), controlledRotateY(), and controlledRotateZ().
| void controlledRotateX | ( | MultiQubit | multiQubit, |
| const int | controlQubit, | ||
| const int | targetQubit, | ||
| REAL | angle | ||
| ) |
Applies a controlled rotation by a given angle around the X-axis of the Bloch-sphere.
The target qubit is rotated in states where the control qubit has value 1.
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | controlQubit | qubit which has value 1 in the rotated states |
| [in] | tagretQubit | qubit to rotate |
| [in] | angle | angle by which to rotate the target qubit in radians |
| exitWithError | if either controlQubit or targetQubit are outside [0, multiQubit.numQubits) or are equal. |
Definition at line 135 of file QuEST.cpp.
References controlledRotateAroundAxis().
| void controlledRotateY | ( | MultiQubit | multiQubit, |
| const int | controlQubit, | ||
| const int | targetQubit, | ||
| REAL | angle | ||
| ) |
Applies a controlled rotation by a given angle around the Y-axis of the Bloch-sphere.
The target qubit is rotated in states where the control qubit has value 1.
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | controlQubit | qubit which has value 1 in the rotated states |
| [in] | tagretQubit | qubit to rotate |
| [in] | angle | angle by which to rotate the target qubit in radians |
| exitWithError | if either controlQubit or targetQubit are outside [0, multiQubit.numQubits) or are equal. |
Definition at line 141 of file QuEST.cpp.
References controlledRotateAroundAxis().
| void controlledRotateZ | ( | MultiQubit | multiQubit, |
| const int | controlQubit, | ||
| const int | targetQubit, | ||
| REAL | angle | ||
| ) |
Applies a controlled rotation by a given angle around the Z-axis of the Bloch-sphere.
The target qubit is rotated in states where the control qubit has value 1.
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | controlQubit | qubit which has value 1 in the rotated states |
| [in] | tagretQubit | qubit to rotate |
| [in] | angle | angle by which to rotate the target qubit in radians |
| exitWithError | if either controlQubit or targetQubit are outside [0, multiQubit.numQubits) or are equal. |
Definition at line 147 of file QuEST.cpp.
References controlledRotateAroundAxis().
| unsigned long int hashString | ( | char * | str | ) |
Definition at line 238 of file QuEST.cpp.
Referenced by QuESTSeedRandomDefault().
| void QuESTSeedRandom | ( | unsigned long int * | seedArray, |
| int | numSeeds | ||
| ) |
numSeeds <= 64
Seed the Mersenne Twister used for random number generation in the QuEST environment with a user defined seed.
Definition at line 231 of file QuEST.cpp.
References init_by_array().
| void QuESTSeedRandomDefault | ( | void | ) |
Seed the Mersenne Twister used for random number generation in the QuEST environment with an example defualt seed.
This default seeding function uses the mt19937 init_by_array function with three keys – time, pid and hostname. Subsequent calls to mt19937 genrand functions will use this seeding. For a multi process code, the same seed is given to all process, therefore this seeding is only appropriate to use for functions such as measure where all processes require the same random value.
For more information about the MT, see http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
Definition at line 206 of file QuEST.cpp.
References hashString(), and init_by_array().
| void reportMultiQubitParams | ( | MultiQubit | multiQubit | ) |
Report metainformation about a set of qubits: number of qubits, number of probability amplitudes.
| [in,out] | multiQubit | object representing the set of qubits |
| [in] | env | object representing the execution environment (local, multinode etc) |
Definition at line 80 of file QuEST.cpp.
References MultiQubit::chunkId, MultiQubit::numChunks, and MultiQubit::numQubits.
| void reportState | ( | MultiQubit | multiQubit | ) |
Print the current state vector of probability amplitudes for a set of qubits to file.
File format:
real, imag realComponent1, imagComponent1 realComponent2, imagComponent2 ... realComponentN, imagComponentN
File naming convention:
For each node that the program runs on, a file 'state_rank_[node_rank].csv' is generated. If there is more than one node, ranks after the first do not include the header
real, imag
so that files are easier to combine.
| [in,out] | multiQubit | object representing the set of qubits |
Definition at line 62 of file QuEST.cpp.
References MultiQubit::chunkId, ComplexArray::imag, MultiQubit::numAmps, ComplexArray::real, and MultiQubit::stateVec.
| void rotateAroundAxis | ( | MultiQubit | multiQubit, |
| const int | rotQubit, | ||
| REAL | angle, | ||
| Vector | unitAxis | ||
| ) |
Rotate a single qubit by a given angle around a given vector on the Bloch-sphere.
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | rotQubit | qubit to rotate |
| [in] | angle | angle by which to rotate in radians |
| [in] | axis | vector around which to rotate |
| exitWithError | if rotQubit is outside [0, multiQubit.numQubits), or if axis is the zero vector |
Definition at line 91 of file QuEST.cpp.
References compactUnitary(), Complex::imag, Complex::real, Vector::x, Vector::y, and Vector::z.
Referenced by rotateX(), rotateY(), and rotateZ().
| void rotateX | ( | MultiQubit | multiQubit, |
| const int | rotQubit, | ||
| REAL | angle | ||
| ) |
Rotate a single qubit by a given angle around the X-axis of the Bloch-sphere.
For angle
, applies
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | rotQubit | qubit to rotate |
| [in] | angle | angle by which to rotate in radians |
| exitWithError | if rotQubit is outside [0, multiQubit.numQubits). |
Definition at line 104 of file QuEST.cpp.
References rotateAroundAxis().
| void rotateY | ( | MultiQubit | multiQubit, |
| const int | rotQubit, | ||
| REAL | angle | ||
| ) |
Rotate a single qubit by a given angle around the Y-axis of the Bloch-sphere.
For angle
, applies
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | rotQubit | qubit to rotate |
| [in] | angle | angle by which to rotate in radians |
| exitWithError | if rotQubit is outside [0, multiQubit.numQubits). |
Definition at line 110 of file QuEST.cpp.
References rotateAroundAxis().
| void rotateZ | ( | MultiQubit | multiQubit, |
| const int | rotQubit, | ||
| REAL | angle | ||
| ) |
Rotate a single qubit by a given angle around the Z-axis of the Bloch-sphere (also known as a phase shift gate).
For angle
, applies
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | rotQubit | qubit to rotate |
| [in] | angle | angle by which to rotate in radians |
| exitWithError | if rotQubit is outside [0, multiQubit.numQubits). |
Definition at line 116 of file QuEST.cpp.
References rotateAroundAxis().
| void sGate | ( | MultiQubit | multiQubit, |
| const int | targetQubit | ||
| ) |
Apply the single-qubit S gate.
This is a rotation of
around the Z-axis on the Bloch sphere, or the unitary:
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | targetQubit | qubit to operate upon |
| exitWithError | if targetQubit is outside [0, multiQubit.numQubits) |
Definition at line 158 of file QuEST.cpp.
References phaseGate(), and S_GATE.
| void sigmaZ | ( | MultiQubit | multiQubit, |
| const int | targetQubit | ||
| ) |
Apply the single-qubit sigma-Z (also known as the Z, Pauli-Z or phase-flip) gate.
This is a rotation of
around the Z-axis (a phase shift) on the Bloch sphere. I.e.
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | targetQubit | qubit to operate on |
| exitWithError | if targetQubit is outside [0, multiQubit.numQubits). |
Definition at line 153 of file QuEST.cpp.
References phaseGate(), and SIGMA_Z.
| void tGate | ( | MultiQubit | multiQubit, |
| const int | targetQubit | ||
| ) |
Apply the single-qubit T gate.
This is a rotation of
around the Z-axis on the Bloch sphere, or the unitary:
| [in,out] | multiQubit | object representing the set of all qubits |
| [in] | targetQubit | qubit to operate upon |
| exitWithError | if targetQubit is outside [0, multiQubit.numQubits) |
Definition at line 163 of file QuEST.cpp.
References phaseGate(), and T_GATE.
| int validateMatrixIsUnitary | ( | ComplexMatrix2 | u | ) |
Definition at line 168 of file QuEST.cpp.
References Complex::imag, ComplexMatrix2::r0c0, ComplexMatrix2::r0c1, ComplexMatrix2::r1c0, ComplexMatrix2::r1c1, Complex::real, and REAL_EPS.
| const char* errorCodes[] |
1.8.14