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 1573 of file QuEST.c.

1573  {
1574  validateMatchingQuregDims(qureg1, qureg2, __func__);
1575  return statevec_compareStates(qureg1, qureg2, precision);
1576 }

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 1582 of file QuEST.c.

1582  {
1583  int success = statevec_initStateFromSingleFile(qureg, filename, env);
1584  validateFileOpened(success, filename, __func__);
1585 }

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 1587 of file QuEST.c.

1587  {
1588  validateStateVecQureg(*qureg, __func__);
1589  validateTarget(*qureg, qubitId, __func__);
1590  validateOutcome(outcome, __func__);
1591  statevec_initStateOfSingleQubit(qureg, qubitId, outcome);
1592 }

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 1030 of file QuEST.c.

1030  {
1031  long long int numAmps = qureg.numAmpsTotal;
1032  statevec_setAmps(qureg, 0, reals, imags, numAmps);
1033 
1034  qasm_recordComment(qureg, "Here, some amplitudes in the density matrix were manually edited.");
1035 }

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:1611
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:1248
void validateMatchingQuregDims(Qureg qureg1, Qureg qureg2, const char *caller)
void qasm_recordComment(Qureg qureg, char *comment,...)
Definition: QuEST_qasm.c:121
int statevec_initStateFromSingleFile(Qureg *qureg, char filename[200], QuESTEnv env)
Definition: QuEST_cpu.c:1691
long long int numAmpsTotal
Total number of amplitudes, which are possibly distributed among machines.
Definition: QuEST.h:334
int statevec_compareStates(Qureg mq1, Qureg mq2, qreal precision)
Definition: QuEST_cpu.c:1741