QuEST_debug.h File Reference
#include "QuEST_precision.h"

Go to the source code of this file.

Functions

int compareStates (Qureg mq1, Qureg mq2, qreal precision)
 Return whether two given wavefunctions are equivalent within a given precision Global phase included in equivalence check. More...
 
void initStateDebug (Qureg qureg)
 Initialise the state vector of probability amplitudes to an (unphysical) state with each component of each probability amplitude a unique floating point value. More...
 
void initStateFromSingleFile (Qureg *qureg, char filename[200], QuESTEnv env)
 Initialises the wavefunction amplitudes according to those specified in a file. More...
 
void initStateOfSingleQubit (Qureg *qureg, int qubitId, int outcome)
 Initialise the state vector of probability amplitudes such that one qubit is set to 'outcome' and all other qubits are in an equal superposition of zero and one. More...
 
int QuESTPrecision (void)
 Return the precision of qreal for use in testing. More...
 
void setDensityAmps (Qureg qureg, qreal *reals, qreal *imags)
 Set elements in the underlying state vector represenation of a density matrix. More...
 

Detailed Description

Developer functions used for unit testing and debugging, which are not part of the public API. May contain functions that are incomplete or untested.

Author
Ania Brown

Definition in file QuEST_debug.h.

Function Documentation

◆ compareStates()

int compareStates ( Qureg  mq1,
Qureg  mq2,
qreal  precision 
)

Return whether two given wavefunctions are equivalent within a given precision Global phase included in equivalence check.

For debugging purposes.

Definition at line 1303 of file QuEST.c.

1303  {
1304  validateMatchingQuregDims(qureg1, qureg2, __func__);
1305  return statevec_compareStates(qureg1, qureg2, precision);
1306 }

References statevec_compareStates(), and validateMatchingQuregDims().

◆ initStateDebug()

void initStateDebug ( Qureg  qureg)

Initialise the state vector of probability amplitudes to an (unphysical) state with each component of each probability amplitude a unique floating point value.

For debugging processes

Parameters
[in,out]quregobject representing the set of qubits to be initialised

◆ initStateFromSingleFile()

void initStateFromSingleFile ( Qureg qureg,
char  filename[200],
QuESTEnv  env 
)

Initialises the wavefunction amplitudes according to those specified in a file.

For debugging purpsoses

Definition at line 1312 of file QuEST.c.

1312  {
1313  int success = statevec_initStateFromSingleFile(qureg, filename, env);
1314  validateFileOpened(success, filename, __func__);
1315 }

References statevec_initStateFromSingleFile(), and validateFileOpened().

◆ initStateOfSingleQubit()

void initStateOfSingleQubit ( Qureg qureg,
int  qubitId,
int  outcome 
)

Initialise the state vector of probability amplitudes such that one qubit is set to 'outcome' and all other qubits are in an equal superposition of zero and one.

Parameters
[in,out]quregobject representing the set of qubits to be initialised
[in]qubitIdid of qubit to set to state 'outcome'
[in]outcomevalue of qubit 'qubitId' to set

Definition at line 1317 of file QuEST.c.

1317  {
1318  validateStateVecQureg(*qureg, __func__);
1319  validateTarget(*qureg, qubitId, __func__);
1320  validateOutcome(outcome, __func__);
1321  statevec_initStateOfSingleQubit(qureg, qubitId, outcome);
1322 }

References statevec_initStateOfSingleQubit(), validateOutcome(), validateStateVecQureg(), and validateTarget().

◆ QuESTPrecision()

int QuESTPrecision ( void  )

Return the precision of qreal for use in testing.

◆ setDensityAmps()

void setDensityAmps ( Qureg  qureg,
qreal reals,
qreal imags 
)

Set elements in the underlying state vector represenation of a density matrix.

Not exposed in the public API as this requires an understanding of how the state vector is used to represent a density matrix. Currently can only be used to set all amps.

Definition at line 790 of file QuEST.c.

790  {
791  long long int numAmps = qureg.numAmpsTotal;
792  statevec_setAmps(qureg, 0, reals, imags, numAmps);
793 
794  qasm_recordComment(qureg, "Here, some amplitudes in the density matrix were manually edited.");
795 }

References Qureg::numAmpsTotal, qasm_recordComment(), and statevec_setAmps().

void validateTarget(Qureg qureg, int targetQubit, const char *caller)
void validateOutcome(int outcome, const char *caller)
void validateStateVecQureg(Qureg qureg, const char *caller)
void statevec_initStateOfSingleQubit(Qureg *qureg, int qubitId, int outcome)
Initialise the state vector of probability amplitudes such that one qubit is set to 'outcome' and all...
Definition: QuEST_cpu.c:1545
void validateFileOpened(int opened, char *fn, const char *caller)
void statevec_setAmps(Qureg qureg, long long int startInd, qreal *reals, qreal *imags, long long int numAmps)
Definition: QuEST_cpu.c:1237
void validateMatchingQuregDims(Qureg qureg1, Qureg qureg2, const char *caller)
void qasm_recordComment(Qureg qureg, char *comment,...)
Definition: QuEST_qasm.c:120
int statevec_initStateFromSingleFile(Qureg *qureg, char filename[200], QuESTEnv env)
Definition: QuEST_cpu.c:1625
long long int numAmpsTotal
Total number of amplitudes, which are possibly distributed among machines.
Definition: QuEST.h:215
int statevec_compareStates(Qureg mq1, Qureg mq2, qreal precision)
Definition: QuEST_cpu.c:1675