Distributed QUEST for GPU
Functions | Variables
QuEST_internal.h File Reference

Internal functions used to implement the public facing API in qubits.h. More...

#include "QuEST_precision.h"

Go to the source code of this file.

Functions

void phaseGate (MultiQubit multiQubit, const int targetQubit, enum phaseGateType type)
 
REAL findProbabilityOfZero (MultiQubit multiQubit, const int measureQubit)
 Measure the probability of a specified qubit being in the zero state. More...
 
REAL measureInZero (MultiQubit multiQubit, const int measureQubit)
 Update the state vector to be consistent with measuring measureQubit=0. More...
 
int validateMatrixIsUnitary (ComplexMatrix2 u)
 
int validateAlphaBeta (Complex alpha, Complex beta)
 
int validateUnitVector (REAL ux, REAL uy, REAL uz)
 
void exitWithError (int errorCode, const char *func)
 
void QuESTAssert (int isValid, int errorCode, const char *func)
 
unsigned long int hashString (char *str)
 

Variables

const char * errorCodes []
 

Detailed Description

Internal functions used to implement the public facing API in qubits.h.

Do not call these functions directly.

Definition in file QuEST_internal.h.

Function Documentation

◆ exitWithError()

void exitWithError ( int  errorCode,
const char *  func 
)

◆ findProbabilityOfZero()

REAL findProbabilityOfZero ( MultiQubit  multiQubit,
const int  measureQubit 
)

Measure the probability of a specified qubit being in the zero state.

Parameters
[in]multiQubitobject representing the set of qubits
[in]measureQubitqubit to measure
Returns
probability of qubit measureQubit being zero

◆ hashString()

unsigned long int hashString ( char *  str)

Definition at line 238 of file QuEST.cpp.

Referenced by QuESTSeedRandomDefault().

238  {
239  unsigned long int hash = 5381;
240  int c;
241 
242  while ((c = *str++))
243  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
244 
245  return hash;
246 }

◆ measureInZero()

REAL measureInZero ( MultiQubit  multiQubit,
const int  measureQubit 
)

Update the state vector to be consistent with measuring measureQubit=0.

Measure in Zero performs an irreversible change to the state vector: it updates the vector according to the event that a zero have been measured on the qubit indicated by measureQubit (where his label starts from 0, of course). It achieves this by setting all inconsistent amplitudes to 0 and then renormalising based on the total probability of measuring measureQubit=0. It then returns the probability of making this measurement.

Parameters
[in,out]multiQubitobject representing the set of qubits
[in]measureQubitqubit to measure
Returns
probability of qubit measureQubit being zero

◆ phaseGate()

void phaseGate ( MultiQubit  multiQubit,
const int  targetQubit,
enum phaseGateType  type 
)

Referenced by sGate(), sigmaZ(), and tGate().

◆ QuESTAssert()

void QuESTAssert ( int  isValid,
int  errorCode,
const char *  func 
)

◆ validateAlphaBeta()

int validateAlphaBeta ( Complex  alpha,
Complex  beta 
)

Definition at line 193 of file QuEST.cpp.

References Complex::imag, Complex::real, and REAL_EPS.

193  {
194  if ( fabs(alpha.real*alpha.real
195  + alpha.imag*alpha.imag
196  + beta.real*beta.real
197  + beta.imag*beta.imag - 1) > REAL_EPS ) return 0;
198  else return 1;
199 }
REAL imag
Definition: QuEST.h:29
REAL real
Definition: QuEST.h:28
#define REAL_EPS

◆ validateMatrixIsUnitary()

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.

168  {
169 
170  if ( fabs(u.r0c0.real*u.r0c0.real
171  + u.r0c0.imag*u.r0c0.imag
172  + u.r1c0.real*u.r1c0.real
173  + u.r1c0.imag*u.r1c0.imag - 1) > REAL_EPS ) return 0;
174  // check
175  if ( fabs(u.r0c1.real*u.r0c1.real
176  + u.r0c1.imag*u.r0c1.imag
177  + u.r1c1.real*u.r1c1.real
178  + u.r1c1.imag*u.r1c1.imag - 1) > REAL_EPS ) return 0;
179 
180  if ( fabs(u.r0c0.real*u.r0c1.real
181  + u.r0c0.imag*u.r0c1.imag
182  + u.r1c0.real*u.r1c1.real
183  + u.r1c0.imag*u.r1c1.imag) > REAL_EPS ) return 0;
184 
185  if ( fabs(u.r0c1.real*u.r0c0.imag
186  - u.r0c0.real*u.r0c1.imag
187  + u.r1c1.real*u.r1c0.imag
188  - u.r1c0.real*u.r1c1.imag) > REAL_EPS ) return 0;
189 
190  return 1;
191 }
Complex r1c1
Definition: QuEST.h:37
REAL imag
Definition: QuEST.h:29
REAL real
Definition: QuEST.h:28
Complex r0c0
Definition: QuEST.h:36
Complex r1c0
Definition: QuEST.h:37
#define REAL_EPS
Complex r0c1
Definition: QuEST.h:36

◆ validateUnitVector()

int validateUnitVector ( REAL  ux,
REAL  uy,
REAL  uz 
)

Definition at line 201 of file QuEST.cpp.

References REAL_EPS.

201  {
202  if ( fabs(sqrt(ux*ux + uy*uy + uz*uz) - 1) > REAL_EPS ) return 0;
203  else return 1;
204 }
#define REAL_EPS

Variable Documentation

◆ errorCodes

const char* errorCodes[]

Definition at line 24 of file QuEST.cpp.