![]() |
The Quantum Exact Simulation Toolkit v4.0.0
|
Utilities for testing QuEST's deprecated v3 API functions. More...
Typedefs | |
typedef vector< vector< qcomp > > | QMatrix |
typedef vector< qcomp > | QVector |
Functions | |
void | applyReferenceMatrix (QMatrix &state, int *ctrls, int numCtrls, int *targs, int numTargs, QMatrix op) |
void | applyReferenceMatrix (QMatrix &state, int *targs, int numTargs, QMatrix op) |
void | applyReferenceMatrix (QVector &state, int *ctrls, int numCtrls, int *targs, int numTargs, QMatrix op) |
void | applyReferenceMatrix (QVector &state, int *targs, int numTargs, QMatrix op) |
void | applyReferenceOp (QMatrix &state, int *ctrls, int numCtrls, int *targs, int numTargs, QMatrix op) |
void | applyReferenceOp (QMatrix &state, int *ctrls, int numCtrls, int targ1, int targ2, QMatrix op) |
void | applyReferenceOp (QMatrix &state, int *ctrls, int numCtrls, int target, QMatrix op) |
void | applyReferenceOp (QMatrix &state, int *targs, int numTargs, QMatrix op) |
void | applyReferenceOp (QMatrix &state, int ctrl, int *targs, int numTargs, QMatrix op) |
void | applyReferenceOp (QMatrix &state, int ctrl, int targ, QMatrix op) |
void | applyReferenceOp (QMatrix &state, int ctrl, int targ1, int targ2, QMatrix op) |
void | applyReferenceOp (QMatrix &state, int targ, QMatrix op) |
void | applyReferenceOp (QVector &state, int *ctrls, int numCtrls, int *targs, int numTargs, QMatrix op) |
void | applyReferenceOp (QVector &state, int *ctrls, int numCtrls, int targ1, int targ2, QMatrix op) |
void | applyReferenceOp (QVector &state, int *ctrls, int numCtrls, int target, QMatrix op) |
void | applyReferenceOp (QVector &state, int *targs, int numTargs, QMatrix op) |
void | applyReferenceOp (QVector &state, int ctrl, int *targs, int numTargs, QMatrix op) |
void | applyReferenceOp (QVector &state, int ctrl, int targ, QMatrix op) |
void | applyReferenceOp (QVector &state, int ctrl, int targ1, int targ2, QMatrix op) |
void | applyReferenceOp (QVector &state, int targ, QMatrix op) |
bool | areEqual (QMatrix a, QMatrix b) |
bool | areEqual (Qureg qureg, QMatrix matr) |
bool | areEqual (Qureg qureg, QMatrix matr, qreal precision) |
bool | areEqual (Qureg qureg, QVector vec) |
bool | areEqual (Qureg qureg, QVector vec, qreal precision) |
bool | areEqual (Qureg qureg1, Qureg qureg2) |
bool | areEqual (Qureg qureg1, Qureg qureg2, qreal precision) |
bool | areEqual (QVector a, QVector b) |
bool | areEqual (QVector vec, qreal *reals) |
bool | areEqual (QVector vec, qreal *reals, qreal *imags) |
void | assertQuregAndRefInDebugState (Qureg qureg, QMatrix ref) |
void | assertQuregAndRefInDebugState (Qureg qureg, QVector ref) |
CatchGen< int * > | bitsets (int numBits) |
unsigned int | calcLog2 (long unsigned int res) |
void | deleteFilesWithPrefixSynch (char *prefix) |
QMatrix | getConjugateTranspose (QMatrix a) |
QVector | getDFT (QVector in) |
QVector | getDFT (QVector in, int *targs, int numTargs) |
QMatrix | getExponentialOfDiagonalMatrix (QMatrix a) |
QMatrix | getExponentialOfPauliMatrix (qreal angle, QMatrix a) |
QMatrix | getFullOperatorMatrix (int *ctrls, int numCtrls, int *targs, int numTargs, QMatrix op, int numQubits) |
QMatrix | getIdentityMatrix (size_t dim) |
QMatrix | getKetBra (QVector ket, QVector bra) |
QMatrix | getKroneckerProduct (QMatrix a, QMatrix b) |
QVector | getKroneckerProduct (QVector b, QVector a) |
QVector | getMatrixDiagonal (QMatrix matr) |
QMatrix | getMixedDensityMatrix (vector< qreal > probs, vector< QVector > states) |
QVector | getNormalised (QVector vec) |
QMatrix | getPureDensityMatrix (QVector state) |
qcomp | getRandomComplex () |
QMatrix | getRandomDensityMatrix (int numQb) |
int | getRandomInt (int min, int max) |
vector< QMatrix > | getRandomKrausMap (int numQb, int numOps) |
vector< QVector > | getRandomOrthonormalVectors (int numQb, int numStates) |
vector< qreal > | getRandomProbabilities (int numProbs) |
QMatrix | getRandomPureDensityMatrix (int numQb) |
QMatrix | getRandomQMatrix (int dim) |
QVector | getRandomQVector (int dim) |
qreal | getRandomReal (qreal min, qreal max) |
QVector | getRandomStateVector (int numQb) |
QMatrix | getRandomUnitary (int numQb) |
QMatrix | getSwapMatrix (int qb1, int qb2, int numQb) |
long long int | getTwosComplement (long long int decimal, int numBits) |
long long int | getUnsigned (long long int twosComp, int numBits) |
long long int | getValueOfTargets (long long int ind, int *targs, int numTargs) |
QMatrix | getZeroMatrix (size_t dim) |
CatchGen< pauliOpType * > | pauliseqs (int numPaulis) |
CatchGen< int * > | sequences (int base, int numDigits) |
void | setRandomDiagPauliHamil (PauliHamil hamil, int numQubits) |
void | setRandomPauliSum (PauliHamil hamil, int numQubits) |
void | setRandomPauliSum (qreal *coeffs, pauliOpType *codes, int numQubits, int numTerms) |
void | setRandomTargets (int *targs, int numTargs, int numQb) |
void | setRandomTargets (vector< int > &targs, int numQb) |
void | setRandomTestStateSeeds () |
void | setSubMatrix (QMatrix &dest, QMatrix sub, size_t r, size_t c) |
void | setUniqueFilename (char *outFn, int maxlen, char *prefix) |
CatchGen< int * > | sublists (CatchGen< int > &&gen, int numSamps, const int *exclude, int numExclude) |
CatchGen< int * > | sublists (CatchGen< int > &&gen, int numSamps, int excluded) |
CatchGen< int * > | sublists (CatchGen< int > &&gen, int sublen) |
CatchGen< int * > | sublists (int *list, int len, int sublen) |
ComplexMatrix2 | toComplexMatrix2 (QMatrix qm) |
ComplexMatrix4 | toComplexMatrix4 (QMatrix qm) |
void | toComplexMatrixN (QMatrix qm, ComplexMatrixN cm) |
QMatrix | toDiagonalQMatrix (QVector vec) |
QMatrix | toQMatrix (CompMatr src) |
QMatrix | toQMatrix (CompMatr1 src) |
QMatrix | toQMatrix (CompMatr2 src) |
QMatrix | toQMatrix (DiagMatr matr) |
QMatrix | toQMatrix (FullStateDiagMatr matr) |
QMatrix | toQMatrix (PauliHamil hamil) |
QMatrix | toQMatrix (PauliStrSum sum) |
QMatrix | toQMatrix (qreal *coeffs, pauliOpType *paulis, int numQubits, int numTerms) |
QMatrix | toQMatrix (Qureg qureg) |
void | toQureg (Qureg qureg, QMatrix mat) |
void | toQureg (Qureg qureg, QVector vec) |
QVector | toQVector (DiagMatr op) |
QVector | toQVector (FullStateDiagMatr op) |
QVector | toQVector (Qureg qureg) |
void | writeToFileSynch (char *fn, const string &contents) |
Utilities for testing QuEST's deprecated v3 API functions.
typedef vector<vector<qcomp> > QMatrix |
A complex square matrix. Should be initialised with getZeroMatrix(). These have all the natural linear-algebra operator overloads, including left-multiplication onto a vector.
This data-structure is not partitioned between nodes in distributed mode. That is, every node has a complete copy, allowing for safe comparisons.
Definition at line 60 of file test_utilities.hpp.
typedef vector<qcomp> QVector |
A complex vector, which can be zero-initialised with QVector(numAmps). These have all the natural linear-algebra operator overloads.
This data-structure is not partitioned between nodes in distributed mode. That is, every node has a complete copy, allowing for safe comparisons.
Definition at line 71 of file test_utilities.hpp.
void applyReferenceMatrix | ( | QMatrix & | state, |
int * | ctrls, | ||
int | numCtrls, | ||
int * | targs, | ||
int | numTargs, | ||
QMatrix | op ) |
Modifies the density matrix state
to be the result of left-multiplying the multi-target operator matrix op
, with the specified control and target qubits (in ctrls
and targs
respectively). Here, op
is treated like a simple matrix and is hence left-multiplied onto the state once.
Definition at line 997 of file test_utilities.cpp.
Modifies the density matrix state
to be the result of left-multiplying the multi-target operator matrix op
, with the target qubits (assuming no control qubits). Here, op
is treated like a simple matrix and is hence left-multiplied onto the state once.
Definition at line 1005 of file test_utilities.cpp.
void applyReferenceMatrix | ( | QVector & | state, |
int * | ctrls, | ||
int | numCtrls, | ||
int * | targs, | ||
int | numTargs, | ||
QMatrix | op ) |
Modifies the state-vector state
to be the result of left-multiplying the multi-target operator matrix op
, with the specified control and target qubits (in ctrls
and targs
respectively). This is an alias of applyReferenceOp(), since operators are always left-multiplied as matrices onto state-vectors.
Definition at line 985 of file test_utilities.cpp.
Referenced by applyReferenceMatrix(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Modifies the state-vector state
to be the result of left-multiplying the multi-target operator matrix op
, with the specified target qubits (assuming no control qubits). T
Definition at line 991 of file test_utilities.cpp.
void applyReferenceOp | ( | QMatrix & | state, |
int * | ctrls, | ||
int | numCtrls, | ||
int * | targs, | ||
int | numTargs, | ||
QMatrix | op ) |
Modifies the density matrix state
to be the result of applying the multi-target operator matrix op
, with the specified control and target qubits (in ctrls
and targs
respectively). This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]
even if op
is not unitary (which is useful for applying Kraus operators).
op
must be a 2^numTargs-by-2^
. Furthermore, every element of numTargs
matrixtargs
must not appear in ctrls
(and vice-versa), though this is not explicitly checked. Elements of targs
and ctrls
should be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multipling it to state
, then right-multiplying its conjugate transpose onto the result.
Definition at line 928 of file test_utilities.cpp.
void applyReferenceOp | ( | QMatrix & | state, |
int * | ctrls, | ||
int | numCtrls, | ||
int | targ1, | ||
int | targ2, | ||
QMatrix | op ) |
Modifies the density matrix state
to be the result of applying the two-target operator matrix op
, with the specified control qubits (in ctrls
). This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]
even if op
is not unitary (which is useful for applying Kraus operators).
op
must be a 4-by-4 matrix. Both targ1
and targ2
must not appear in ctrls
, though this is not explicitly checked. Elements of ctrls
, and targ1
and targ2
, should be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multipling it to state
, then right-multiplying its conjugate transpose onto the result.
Definition at line 936 of file test_utilities.cpp.
Modifies the density matrix state
to be the result of applying the single-target operator matrix op
, with the specified control qubits (in ctrls
). This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]
even if op
is not unitary (which is useful for applying Kraus operators).
op
must be a 2-by-2 matrix. target
must not appear in ctrls
, though this is not explicitly checked.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multipling it to state
, then right-multiplying its conjugate transpose onto the result.
Definition at line 942 of file test_utilities.cpp.
Modifies the density matrix state
to be the result of applying the multi-target operator matrix op
, with no control qubits. This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]
even if op
is not unitary (which is useful for applying Kraus operators).
op
must be a 2^numTargs-by-2^
. Every element in numTargs
matrixtargs
should be unique, though this is not explicitly checked.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multipling it to state
, then right-multiplying its conjugate transpose onto the result.
Definition at line 948 of file test_utilities.cpp.
Modifies the density matrix state
to be the result of applying the multi-target operator matrix op
, with a single control qubit ctrl
. This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]
even if op
is not unitary (which is useful for applying Kraus operators).
op
must be a 2^numTargs-by-2^
, and numTargs
matrixctrl
must not appear in targs
(though this is not explicitly checked).
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multipling it to state
, then right-multiplying its conjugate transpose onto the result.
Definition at line 960 of file test_utilities.cpp.
Modifies the density matrix state
to be the result of applying the single-control single-target operator matrix op
. This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]
even if op
is not unitary (which is useful for applying Kraus operators).
op
must be a 2-by-2 matrix, and ctrl
and targ
should be different.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multipling it to state
, then right-multiplying its conjugate transpose onto the result.
Definition at line 953 of file test_utilities.cpp.
Modifies the density matrix state
to be the result of applying the two-target operator matrix op
, with a single control qubit ctrl
. This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]
even if op
is not unitary (which is useful for applying Kraus operators).
op
must be a 4-by-4 matrix, and ctrl
, targ1
and targ2
must be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multipling it to state
, then right-multiplying its conjugate transpose onto the result.
Definition at line 966 of file test_utilities.cpp.
Modifies the density matrix state
to be the result of applying the single-target operator matrix op
, with no control qubit. This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]
even if op
is not unitary (which is useful for applying Kraus operators).
op
must be a 2-by-2 matrix.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multipling it to state
, then right-multiplying its conjugate transpose onto the result.
Definition at line 973 of file test_utilities.cpp.
void applyReferenceOp | ( | QVector & | state, |
int * | ctrls, | ||
int | numCtrls, | ||
int * | targs, | ||
int | numTargs, | ||
QMatrix | op ) |
Modifies the state-vector state
to be the result of applying the multi-target operator matrix op
, with the specified control and target qubits (in ctrls
and targs
respectively). This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \]
even if op
is not unitary.
op
must be a 2^numTargs-by-2^
. Furthermore, every element of numTargs
matrixtargs
must not appear in ctrls
(and vice-versa), though this is not explicitly checked. Elements of targs
and ctrls
should be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multiplying it onto state
.
Definition at line 872 of file test_utilities.cpp.
Referenced by applyReferenceMatrix(), applyReferenceMatrix(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), applyReferenceOp(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
void applyReferenceOp | ( | QVector & | state, |
int * | ctrls, | ||
int | numCtrls, | ||
int | targ1, | ||
int | targ2, | ||
QMatrix | op ) |
Modifies the state-vector state
to be the result of applying the two-target operator matrix op
, with the specified control qubits (in ctrls
). This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \]
even if op
is not unitary.
op
must be a 4-by-4 matrix. Furthermore, ctrls
, targ1
and targ2
should all be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multiplying it onto state
.
Definition at line 879 of file test_utilities.cpp.
Modifies the state-vector state
to be the result of applying the single-target operator matrix op
, with the specified control qubits (in ctrls
). This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \]
even if op
is not unitary.
op
must be a 2-by-2 matrix. Furthermore, elements in ctrls
and target
should all be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multiplying it onto state
.
Definition at line 885 of file test_utilities.cpp.
Modifies the state-vector state
to be the result of applying the multi-target operator matrix op
, with no contorl qubits. This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \]
even if op
is not unitary.
op
must be a 2^numTargs-by-2^
. Furthermore, elements in numTargs
matrixtargs
should be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multiplying it onto state
.
Definition at line 891 of file test_utilities.cpp.
Modifies the state-vector state
to be the result of applying the multi-target operator matrix op
, with a single control qubit (ctrl
) This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \]
even if op
is not unitary.
op
must be a 2^numTargs-by-2^
. Furthermore, elements in numTargs
matrixtargs
and ctrl
should be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multiplying it onto state
.
Definition at line 903 of file test_utilities.cpp.
Modifies the state-vector state
to be the result of applying the single-target operator matrix op
, with a single control qubit (ctrl
). This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \]
even if op
is not unitary.
op
must be a 2-by-2 matrix. Furthermore, ctrl
and targ
must be different.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multiplying it onto state
.
Definition at line 896 of file test_utilities.cpp.
Modifies the state-vector state
to be the result of applying the two-target operator matrix op
, with a single control qubit (ctrl
). This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \]
even if op
is not unitary.
op
must be a 4-by-4 matrix. Furthermore, ctrl
, targ1
and targ2
should all be unique.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multiplying it onto state
.
Definition at line 909 of file test_utilities.cpp.
Modifies the state-vector state
to be the result of applying the single-target operator matrix op
, with no contorl qubits. This updates state
under
\[ \text{state} \to \text{op} \, \text{state} \]
even if op
is not unitary.
op
must be a 2-by-2 matrix.
This function works by computing getFullOperatorMatrix() from the given arguments, and left-multiplying it onto state
.
Definition at line 916 of file test_utilities.cpp.
Returns true if the absolute value of the difference between every amplitude in matrices a
and b
is less than REAL_EPS
.
Definition at line 524 of file test_utilities.cpp.
Performs a hardware-agnostic comparison of density-matrix qureg
to matr
, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision. This function demands qureg
is a density matrix, and that qureg
and matr
have equal dimensions.
In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.
Definition at line 1139 of file test_utilities.cpp.
Performs a hardware-agnostic comparison of density-matrix qureg
to matr
, checking whether the difference between the real and imaginary components of every amplitude is smaller than precision
. This function demands qureg
is a density matrix, and that qureg
and matr
have equal dimensions.
In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.
Definition at line 1080 of file test_utilities.cpp.
Performs a hardware-agnostic comparison of state-vector qureg
to vec
, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision. This function demands qureg
is a state-vector, and that qureg
and vec
have the same number of amplitudes.
In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.
Definition at line 1076 of file test_utilities.cpp.
Performs a hardware-agnostic comparison of state-vector qureg
to vec
, checking whether the difference between the real and imaginary components of every amplitude is smaller than precision
. This function demands qureg
is a state-vector, and that qureg
and vec
have the same number of amplitudes.
In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.
Definition at line 1036 of file test_utilities.cpp.
Performs a hardware-agnostic comparison of the given quregs, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision. This function demands that qureg1
and qureg2
are of the same type (i.e. both state-vectors or both density matrices), and of an equal number of qubits.
In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.
Definition at line 1032 of file test_utilities.cpp.
Performs a hardware-agnostic comparison of the given quregs, checking whether the difference between the real and imaginary components of every amplitude is smaller than precision
. This function demands that qureg1
and qureg2
are of the same type (i.e. both state-vectors or both density matrices), and of an equal number of qubits.
In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.
Definition at line 1011 of file test_utilities.cpp.
Returns true if the absolute value of the difference between every amplitude in vectors a
and b
is less than REAL_EPS
.
Definition at line 515 of file test_utilities.cpp.
Referenced by areEqual(), areEqual(), areEqual(), assertQuregAndRefInDebugState(), assertQuregAndRefInDebugState(), getRandomKrausMap(), getRandomUnitary(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
bool areEqual | ( | QVector | vec, |
qreal * | reals ) |
Returns true if the absolute value of the difference between every element in vec
(which must be strictly real) and those implied by reals
, is less than REAL_EPS
.
Definition at line 1157 of file test_utilities.cpp.
bool areEqual | ( | QVector | vec, |
qreal * | reals, | ||
qreal * | imags ) |
Returns true if the absolute value of the difference between every element in vec
and those implied by reals
and imags
, is less than REAL_EPS
.
Definition at line 1143 of file test_utilities.cpp.
Asserts the given density qureg and reference agree, and are properly initialised in the debug state. Assertion uses the DEMAND() macro, calling Catch2's FAIL() if unsatisfied, so does not contribute toward unit test statistics. This should be called within every PREPARE_TEST macro, to ensure that the test states themselves are initially correct, and do not accidentally agree by (e.g.) being all-zero.
Definition at line 233 of file test_utilities.cpp.
Asserts the given statevector qureg and reference agree, and are properly initialised in the debug state. Assertion uses the DEMAND() macro, calling Catch2's FAIL() if unsatisfied, so does not contribute toward unit test statistics. This should be called within every PREPARE_TEST macro, to ensure that the test states themselves are initially correct, and do not accidentally agree by (e.g.) being all-zero.
Definition at line 219 of file test_utilities.cpp.
CatchGen< int * > bitsets | ( | int | numBits | ) |
Returns a Catch2 generator of every numBits-length
bit-set, in increasing lexographic order, where left-most (zero index) bit is treated as LEAST significant (opposite typical convention). Note that the produced bitset must not be modified during generation.
This function can be used like
int* bits = GENERATE( bitsets(3) );
to produce {0,0,0}, {1,0,0}, {0,1,0}, {1,1,0}, {0,0,1}, {1,0,1}, {0,1,1}, {1,1,1}.
Definition at line 1723 of file test_utilities.cpp.
Referenced by TEST_CASE().
unsigned int calcLog2 | ( | long unsigned int | res | ) |
Returns log2 of numbers which must be gauranteed to be 2^n
Definition at line 488 of file test_utilities.cpp.
Referenced by applyReferenceMatrix(), applyReferenceOp(), applyReferenceOp(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
void deleteFilesWithPrefixSynch | ( | char * | prefix | ) |
Deletes all files with filename starting with prefix. In distributed mode, the master node deletes while the other nodes wait until complete.
Definition at line 1543 of file test_utilities.cpp.
Returns the conjugate transpose of the complex square matrix a
Definition at line 291 of file linalg.cpp.
Referenced by applyReferenceOp(), getRandomKrausMap(), getRandomUnitary(), TEST_CASE(), and TEST_CASE().
Returns the discrete fourier transform of vector in
Definition at line 795 of file test_utilities.cpp.
Referenced by TEST_CASE(), and TEST_CASE().
Returns the discrete fourier transform of a sub-partition of the vector in.
Definition at line 843 of file test_utilities.cpp.
Returns the matrix exponential of a diagonal, square, complex matrix. This method explicitly checks that the passed matrix a
is diagonal.
Definition at line 336 of file linalg.cpp.
Referenced by TEST_CASE(), and TEST_CASE().
Returns the matrix exponential of a kronecker product of pauli matrices (or of any involutory matrices), with exponent factor (-i angle
/ 2). This method will not explicitly check that the passed matrix a
is kronecker product of involutory matrices, but will otherwise return an incorrect exponential.
Definition at line 348 of file linalg.cpp.
Referenced by TEST_CASE(), and TEST_CASE().
QMatrix getFullOperatorMatrix | ( | int * | ctrls, |
int | numCtrls, | ||
int * | targs, | ||
int | numTargs, | ||
QMatrix | op, | ||
int | numQubits ) |
Takes a 2^numTargs-by-2^
numTargs
matrixop
and a returns a 2^numQubits-by-2^
where numQubits
matrixop
is controlled on the given ctrls
qubits. The union of {ctrls}
and {targs}
must be unique (though this is not explicitly checked), and every element must be >= 0 (not checked). The passed {ctrls}
and {targs}
arrays are unmodified.
This funciton works by first swapping {targs}
and {ctrls}
(via swap unitaries) to be strictly increasing {0,1,...}, building controlled(op
), tensoring it to the full Hilbert space, and then 'unswapping'. The returned matrix has form: swap1 ... swapN . controlled(op
) . swapN ... swap1
Definition at line 420 of file test_utilities.cpp.
Referenced by applyReferenceMatrix(), applyReferenceOp(), applyReferenceOp(), TEST_CASE(), and TEST_CASE().
QMatrix getIdentityMatrix | ( | size_t | dim | ) |
Returns a dim-by-dim identity matrix
Definition at line 30 of file qmatrix.cpp.
Referenced by getExponentialOfPauliMatrix(), getExponentialOfPauliMatrix(), getFullOperatorMatrix(), getRandomKrausMap(), getRandomUnitary(), getSwapMatrix(), and TEST_CASE().
Returns the matrix |ket><
with ith-jth element bra|
,ket(i)
conj(bra(j)
), since |ket><
sum_i a_i|i> sum_j b_j* <j| = sum_{ij} a_i b_j* |i><j|. The dimensions of bra and ket must agree, and the returned square complex matrix has dimensions size(bra) x size(bra).bra|
=
Definition at line 277 of file test_utilities.cpp.
Referenced by getPureDensityMatrix(), getRandomDensityMatrix(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Returns the kronecker product of a
and b
, where a
and b
are square but possibly differently-sized complex matrices.
Definition at line 523 of file linalg.cpp.
Referenced by getSwapMatrix(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Returns b (otimes) a. If b and a are state-vectors, the resulting kronecker product is the seperable state formed by joining the qubits in the state-vectors, producing |b>|a> (a is least significant)
Definition at line 251 of file test_utilities.cpp.
Referenced by getFullOperatorMatrix(), getSwapMatrix(), and toQMatrix().
Returns the diagonal vector of the given matrix
Definition at line 633 of file test_utilities.cpp.
Returns a mixed density matrix formed from mixing the given pure states, which are assumed normalised, but not necessarily orthogonal.
Definition at line 783 of file test_utilities.cpp.
Referenced by TEST_CASE(), and TEST_CASE().
Returns an L2-normalised copy of vec
, using Kahan summation for improved accuracy.
Definition at line 560 of file test_utilities.cpp.
Referenced by getRandomOrthonormalVectors(), and getRandomStateVector().
Returns a density matrix initialised into the given pure state
Definition at line 623 of file test_utilities.cpp.
Referenced by getMixedDensityMatrix(), getRandomPureDensityMatrix(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
qcomp getRandomComplex | ( | ) |
Returns a random complex number within the square closing (-1-i) and (1+i), from a distribution uniformly randomising the individual real and imaginary components in their domains.
Definition at line 107 of file random.cpp.
Referenced by getRandomQVector(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
QMatrix getRandomDensityMatrix | ( | int | numQb | ) |
Returns a random numQb-by-
matrix, from an undisclosed distribution, in a very mixed state. This function works by generating 2^numQb
densitynumQb
random pure states, and mixing them with random probabilities.
Definition at line 308 of file random.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
int getRandomInt | ( | int | min, |
int | max ) |
Returns a random integer between min
(inclusive) and max
(exclusive), from the uniform distribution. Demands that max
> min
.
Definition at line 90 of file random.cpp.
Referenced by setRandomPauliSum(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
vector< QMatrix > getRandomKrausMap | ( | int | numQb, |
int | numOps ) |
Returns a random Kraus map of #numOps
2^numQb-by-2^
, from an undisclosed distribution. Note this method is very simple and cannot generate all possible Kraus maps. It works by generating numQb
operatorsnumOps
random unitary matrices, and randomly re-normalising them, such that the sum of ops[j]^dagger ops[j] = 1
Definition at line 405 of file random.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
vector< QVector > getRandomOrthonormalVectors | ( | int | numQb, |
int | numStates ) |
Returns a list of random orthonormal complex vectors, from an undisclosed distribution.
Definition at line 756 of file test_utilities.cpp.
vector< qreal > getRandomProbabilities | ( | int | numProbs | ) |
Returns a list of random real scalars, each in [0, 1], which sum to unity.
Definition at line 160 of file random.cpp.
Referenced by getRandomDensityMatrix(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
QMatrix getRandomPureDensityMatrix | ( | int | numQb | ) |
Returns a random numQb-by-
matrix, from an undisclosed distribution, which is pure (corresponds to a random state-vector)numQb
density
Definition at line 326 of file random.cpp.
QMatrix getRandomQMatrix | ( | int | dim | ) |
Returns a dim-by-
matrix, where the real and imaginary value of each element are independently random, under the standard normal distribution (mean 0, standard deviation 1).dim
complex
Definition at line 495 of file test_utilities.cpp.
Referenced by getRandomUnitary(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
QVector getRandomQVector | ( | int | dim | ) |
Returns a dim-length
vector with random complex amplitudes in the square joining {-1-i, 1+i}, of an undisclosed distribution. The resulting vector is NOT L2-normalised.
Definition at line 552 of file test_utilities.cpp.
Referenced by getRandomStateVector(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
qreal getRandomReal | ( | qreal | min, |
qreal | max ) |
Returns a random real between min
(inclusive) and max
(exclusive), from the uniform distribution. Demands that max
> min
.
Definition at line 63 of file random.cpp.
Referenced by getRandomComplex(), getRandomInt(), getRandomInt(), getRandomKrausMap(), getRandomProbabilities(), setRandomDiagPauliHamil(), setRandomPauliSum(), setRandomPauliSum(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
QVector getRandomStateVector | ( | int | numQb | ) |
Returns a random numQb-length
L2-normalised state-vector from an undisclosed distribution. This function works by randomly generating each complex amplitude, then L2-normalising.
Definition at line 296 of file random.cpp.
Referenced by getRandomDensityMatrix(), getRandomOrthonormalVectors(), getRandomPureDensityMatrix(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
QMatrix getRandomUnitary | ( | int | numQb | ) |
Returns a uniformly random (under Haar) 2^numQb-by-2^
matrix. This function works by first generating a complex matrix where each element is independently random; the real and imaginary component thereof are independent standard normally-distributed (mean 0, standard-dev 1). Then, the matrix is orthonormalised via the Gram Schmidt algorithm. The resulting unitary matrix MAY be uniformly distributed under the Haar measure, but we make no assurance. This routine may return an identity matrix if it was unable to sufficiently precisely produce a unitary of the given size.numQb
unitary
Definition at line 348 of file random.cpp.
Referenced by getRandomKrausMap(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
QMatrix getSwapMatrix | ( | int | qb1, |
int | qb2, | ||
int | numQb ) |
Returns the 2^numQb-by-2^
matrix which swaps qubits numQb
unitaryqb1
and qb2
; the SWAP gate of not-necessarily-adjacent qubits. If qb1
== qb2
, returns the identity matrix.
Definition at line 28 of file evolve.cpp.
Referenced by getFullOperatorMatrix().
long long int getTwosComplement | ( | long long int | decimal, |
int | numBits ) |
Returns the two's complement signed encoding of the unsigned number decimal, which must be a number between 0 and 2^numBits (exclusive). The returned number lies in [-2^(numBits-1), 2^(numBits-1)-1]
Definition at line 1454 of file test_utilities.cpp.
long long int getUnsigned | ( | long long int | twosComp, |
int | numBits ) |
Return the unsigned value of a number, made of #numBits
bits, which under two's complement, encodes the signed number twosComp. The returned number lies in [0, 2^(numBits)-1]
Definition at line 1466 of file test_utilities.cpp.
long long int getValueOfTargets | ( | long long int | ind, |
int * | targs, | ||
int | numTargs ) |
Returns the integer value of the targeted sub-register for the given full state index ind
.
Definition at line 813 of file test_utilities.cpp.
Referenced by getDFT().
QMatrix getZeroMatrix | ( | size_t | dim | ) |
Returns a dim-by-dim square complex matrix, initialised to all zeroes.
Definition at line 18 of file qmatrix.cpp.
Referenced by getExponentialOfDiagonalMatrix(), getIdentityMatrix(), getKetBra(), getKroneckerProduct(), getMixedDensityMatrix(), getRandomDensityMatrix(), getRandomKrausMap(), getRandomQMatrix(), getRandomUnitary(), getSwapMatrix(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), toDiagonalQMatrix(), toQMatrix(), toQMatrix(), toQMatrix(), toQMatrix(), toQMatrix(), toQMatrix(), and toQMatrix().
CatchGen< pauliOpType * > pauliseqs | ( | int | numPaulis | ) |
Returns a Catch2 generator of every numPaulis-length
set of Pauli-matrix types (or base-4 integers). Generates in increasing lexographic order, where the left-most (zero index) pauli is treated as LEAST significant. Note that the sequence must not be modified during generation.
This function can be used like
pauliOpType* set = GENERATE( pauliseqs(2) );
to produce {I,I}, {X,I}, {Y,I}, {Z,I}, {I,X}, {X,X}, {Y,X}, {Z,X}, {I,Y}, {X,Y}, {Y,Y}, {Z,Y}, {I,Z}, {X,Z}, {Y,Z}, {Z,Z}/
Definition at line 1731 of file test_utilities.cpp.
CatchGen< int * > sequences | ( | int | base, |
int | numDigits ) |
Returns a Catch2 generator of every numDigits-length
sequence in the given base
, in increasing lexographic order, where left-most (zero index) bit is treated as LEAST significant (opposite typical convention). Note that the sequence must not be modified during generation.
This function can be used like
int base = 3; int numDigits = 2; int* seq = GENERATE_COPY( sequences(base, numDigits) );
to produce {0,0}, {1,0}, {2,0}, {0,1}, {1,1}, {2,1}, {0,2}, {1,2}, {2,2}.
Definition at line 1727 of file test_utilities.cpp.
void setRandomDiagPauliHamil | ( | PauliHamil | hamil, |
int | numQubits ) |
Populates hamil
with random coefficients and a random amount number of PAULI_I and PAULI_Z operators.
Definition at line 1390 of file test_utilities.cpp.
void setRandomPauliSum | ( | PauliHamil | hamil, |
int | numQubits ) |
Populates hamil
with random coefficients and pauli codes
Definition at line 1382 of file test_utilities.cpp.
void setRandomPauliSum | ( | qreal * | coeffs, |
pauliOpType * | codes, | ||
int | numQubits, | ||
int | numTerms ) |
Populates the coeffs
array with random qreals in (-5, 5), and populates codes
with random Pauli codes
Definition at line 1373 of file test_utilities.cpp.
Referenced by TEST_CASE().
void setRandomTargets | ( | int * | targs, |
int | numTargs, | ||
int | numQb ) |
Populates targs
with a random selection of numTargs
elements from [0,numQb-1
]. List targs
does not need to be initialised and its elements are overwritten.
Definition at line 1397 of file test_utilities.cpp.
Referenced by setRandomTargets(), TEST_CASE(), and TEST_CASE().
void setRandomTargets | ( | vector< int > & | targs, |
int | numQb ) |
Populates targs
with a random selection of elements from [0,numQb-1
]. List targs
does not need to be initialised and its elements are overwritten.
Definition at line 1414 of file test_utilities.cpp.
void setRandomTestStateSeeds | ( | ) |
Seed the C and C++ RNGs using hardware CSPRNG
Definition at line 39 of file random.cpp.
Modifies dest
by overwriting its submatrix (from top-left corner (r
, c
) to bottom-right corner (r
+ dest.size()
, c
+ dest.size()
) with the complete elements of sub. This demands that dest.size() >= sub.size() + max(r,c).
Definition at line 203 of file qmatrix.cpp.
Referenced by getFullOperatorMatrix(), getSwapMatrix(), TEST_CASE(), and TEST_CASE().
void setUniqueFilename | ( | char * | outFn, |
int | maxlen, | ||
char * | prefix ) |
Modifies the given diagonal matrix such that the diagonal elements which correspond to the coordinates in overrideInds are replaced with exp(i phase), as prescribed by overridePhases. This function assumes that the given registers are contiguous, are in order of increasing significance, and that the matrix is proportionately sized and structured to act on the space of all registers combined. Overrides can be repeated, and only the first encountered for a given index will be effected (much like applyMultiVarPhaseFuncOverrides()).
Definition at line 1526 of file test_utilities.cpp.
CatchGen< int * > sublists | ( | CatchGen< int > && | gen, |
int | numSamps, | ||
const int * | exclude, | ||
int | numExclude ) |
Returns a Catch2 generator of every length-sublen
sublist of the elements generated by gen
, which exclude all elements in exclude
, in increasing lexographic order. This generates every fixed-length combination of gen's
elements the nominated exclusions, and every permutation of each.
There is on need for the elements of exclude
to actually appear in those of gen
. sublen
must less than or equal to the number of elements in gen
, after the nominated exclusions.
Note that the sublist must not be modified, else further generation may break (QuEST's internal functions will indeed modify but restore the qubit index lists given to them, which is ok). Assumes list
contains no duplicates, otherwise the generated sublists may be duplicated.
This function can be used like
int sublen = 2; int exclude[2] = {3,4}; int* sublist = GENERATE_COPY( sublists(range(1,6), sublen, exclude, 2) );
to generate {1,2}, {1,5}, {2,1}, {2,5}, {5,1}, {5,2}
CatchGen< int * > sublists | ( | CatchGen< int > && | gen, |
int | numSamps, | ||
int | excluded ) |
Returns a Catch2 generator of every length-sublen
sublist of the elements generated by gen
which exclude element excluded
, in increasing lexographic order. This generates every fixed-length combination of gen's
elements the nominated exclusions, and every permutation of each.
sublen
must less than or equal to the number of elements in gen
, after the nominated exclusion. There is no need for excluded
to actually appear in the elements of gen
.
Note that the sublist must not be modified, else further generation may break (QuEST's internal functions will indeed modify but restore the qubit index lists given to them, which is ok). Assumes list
contains no duplicates, otherwise the generated sublists may be duplicated.
This function can be used like
int sublen = 2; int excluded = 1; int* sublist = GENERATE_COPY( sublists(range(1,4), sublen, excluded) );
to generate {2,3}, {3,2}.
CatchGen< int * > sublists | ( | CatchGen< int > && | gen, |
int | sublen ) |
Returns a Catch2 generator of every length-sublen
sublist of the elements generated by gen
, in increasing lexographic order. This generates every fixed-length combination of gen's
elements, and every permutation of each. Note that the produced sublist must not be modified, else further generation may break (QuEST's internal functions will indeed modify but restore the qubit index lists given to them, which is ok). Assumes list
contains no duplicates, otherwise the generated sublists may be duplicated.
This function can be used like
int sublen = 2; int* sublist = GENERATE_COPY( sublists(list, 4, sublen) );
to generate {1,2}, {1,3}, {1,4}, {2,1}, {2,3}, {2,4}, {3,1}, {3,2}, {3, 4}, {4,1}, {4,2}, {4, 3}.
CatchGen< int * > sublists | ( | int * | list, |
int | len, | ||
int | sublen ) |
Returns a Catch2 generator of every length-sublen
sublist of length-len
list
, in increasing lexographic order. This generates every fixed-length combination of the given list and every permutation of each. & If the sublist length is the full list length, this generator produces every permutation correctly. Note that the sublist must not be modified, else further & generation may break (QuEST's internal functions will indeed modify but restore the qubit index lists given to them, which is ok). Assumes list
contains no duplicates, otherwise the generated sublists may be duplicated.
This function can be used like
int list[4] = {1,2,3,4}; int sublen = 2; int* sublist = GENERATE_COPY( sublists(list, 4, sublen) );
to generate {1,2}, {1,3}, {1,4}, {2,1}, {2,3}, {2,4}, {3,1}, {3,2}, {3, 4}, {4,1}, {4,2}, {4, 3}.
Definition at line 1657 of file test_utilities.cpp.
ComplexMatrix2 toComplexMatrix2 | ( | QMatrix | qm | ) |
Returns a ComplexMatrix2
copy of QMatix qm
. Demands that qm
is a 2-by-2 matrix.
Definition at line 1177 of file test_utilities.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
ComplexMatrix4 toComplexMatrix4 | ( | QMatrix | qm | ) |
Returns a ComplexMatrix4
copy of QMatix qm
. Demands that qm
is a 4-by-4 matrix.
Definition at line 1183 of file test_utilities.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
void toComplexMatrixN | ( | QMatrix | qm, |
ComplexMatrixN | cm ) |
Populates the ComplexMatrixN with the contents of a QMatrix. In GPU-mode, this will then sync the elements ot the matrix's persistent GPU memory
Definition at line 1196 of file test_utilities.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Returns a diagonal complex matrix formed by the given vector
Definition at line 1477 of file test_utilities.cpp.
Returns a copy of the given matrix
Definition at line 1212 of file test_utilities.cpp.
Returns a copy of the given 2-by-2 matrix.
Definition at line 1202 of file test_utilities.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Returns a copy of the given 4-by-4 matrix.
Definition at line 1207 of file test_utilities.cpp.
Returns a dense matrix equivalent to the given diagonal
Definition at line 1323 of file test_utilities.cpp.
QMatrix toQMatrix | ( | FullStateDiagMatr | matr | ) |
Returns a dense matrix equivalent to the given diagonal
Definition at line 1315 of file test_utilities.cpp.
QMatrix toQMatrix | ( | PauliHamil | hamil | ) |
Returns a 2^N-by-2^
matrix form of the PauliHamilN
Hermitian
QMatrix toQMatrix | ( | PauliStrSum | sum | ) |
Returns a 2^N-by-2^
Z-basis matrix of the given complex-weighted sum of Pauli strings, where N is the number of non-Identity operators.N
Hermitian
QMatrix toQMatrix | ( | qreal * | coeffs, |
pauliOpType * | paulis, | ||
int | numQubits, | ||
int | numTerms ) |
Returns a 2^N-by-2^
matrix form of the specified weighted sum of Pauli productsN
Hermitian
Definition at line 1419 of file test_utilities.cpp.
Returns an equal-size copy of the given density matrix qureg
. In GPU mode, this function involves a copy of qureg
from GPU memory to RAM. In distributed mode, this involves an all-to-all broadcast of qureg
.
Definition at line 1218 of file test_utilities.cpp.
Initialises the density matrix qureg
to have the same amplitudes as mat
. Demands qureg
is a density matrix of equal dimensions to mat
. In GPU mode, this function involves a copy from RAM to GPU memory. This function has no communication cost in distributed mode.
Definition at line 1342 of file test_utilities.cpp.
Initialises the state-vector qureg
to have the same amplitudes as vec
. Demands qureg
is a state-vector of an equal size to vec
. In GPU mode, this function involves a copy from RAM to GPU memory. This function has no communication cost in distributed mode.
Definition at line 1330 of file test_utilities.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Returns a vector with the given diagonal's elements. In distributed mode, this involves an all-to-all broadcast of op
.
Definition at line 1288 of file test_utilities.cpp.
QVector toQVector | ( | FullStateDiagMatr | op | ) |
Returns a vector with the given diagonal's elements. In distributed mode, this involves an all-to-all broadcast of op
.
Definition at line 1293 of file test_utilities.cpp.
Returns an equal-size copy of the given state-vector qureg
. In GPU mode, this function involves a copy of qureg
from GPU memory to RAM. In distributed mode, this involves an all-to-all broadcast of qureg
.
Definition at line 1253 of file test_utilities.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and toQMatrix().
void writeToFileSynch | ( | char * | fn, |
const string & | contents ) |
Writes contents to the file with filename fn, which is created and/or overwritten. In distributed mode, the master node writes while the other nodes wait until complete.
Definition at line 1530 of file test_utilities.cpp.