#include "QuEST.h"
#include "QuEST_internal.h"
#include "QuEST_precision.h"
#include "mt19937ar.h"
#include "QuEST_cpu_internal.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <sys/types.h>
Go to the source code of this file.
Functions | |
QuESTEnv | createQuESTEnv (void) |
Create the QuEST execution environment. More... | |
void | densmatr_applyDiagonalOp (Qureg qureg, DiagonalOp op) |
Complex | densmatr_calcExpecDiagonalOp (Qureg qureg, DiagonalOp op) |
qreal | densmatr_calcFidelity (Qureg qureg, Qureg pureState) |
qreal | densmatr_calcHilbertSchmidtDistance (Qureg a, Qureg b) |
qreal | densmatr_calcInnerProduct (Qureg a, Qureg b) |
void | densmatr_calcProbOfAllOutcomes (qreal *retProbs, Qureg qureg, int *qubits, int numQubits) |
qreal | densmatr_calcProbOfOutcome (Qureg qureg, int measureQubit, int outcome) |
qreal | densmatr_calcPurity (Qureg qureg) |
qreal | densmatr_calcTotalProb (Qureg qureg) |
void | densmatr_initPureState (Qureg qureg, Qureg pureState) |
void | densmatr_mixDamping (Qureg qureg, int targetQubit, qreal damping) |
void | densmatr_mixDepolarising (Qureg qureg, int targetQubit, qreal depolLevel) |
void | densmatr_mixTwoQubitDepolarising (Qureg qureg, int qubit1, int qubit2, qreal depolLevel) |
void | destroyQuESTEnv (QuESTEnv env) |
Destroy the QuEST environment. More... | |
void | getEnvironmentString (QuESTEnv env, char str[200]) |
Sets str to a string containing information about the runtime environment, including whether simulation is using CUDA (for GPU), OpenMP (for multithreading) and/or MPI (for distribution). More... | |
void | reportQuESTEnv (QuESTEnv env) |
Report information about the QuEST environment. More... | |
void | seedQuEST (QuESTEnv *env, unsigned long int *seedArray, int numSeeds) |
Seeds the random number generator with a custom array of key(s), overriding the default keys. More... | |
Complex | statevec_calcExpecDiagonalOp (Qureg qureg, DiagonalOp op) |
Complex | statevec_calcInnerProduct (Qureg bra, Qureg ket) |
void | statevec_calcProbOfAllOutcomes (qreal *retProbs, Qureg qureg, int *qubits, int numQubits) |
qreal | statevec_calcProbOfOutcome (Qureg qureg, int measureQubit, int outcome) |
qreal | statevec_calcTotalProb (Qureg qureg) |
void | statevec_collapseToKnownProbOutcome (Qureg qureg, int measureQubit, int outcome, qreal stateProb) |
void | statevec_compactUnitary (Qureg qureg, int targetQubit, Complex alpha, Complex beta) |
void | statevec_controlledCompactUnitary (Qureg qureg, int controlQubit, int targetQubit, Complex alpha, Complex beta) |
void | statevec_controlledNot (Qureg qureg, int controlQubit, int targetQubit) |
void | statevec_controlledPauliY (Qureg qureg, int controlQubit, int targetQubit) |
void | statevec_controlledPauliYConj (Qureg qureg, int controlQubit, int targetQubit) |
void | statevec_controlledUnitary (Qureg qureg, int controlQubit, int targetQubit, ComplexMatrix2 u) |
qreal | statevec_getImagAmp (Qureg qureg, long long int index) |
qreal | statevec_getRealAmp (Qureg qureg, long long int index) |
void | statevec_hadamard (Qureg qureg, int targetQubit) |
void | statevec_multiControlledMultiQubitNot (Qureg qureg, int ctrlMask, int targMask) |
void | statevec_multiControlledMultiQubitUnitary (Qureg qureg, long long int ctrlMask, int *targs, int numTargs, ComplexMatrixN u) |
This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct. More... | |
void | statevec_multiControlledTwoQubitUnitary (Qureg qureg, long long int ctrlMask, int q1, int q2, ComplexMatrix4 u) |
This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct. More... | |
void | statevec_multiControlledUnitary (Qureg qureg, long long int ctrlQubitsMask, long long int ctrlFlipMask, int targetQubit, ComplexMatrix2 u) |
void | statevec_pauliX (Qureg qureg, int targetQubit) |
void | statevec_pauliY (Qureg qureg, int targetQubit) |
void | statevec_pauliYConj (Qureg qureg, int targetQubit) |
void | statevec_swapQubitAmps (Qureg qureg, int qb1, int qb2) |
void | statevec_unitary (Qureg qureg, int targetQubit, ComplexMatrix2 u) |
void | syncQuESTEnv (QuESTEnv env) |
Guarantees that all code up to the given point has been executed on all nodes (if running in distributed mode) More... | |
int | syncQuESTSuccess (int successCode) |
Performs a logical AND on all successCodes held by all processes. More... | |
Detailed Description
An implementation of the pure backend in ../QuEST_ops_pure.h for a local (non-MPI, non-GPU) environment. Mostly pure-state wrappers for the local/distributed functions implemented in QuEST_cpu
Definition in file QuEST_cpu_local.c.
Function Documentation
◆ densmatr_applyDiagonalOp()
void densmatr_applyDiagonalOp | ( | Qureg | qureg, |
DiagonalOp | op | ||
) |
Definition at line 358 of file QuEST_cpu_local.c.
References densmatr_applyDiagonalOpLocal(), DiagonalOp::imag, Qureg::pairStateVec, qreal, and DiagonalOp::real.
◆ densmatr_calcExpecDiagonalOp()
Complex densmatr_calcExpecDiagonalOp | ( | Qureg | qureg, |
DiagonalOp | op | ||
) |
Definition at line 378 of file QuEST_cpu_local.c.
References densmatr_calcExpecDiagonalOpLocal().
◆ densmatr_calcFidelity()
Definition at line 75 of file QuEST_cpu_local.c.
References densmatr_calcFidelityLocal(), Qureg::pairStateVec, qreal, and Qureg::stateVec.
◆ densmatr_calcHilbertSchmidtDistance()
Definition at line 62 of file QuEST_cpu_local.c.
References densmatr_calcHilbertSchmidtDistanceSquaredLocal(), and qreal.
◆ densmatr_calcInnerProduct()
Definition at line 69 of file QuEST_cpu_local.c.
References densmatr_calcInnerProductLocal(), and qreal.
◆ densmatr_calcProbOfAllOutcomes()
Definition at line 317 of file QuEST_cpu_local.c.
References densmatr_calcProbOfAllOutcomesLocal().
◆ densmatr_calcProbOfOutcome()
Definition at line 304 of file QuEST_cpu_local.c.
References densmatr_findProbabilityOfZeroLocal(), and qreal.
◆ densmatr_calcPurity()
Definition at line 57 of file QuEST_cpu_local.c.
References densmatr_calcPurityLocal().
◆ densmatr_calcTotalProb()
Definition at line 118 of file QuEST_cpu_local.c.
References Qureg::numQubitsRepresented, qreal, and Qureg::stateVec.
◆ densmatr_initPureState()
Definition at line 95 of file QuEST_cpu_local.c.
References densmatr_initPureStateLocal(), Qureg::pairStateVec, qreal, and Qureg::stateVec.
◆ densmatr_mixDamping()
◆ densmatr_mixDepolarising()
◆ densmatr_mixTwoQubitDepolarising()
Definition at line 44 of file QuEST_cpu_local.c.
References densmatr_mixTwoQubitDephasing(), densmatr_mixTwoQubitDepolarisingLocal(), and qreal.
◆ statevec_calcExpecDiagonalOp()
Complex statevec_calcExpecDiagonalOp | ( | Qureg | qureg, |
DiagonalOp | op | ||
) |
Definition at line 373 of file QuEST_cpu_local.c.
References statevec_calcExpecDiagonalOpLocal().
◆ statevec_calcInnerProduct()
Definition at line 113 of file QuEST_cpu_local.c.
References statevec_calcInnerProductLocal().
◆ statevec_calcProbOfAllOutcomes()
Definition at line 312 of file QuEST_cpu_local.c.
References statevec_calcProbOfAllOutcomesLocal().
◆ statevec_calcProbOfOutcome()
Definition at line 296 of file QuEST_cpu_local.c.
References qreal, and statevec_findProbabilityOfZeroLocal().
◆ statevec_calcTotalProb()
Definition at line 141 of file QuEST_cpu_local.c.
References Qureg::numAmpsPerChunk, qreal, and Qureg::stateVec.
◆ statevec_collapseToKnownProbOutcome()
void statevec_collapseToKnownProbOutcome | ( | Qureg | qureg, |
int | measureQubit, | ||
int | outcome, | ||
qreal | stateProb | ||
) |
Definition at line 322 of file QuEST_cpu_local.c.
References statevec_collapseToKnownProbOutcomeLocal().
◆ statevec_compactUnitary()
Definition at line 227 of file QuEST_cpu_local.c.
References statevec_compactUnitaryLocal().
◆ statevec_controlledCompactUnitary()
void statevec_controlledCompactUnitary | ( | Qureg | qureg, |
int | controlQubit, | ||
int | targetQubit, | ||
Complex | alpha, | ||
Complex | beta | ||
) |
Definition at line 237 of file QuEST_cpu_local.c.
References statevec_controlledCompactUnitaryLocal().
◆ statevec_controlledNot()
void statevec_controlledNot | ( | Qureg | qureg, |
int | controlQubit, | ||
int | targetQubit | ||
) |
Definition at line 286 of file QuEST_cpu_local.c.
References statevec_controlledNotLocal().
◆ statevec_controlledPauliY()
void statevec_controlledPauliY | ( | Qureg | qureg, |
int | controlQubit, | ||
int | targetQubit | ||
) |
◆ statevec_controlledPauliYConj()
void statevec_controlledPauliYConj | ( | Qureg | qureg, |
int | controlQubit, | ||
int | targetQubit | ||
) |
◆ statevec_controlledUnitary()
void statevec_controlledUnitary | ( | Qureg | qureg, |
int | controlQubit, | ||
int | targetQubit, | ||
ComplexMatrix2 | u | ||
) |
Definition at line 242 of file QuEST_cpu_local.c.
References statevec_controlledUnitaryLocal().
◆ statevec_getImagAmp()
Definition at line 223 of file QuEST_cpu_local.c.
References Qureg::stateVec.
◆ statevec_getRealAmp()
Definition at line 219 of file QuEST_cpu_local.c.
References Qureg::stateVec.
◆ statevec_hadamard()
void statevec_hadamard | ( | Qureg | qureg, |
int | targetQubit | ||
) |
Definition at line 281 of file QuEST_cpu_local.c.
References statevec_hadamardLocal().
◆ statevec_multiControlledMultiQubitNot()
void statevec_multiControlledMultiQubitNot | ( | Qureg | qureg, |
int | ctrlMask, | ||
int | targMask | ||
) |
Definition at line 291 of file QuEST_cpu_local.c.
References statevec_multiControlledMultiQubitNotLocal().
◆ statevec_multiControlledMultiQubitUnitary()
void statevec_multiControlledMultiQubitUnitary | ( | Qureg | qureg, |
long long int | ctrlMask, | ||
int * | targs, | ||
int | numTargs, | ||
ComplexMatrixN | u | ||
) |
This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct.
It is already gauranteed here that all target qubits can fit on each node (this is validated in the front-end)
- Todo:
- refactor so that the 'swap back' isn't performed; instead the qubit locations are updated.
Definition at line 348 of file QuEST_cpu_local.c.
References statevec_multiControlledMultiQubitUnitaryLocal().
◆ statevec_multiControlledTwoQubitUnitary()
void statevec_multiControlledTwoQubitUnitary | ( | Qureg | qureg, |
long long int | ctrlMask, | ||
int | q1, | ||
int | q2, | ||
ComplexMatrix4 | u | ||
) |
This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct.
Note the order of q1 and q2 in the call to twoQubitUnitaryLocal is important.
- Todo:
refactor so that the 'swap back' isn't performed; instead the qubit locations are updated.
the double swap (q1,q2 to 0,1) may be possible simultaneously by a bespoke swap routine.
Definition at line 343 of file QuEST_cpu_local.c.
References statevec_multiControlledTwoQubitUnitaryLocal().
◆ statevec_multiControlledUnitary()
void statevec_multiControlledUnitary | ( | Qureg | qureg, |
long long int | ctrlQubitsMask, | ||
long long int | ctrlFlipMask, | ||
int | targetQubit, | ||
ComplexMatrix2 | u | ||
) |
Definition at line 247 of file QuEST_cpu_local.c.
References statevec_multiControlledUnitaryLocal().
◆ statevec_pauliX()
void statevec_pauliX | ( | Qureg | qureg, |
int | targetQubit | ||
) |
Definition at line 252 of file QuEST_cpu_local.c.
References statevec_pauliXLocal().
◆ statevec_pauliY()
void statevec_pauliY | ( | Qureg | qureg, |
int | targetQubit | ||
) |
Definition at line 257 of file QuEST_cpu_local.c.
References statevec_pauliYLocal().
◆ statevec_pauliYConj()
void statevec_pauliYConj | ( | Qureg | qureg, |
int | targetQubit | ||
) |
Definition at line 263 of file QuEST_cpu_local.c.
References statevec_pauliYLocal().
◆ statevec_swapQubitAmps()
void statevec_swapQubitAmps | ( | Qureg | qureg, |
int | qb1, | ||
int | qb2 | ||
) |
Definition at line 353 of file QuEST_cpu_local.c.
References statevec_swapQubitAmpsLocal().
◆ statevec_unitary()
void statevec_unitary | ( | Qureg | qureg, |
int | targetQubit, | ||
ComplexMatrix2 | u | ||
) |
Definition at line 232 of file QuEST_cpu_local.c.
References statevec_unitaryLocal().