#include "QuEST.h"
#include "QuEST_precision.h"
#include "QuEST_internal.h"
#include "QuEST_validation.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
Go to the source code of this file.
Macros | |
#define | macro_isCompletelyPositiveMap(ops, numOps, opDim) |
#define | macro_isMatrixUnitary(m, dim, retVal) |
Functions | |
int | areUniqueQubits (int *qubits, int numQubits) |
unsigned int | calcLog2 (long unsigned int num) |
returns log2 of numbers which must be gauranteed to be 2^n More... | |
void | default_invalidQuESTInputError (const char *errMsg, const char *errFunc) |
void | invalidQuESTInputError (const char *errMsg, const char *errFunc) |
An internal function called when invalid arguments are passed to a QuEST API call, which the user can optionally override by redefining. More... | |
int | isCompletelyPositiveMap2 (ComplexMatrix2 *ops, int numOps) |
int | isCompletelyPositiveMap4 (ComplexMatrix4 *ops, int numOps) |
int | isCompletelyPositiveMapN (ComplexMatrixN *ops, int numOps) |
int | isComplexPairUnitary (Complex alpha, Complex beta) |
int | isComplexUnit (Complex alpha) |
int | isMatrix2Unitary (ComplexMatrix2 u) |
int | isMatrix4Unitary (ComplexMatrix4 u) |
int | isMatrixNUnitary (ComplexMatrixN u) |
int | isValidPauliCode (enum pauliOpType code) |
int | isVectorUnit (qreal ux, qreal uy, qreal uz) |
void | QuESTAssert (int isValid, ErrorCode code, const char *func) |
void | validateAmpIndex (Qureg qureg, long long int ampInd, const char *caller) |
void | validateBitEncoding (int numQubits, enum bitEncoding encoding, const char *caller) |
void | validateControl (Qureg qureg, int controlQubit, const char *caller) |
void | validateControlState (int *controlState, int numControlQubits, const char *caller) |
void | validateControlTarget (Qureg qureg, int controlQubit, int targetQubit, const char *caller) |
void | validateDensityMatrQureg (Qureg qureg, const char *caller) |
void | validateDiagonalOp (Qureg qureg, DiagonalOp op, const char *caller) |
void | validateDiagOpInit (DiagonalOp op, const char *caller) |
void | validateDiagPauliHamil (DiagonalOp op, PauliHamil hamil, const char *caller) |
void | validateDiagPauliHamilFromFile (PauliHamil hamil, int numRanks, const char *caller) |
void | validateFileOpened (int opened, char *fn, const char *caller) |
void | validateHamilFileCoeffParsed (int parsed, PauliHamil h, FILE *file, char *fn, const char *caller) |
void | validateHamilFileParams (int numQubits, int numTerms, FILE *file, char *fn, const char *caller) |
void | validateHamilFilePauliCode (enum pauliOpType code, PauliHamil h, FILE *file, char *fn, const char *caller) |
void | validateHamilFilePauliParsed (int parsed, PauliHamil h, FILE *file, char *fn, const char *caller) |
void | validateHamilParams (int numQubits, int numTerms, const char *caller) |
void | validateMatchingQuregDims (Qureg qureg1, Qureg qureg2, const char *caller) |
void | validateMatchingQuregPauliHamilDims (Qureg qureg, PauliHamil hamil, const char *caller) |
void | validateMatchingQuregTypes (Qureg qureg1, Qureg qureg2, const char *caller) |
void | validateMatrixInit (ComplexMatrixN matr, const char *caller) |
void | validateMeasurementProb (qreal prob, const char *caller) |
void | validateMultiControls (Qureg qureg, int *controlQubits, int numControlQubits, const char *caller) |
void | validateMultiControlsMultiTargets (Qureg qureg, int *controlQubits, int numControlQubits, int *targetQubits, int numTargetQubits, const char *caller) |
void | validateMultiControlsTarget (Qureg qureg, int *controlQubits, int numControlQubits, int targetQubit, const char *caller) |
void | validateMultiQubitKrausMap (Qureg qureg, int numTargs, ComplexMatrixN *ops, int numOps, const char *caller) |
void | validateMultiQubitMatrix (Qureg qureg, ComplexMatrixN u, int numTargs, const char *caller) |
void | validateMultiQubitMatrixFitsInNode (Qureg qureg, int numTargets, const char *caller) |
void | validateMultiQubits (Qureg qureg, int *qubits, int numQubits, const char *caller) |
void | validateMultiQubitUnitaryMatrix (Qureg qureg, ComplexMatrixN u, int numTargs, const char *caller) |
void | validateMultiRegBitEncoding (int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, const char *caller) |
void | validateMultiTargets (Qureg qureg, int *targetQubits, int numTargetQubits, const char *caller) |
void | validateMultiVarPhaseFuncOverrides (int *numQubitsPerReg, const int numRegs, enum bitEncoding encoding, long long int *overrideInds, int numOverrides, const char *caller) |
void | validateMultiVarPhaseFuncTerms (int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *exponents, int *numTermsPerReg, const char *caller) |
void | validateNormProbs (qreal prob1, qreal prob2, const char *caller) |
void | validateNumAmps (Qureg qureg, long long int startInd, long long int numAmps, const char *caller) |
void | validateNumControls (Qureg qureg, int numControlQubits, const char *caller) |
void | validateNumElems (DiagonalOp op, long long int startInd, long long int numElems, const char *caller) |
void | validateNumPauliSumTerms (int numTerms, const char *caller) |
void | validateNumQubitsInDiagOp (int numQubits, int numRanks, const char *caller) |
void | validateNumQubitsInMatrix (int numQubits, const char *caller) |
void | validateNumQubitsInQureg (int numQubits, int numRanks, const char *caller) |
void | validateNumRanks (int numRanks, const char *caller) |
void | validateNumTargets (Qureg qureg, int numTargetQubits, const char *caller) |
void | validateOneQubitDampingProb (qreal prob, const char *caller) |
void | validateOneQubitDephaseProb (qreal prob, const char *caller) |
void | validateOneQubitDepolProb (qreal prob, const char *caller) |
void | validateOneQubitKrausMap (Qureg qureg, ComplexMatrix2 *ops, int numOps, const char *caller) |
void | validateOneQubitPauliProbs (qreal probX, qreal probY, qreal probZ, const char *caller) |
void | validateOneQubitUnitaryMatrix (ComplexMatrix2 u, const char *caller) |
void | validateOutcome (int outcome, const char *caller) |
void | validatePauliCodes (enum pauliOpType *pauliCodes, int numPauliCodes, const char *caller) |
void | validatePauliHamil (PauliHamil hamil, const char *caller) |
void | validatePhaseFuncName (enum phaseFunc funcCode, int numRegs, int numParams, const char *caller) |
void | validatePhaseFuncOverrides (const int numQubits, enum bitEncoding encoding, long long int *overrideInds, int numOverrides, const char *caller) |
void | validatePhaseFuncTerms (int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, int numOverrides, const char *caller) |
void | validateProb (qreal prob, const char *caller) |
void | validateQubitSubregs (Qureg qureg, int *qubits, int *numQubitsPerReg, const int numRegs, const char *caller) |
void | validateSecondQuregStateVec (Qureg qureg2, const char *caller) |
void | validateStateIndex (Qureg qureg, long long int stateInd, const char *caller) |
void | validateStateVecQureg (Qureg qureg, const char *caller) |
void | validateTarget (Qureg qureg, int targetQubit, const char *caller) |
void | validateTrotterParams (int order, int reps, const char *caller) |
void | validateTwoQubitDephaseProb (qreal prob, const char *caller) |
void | validateTwoQubitDepolProb (qreal prob, const char *caller) |
void | validateTwoQubitKrausMap (Qureg qureg, ComplexMatrix4 *ops, int numOps, const char *caller) |
void | validateTwoQubitUnitaryMatrix (Qureg qureg, ComplexMatrix4 u, const char *caller) |
void | validateUniqueTargets (Qureg qureg, int qubit1, int qubit2, const char *caller) |
void | validateUnitaryComplexPair (Complex alpha, Complex beta, const char *caller) |
void | validateVector (Vector vec, const char *caller) |
Variables | |
char | errMsgBuffer [1024] |
static const char * | errorMessages [] |
Detailed Description
Provides validation of user input
Definition in file QuEST_validation.c.
Macro Definition Documentation
◆ macro_isCompletelyPositiveMap
#define macro_isCompletelyPositiveMap | ( | ops, | |
numOps, | |||
opDim | |||
) |
Definition at line 282 of file QuEST_validation.c.
◆ macro_isMatrixUnitary
#define macro_isMatrixUnitary | ( | m, | |
dim, | |||
retVal | |||
) |
Definition at line 236 of file QuEST_validation.c.
Enumeration Type Documentation
◆ ErrorCode
enum ErrorCode |
Definition at line 32 of file QuEST_validation.c.
Function Documentation
◆ areUniqueQubits()
int areUniqueQubits | ( | int * | qubits, |
int | numQubits | ||
) |
Definition at line 315 of file QuEST_validation.c.
Referenced by validateMultiControls(), validateMultiQubits(), validateMultiTargets(), and validateQubitSubregs().
◆ default_invalidQuESTInputError()
void default_invalidQuESTInputError | ( | const char * | errMsg, |
const char * | errFunc | ||
) |
◆ isCompletelyPositiveMap2()
int isCompletelyPositiveMap2 | ( | ComplexMatrix2 * | ops, |
int | numOps | ||
) |
Definition at line 300 of file QuEST_validation.c.
References macro_isCompletelyPositiveMap.
Referenced by validateOneQubitKrausMap().
◆ isCompletelyPositiveMap4()
int isCompletelyPositiveMap4 | ( | ComplexMatrix4 * | ops, |
int | numOps | ||
) |
Definition at line 303 of file QuEST_validation.c.
References macro_isCompletelyPositiveMap.
Referenced by validateTwoQubitKrausMap().
◆ isCompletelyPositiveMapN()
int isCompletelyPositiveMapN | ( | ComplexMatrixN * | ops, |
int | numOps | ||
) |
Definition at line 306 of file QuEST_validation.c.
References macro_isCompletelyPositiveMap, and ComplexMatrixN::numQubits.
Referenced by validateMultiQubitKrausMap().
◆ isComplexPairUnitary()
Definition at line 228 of file QuEST_validation.c.
References Complex::imag, and Complex::real.
Referenced by validateUnitaryComplexPair().
◆ isComplexUnit()
int isComplexUnit | ( | Complex | alpha | ) |
◆ isMatrix2Unitary()
int isMatrix2Unitary | ( | ComplexMatrix2 | u | ) |
Definition at line 263 of file QuEST_validation.c.
References macro_isMatrixUnitary.
Referenced by validateOneQubitUnitaryMatrix().
◆ isMatrix4Unitary()
int isMatrix4Unitary | ( | ComplexMatrix4 | u | ) |
Definition at line 269 of file QuEST_validation.c.
References macro_isMatrixUnitary.
Referenced by validateTwoQubitUnitaryMatrix().
◆ isMatrixNUnitary()
int isMatrixNUnitary | ( | ComplexMatrixN | u | ) |
Definition at line 275 of file QuEST_validation.c.
References macro_isMatrixUnitary, and ComplexMatrixN::numQubits.
Referenced by validateMultiQubitUnitaryMatrix().
◆ isValidPauliCode()
int isValidPauliCode | ( | enum pauliOpType | code | ) |
Definition at line 311 of file QuEST_validation.c.
References PAULI_I, PAULI_X, PAULI_Y, and PAULI_Z.
Referenced by validateHamilFilePauliCode(), and validatePauliCodes().
◆ isVectorUnit()
Definition at line 224 of file QuEST_validation.c.
◆ QuESTAssert()
void QuESTAssert | ( | int | isValid, |
ErrorCode | code, | ||
const char * | func | ||
) |
Definition at line 216 of file QuEST_validation.c.
References errorMessages, and invalidQuESTInputError().
Referenced by validateAmpIndex(), validateBitEncoding(), validateControl(), validateControlState(), validateControlTarget(), validateDensityMatrQureg(), validateDiagonalOp(), validateDiagOpInit(), validateDiagPauliHamil(), validateDiagPauliHamilFromFile(), validateHamilParams(), validateMatchingQuregDims(), validateMatchingQuregPauliHamilDims(), validateMatchingQuregTypes(), validateMatrixInit(), validateMeasurementProb(), validateMultiControls(), validateMultiControlsMultiTargets(), validateMultiControlsTarget(), validateMultiQubitKrausMap(), validateMultiQubitMatrix(), validateMultiQubitMatrixFitsInNode(), validateMultiQubits(), validateMultiQubitUnitaryMatrix(), validateMultiRegBitEncoding(), validateMultiTargets(), validateMultiVarPhaseFuncOverrides(), validateMultiVarPhaseFuncTerms(), validateNormProbs(), validateNumAmps(), validateNumControls(), validateNumElems(), validateNumPauliSumTerms(), validateNumQubitsInDiagOp(), validateNumQubitsInMatrix(), validateNumQubitsInQureg(), validateNumRanks(), validateNumTargets(), validateOneQubitDampingProb(), validateOneQubitDephaseProb(), validateOneQubitDepolProb(), validateOneQubitKrausMap(), validateOneQubitPauliProbs(), validateOneQubitUnitaryMatrix(), validateOutcome(), validatePauliCodes(), validatePhaseFuncName(), validatePhaseFuncOverrides(), validatePhaseFuncTerms(), validateProb(), validateQubitSubregs(), validateSecondQuregStateVec(), validateStateIndex(), validateStateVecQureg(), validateTarget(), validateTrotterParams(), validateTwoQubitDephaseProb(), validateTwoQubitDepolProb(), validateTwoQubitKrausMap(), validateTwoQubitUnitaryMatrix(), validateUniqueTargets(), validateUnitaryComplexPair(), and validateVector().
◆ validateAmpIndex()
void validateAmpIndex | ( | Qureg | qureg, |
long long int | ampInd, | ||
const char * | caller | ||
) |
Definition at line 382 of file QuEST_validation.c.
References E_INVALID_AMP_INDEX, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by getAmp(), getDensityAmp(), getImagAmp(), getProbAmp(), getRealAmp(), and validateNumAmps().
◆ validateBitEncoding()
void validateBitEncoding | ( | int | numQubits, |
enum bitEncoding | encoding, | ||
const char * | caller | ||
) |
Definition at line 966 of file QuEST_validation.c.
References E_INVALID_BIT_ENCODING, E_INVALID_NUM_QUBITS_TWOS_COMPLEMENT, QuESTAssert(), TWOS_COMPLEMENT, and UNSIGNED.
Referenced by applyPhaseFunc(), and applyPhaseFuncOverrides().
◆ validateControl()
void validateControl | ( | Qureg | qureg, |
int | controlQubit, | ||
const char * | caller | ||
) |
Definition at line 404 of file QuEST_validation.c.
References E_INVALID_CONTROL_QUBIT, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by validateControlTarget(), and validateMultiControls().
◆ validateControlState()
void validateControlState | ( | int * | controlState, |
int | numControlQubits, | ||
const char * | caller | ||
) |
Definition at line 468 of file QuEST_validation.c.
References E_INVALID_CONTROLS_BIT_STATE, and QuESTAssert().
Referenced by multiStateControlledUnitary().
◆ validateControlTarget()
void validateControlTarget | ( | Qureg | qureg, |
int | controlQubit, | ||
int | targetQubit, | ||
const char * | caller | ||
) |
Definition at line 408 of file QuEST_validation.c.
References E_TARGET_IS_CONTROL, QuESTAssert(), validateControl(), and validateTarget().
Referenced by controlledCompactUnitary(), controlledNot(), controlledPauliY(), controlledPhaseFlip(), controlledPhaseShift(), controlledRotateAroundAxis(), controlledRotateX(), controlledRotateY(), controlledRotateZ(), and controlledUnitary().
◆ validateDensityMatrQureg()
void validateDensityMatrQureg | ( | Qureg | qureg, |
const char * | caller | ||
) |
Definition at line 519 of file QuEST_validation.c.
References E_DEFINED_ONLY_FOR_DENSMATRS, Qureg::isDensityMatrix, and QuESTAssert().
Referenced by calcDensityInnerProduct(), calcHilbertSchmidtDistance(), calcPurity(), getDensityAmp(), mixDamping(), mixDensityMatrix(), mixDephasing(), mixDepolarising(), mixKrausMap(), mixMultiQubitKrausMap(), mixPauli(), mixTwoQubitDephasing(), mixTwoQubitDepolarising(), and mixTwoQubitKrausMap().
◆ validateDiagonalOp()
void validateDiagonalOp | ( | Qureg | qureg, |
DiagonalOp | op, | ||
const char * | caller | ||
) |
Definition at line 713 of file QuEST_validation.c.
References E_MISMATCHING_QUREG_DIAGONAL_OP_SIZE, DiagonalOp::numQubits, Qureg::numQubitsRepresented, QuESTAssert(), and validateDiagOpInit().
Referenced by applyDiagonalOp(), and calcExpecDiagonalOp().
◆ validateDiagOpInit()
void validateDiagOpInit | ( | DiagonalOp | op, |
const char * | caller | ||
) |
Definition at line 709 of file QuEST_validation.c.
References E_DIAGONAL_OP_NOT_INITIALISED, DiagonalOp::imag, QuESTAssert(), and DiagonalOp::real.
Referenced by destroyDiagonalOp(), initDiagonalOp(), initDiagonalOpFromPauliHamil(), setDiagonalOpElems(), syncDiagonalOp(), and validateDiagonalOp().
◆ validateDiagPauliHamil()
void validateDiagPauliHamil | ( | DiagonalOp | op, |
PauliHamil | hamil, | ||
const char * | caller | ||
) |
Definition at line 718 of file QuEST_validation.c.
References E_MISMATCHING_PAULI_HAMIL_DIAGONAL_OP_SIZE, E_PAULI_HAMIL_NOT_DIAGONAL, PauliHamil::numQubits, DiagonalOp::numQubits, PauliHamil::numSumTerms, PAULI_I, PAULI_Z, PauliHamil::pauliCodes, and QuESTAssert().
Referenced by initDiagonalOpFromPauliHamil().
◆ validateDiagPauliHamilFromFile()
void validateDiagPauliHamilFromFile | ( | PauliHamil | hamil, |
int | numRanks, | ||
const char * | caller | ||
) |
Definition at line 727 of file QuEST_validation.c.
References calcLog2(), destroyPauliHamil(), E_DISTRIB_DIAG_OP_TOO_SMALL, E_NUM_AMPS_EXCEED_TYPE, E_PAULI_HAMIL_NOT_DIAGONAL, PauliHamil::numQubits, PauliHamil::numSumTerms, PAULI_I, PAULI_Z, PauliHamil::pauliCodes, and QuESTAssert().
Referenced by createDiagonalOpFromPauliHamilFile().
◆ validateFileOpened()
void validateFileOpened | ( | int | opened, |
char * | fn, | ||
const char * | caller | ||
) |
Definition at line 543 of file QuEST_validation.c.
References E_CANNOT_OPEN_FILE, errMsgBuffer, errorMessages, and invalidQuESTInputError().
Referenced by createPauliHamilFromFile(), initStateFromSingleFile(), and writeRecordedQASMToFile().
◆ validateHamilFileCoeffParsed()
void validateHamilFileCoeffParsed | ( | int | parsed, |
PauliHamil | h, | ||
FILE * | file, | ||
char * | fn, | ||
const char * | caller | ||
) |
Definition at line 673 of file QuEST_validation.c.
References destroyPauliHamil(), E_CANNOT_PARSE_PAULI_HAMIL_FILE_COEFF, errMsgBuffer, errorMessages, and invalidQuESTInputError().
Referenced by createPauliHamilFromFile().
◆ validateHamilFileParams()
void validateHamilFileParams | ( | int | numQubits, |
int | numTerms, | ||
FILE * | file, | ||
char * | fn, | ||
const char * | caller | ||
) |
Definition at line 664 of file QuEST_validation.c.
References E_INVALID_PAULI_HAMIL_FILE_PARAMS, errMsgBuffer, errorMessages, and invalidQuESTInputError().
Referenced by createPauliHamilFromFile().
◆ validateHamilFilePauliCode()
void validateHamilFilePauliCode | ( | enum pauliOpType | code, |
PauliHamil | h, | ||
FILE * | file, | ||
char * | fn, | ||
const char * | caller | ||
) |
Definition at line 693 of file QuEST_validation.c.
References destroyPauliHamil(), E_INVALID_PAULI_HAMIL_FILE_PAULI_CODE, errMsgBuffer, errorMessages, invalidQuESTInputError(), and isValidPauliCode().
Referenced by createPauliHamilFromFile().
◆ validateHamilFilePauliParsed()
void validateHamilFilePauliParsed | ( | int | parsed, |
PauliHamil | h, | ||
FILE * | file, | ||
char * | fn, | ||
const char * | caller | ||
) |
Definition at line 683 of file QuEST_validation.c.
References destroyPauliHamil(), E_CANNOT_PARSE_PAULI_HAMIL_FILE_PAULI, errMsgBuffer, errorMessages, and invalidQuESTInputError().
Referenced by createPauliHamilFromFile().
◆ validateHamilParams()
void validateHamilParams | ( | int | numQubits, |
int | numTerms, | ||
const char * | caller | ||
) |
Definition at line 651 of file QuEST_validation.c.
References E_INVALID_PAULI_HAMIL_PARAMS, and QuESTAssert().
Referenced by createPauliHamil(), initDiagonalOpFromPauliHamil(), initPauliHamil(), and validatePauliHamil().
◆ validateMatchingQuregDims()
Definition at line 531 of file QuEST_validation.c.
References E_MISMATCHING_QUREG_DIMENSIONS, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by applyPauliHamil(), applyPauliSum(), calcDensityInnerProduct(), calcExpecPauliHamil(), calcExpecPauliProd(), calcExpecPauliSum(), calcFidelity(), calcHilbertSchmidtDistance(), calcInnerProduct(), cloneQureg(), compareStates(), initPureState(), mixDensityMatrix(), and setWeightedQureg().
◆ validateMatchingQuregPauliHamilDims()
void validateMatchingQuregPauliHamilDims | ( | Qureg | qureg, |
PauliHamil | hamil, | ||
const char * | caller | ||
) |
Definition at line 660 of file QuEST_validation.c.
References E_MISMATCHING_PAULI_HAMIL_QUREG_NUM_QUBITS, PauliHamil::numQubits, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by applyPauliHamil(), applyTrotterCircuit(), and calcExpecPauliHamil().
◆ validateMatchingQuregTypes()
Definition at line 535 of file QuEST_validation.c.
References E_MISMATCHING_QUREG_TYPES, Qureg::isDensityMatrix, and QuESTAssert().
Referenced by applyPauliHamil(), applyPauliSum(), calcExpecPauliHamil(), calcExpecPauliProd(), calcExpecPauliSum(), cloneQureg(), and setWeightedQureg().
◆ validateMatrixInit()
void validateMatrixInit | ( | ComplexMatrixN | matr, |
const char * | caller | ||
) |
Definition at line 486 of file QuEST_validation.c.
References E_COMPLEX_MATRIX_NOT_INIT, ComplexMatrixN::imag, QuESTAssert(), and ComplexMatrixN::real.
Referenced by createComplexMatrixN(), destroyComplexMatrixN(), initComplexMatrixN(), validateMultiQubitKrausMap(), and validateMultiQubitMatrix().
◆ validateMeasurementProb()
void validateMeasurementProb | ( | qreal | prob, |
const char * | caller | ||
) |
Definition at line 527 of file QuEST_validation.c.
References E_COLLAPSE_STATE_ZERO_PROB, and QuESTAssert().
Referenced by collapseToOutcome().
◆ validateMultiControls()
void validateMultiControls | ( | Qureg | qureg, |
int * | controlQubits, | ||
int | numControlQubits, | ||
const char * | caller | ||
) |
Definition at line 436 of file QuEST_validation.c.
References areUniqueQubits(), E_CONTROLS_NOT_UNIQUE, QuESTAssert(), validateControl(), and validateNumControls().
Referenced by validateMultiControlsMultiTargets(), and validateMultiControlsTarget().
◆ validateMultiControlsMultiTargets()
void validateMultiControlsMultiTargets | ( | Qureg | qureg, |
int * | controlQubits, | ||
int | numControlQubits, | ||
int * | targetQubits, | ||
int | numTargetQubits, | ||
const char * | caller | ||
) |
Definition at line 459 of file QuEST_validation.c.
References E_CONTROL_TARGET_COLLISION, getQubitBitMask(), QuESTAssert(), validateMultiControls(), and validateMultiTargets().
Referenced by applyMultiControlledMatrixN(), controlledMultiQubitUnitary(), controlledTwoQubitUnitary(), multiControlledMultiQubitNot(), multiControlledMultiQubitUnitary(), multiControlledMultiRotatePauli(), multiControlledMultiRotateZ(), and multiControlledTwoQubitUnitary().
◆ validateMultiControlsTarget()
void validateMultiControlsTarget | ( | Qureg | qureg, |
int * | controlQubits, | ||
int | numControlQubits, | ||
int | targetQubit, | ||
const char * | caller | ||
) |
Definition at line 452 of file QuEST_validation.c.
References E_TARGET_IN_CONTROLS, QuESTAssert(), validateMultiControls(), and validateTarget().
Referenced by multiControlledUnitary(), and multiStateControlledUnitary().
◆ validateMultiQubitKrausMap()
void validateMultiQubitKrausMap | ( | Qureg | qureg, |
int | numTargs, | ||
ComplexMatrixN * | ops, | ||
int | numOps, | ||
const char * | caller | ||
) |
Definition at line 634 of file QuEST_validation.c.
References E_INVALID_KRAUS_OPS, E_INVALID_NUM_N_QUBIT_KRAUS_OPS, E_MISMATCHING_NUM_TARGS_KRAUS_SIZE, isCompletelyPositiveMapN(), QuESTAssert(), validateMatrixInit(), and validateMultiQubitMatrixFitsInNode().
Referenced by mixMultiQubitKrausMap().
◆ validateMultiQubitMatrix()
void validateMultiQubitMatrix | ( | Qureg | qureg, |
ComplexMatrixN | u, | ||
int | numTargs, | ||
const char * | caller | ||
) |
Definition at line 496 of file QuEST_validation.c.
References E_INVALID_UNITARY_SIZE, ComplexMatrixN::numQubits, QuESTAssert(), validateMatrixInit(), and validateMultiQubitMatrixFitsInNode().
Referenced by applyMatrixN(), applyMultiControlledMatrixN(), and validateMultiQubitUnitaryMatrix().
◆ validateMultiQubitMatrixFitsInNode()
void validateMultiQubitMatrixFitsInNode | ( | Qureg | qureg, |
int | numTargets, | ||
const char * | caller | ||
) |
Definition at line 473 of file QuEST_validation.c.
References E_CANNOT_FIT_MULTI_QUBIT_MATRIX, Qureg::numAmpsPerChunk, and QuESTAssert().
Referenced by applyMatrix4(), sqrtSwapGate(), validateMultiQubitKrausMap(), validateMultiQubitMatrix(), validateOneQubitKrausMap(), validateTwoQubitKrausMap(), and validateTwoQubitUnitaryMatrix().
◆ validateMultiQubits()
void validateMultiQubits | ( | Qureg | qureg, |
int * | qubits, | ||
int | numQubits, | ||
const char * | caller | ||
) |
Definition at line 444 of file QuEST_validation.c.
References areUniqueQubits(), E_INVALID_NUM_QUBITS, E_INVALID_QUBIT_INDEX, E_QUBITS_NOT_UNIQUE, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by applyPhaseFunc(), applyPhaseFuncOverrides(), multiControlledPhaseFlip(), and multiControlledPhaseShift().
◆ validateMultiQubitUnitaryMatrix()
void validateMultiQubitUnitaryMatrix | ( | Qureg | qureg, |
ComplexMatrixN | u, | ||
int | numTargs, | ||
const char * | caller | ||
) |
Definition at line 502 of file QuEST_validation.c.
References E_NON_UNITARY_MATRIX, isMatrixNUnitary(), QuESTAssert(), and validateMultiQubitMatrix().
Referenced by controlledMultiQubitUnitary(), multiControlledMultiQubitUnitary(), and multiQubitUnitary().
◆ validateMultiRegBitEncoding()
void validateMultiRegBitEncoding | ( | int * | numQubitsPerReg, |
int | numRegs, | ||
enum bitEncoding | encoding, | ||
const char * | caller | ||
) |
Definition at line 976 of file QuEST_validation.c.
References E_INVALID_BIT_ENCODING, E_INVALID_NUM_QUBITS_TWOS_COMPLEMENT, QuESTAssert(), TWOS_COMPLEMENT, and UNSIGNED.
Referenced by applyMultiVarPhaseFunc(), applyMultiVarPhaseFuncOverrides(), applyNamedPhaseFunc(), applyNamedPhaseFuncOverrides(), applyParamNamedPhaseFunc(), and applyParamNamedPhaseFuncOverrides().
◆ validateMultiTargets()
void validateMultiTargets | ( | Qureg | qureg, |
int * | targetQubits, | ||
int | numTargetQubits, | ||
const char * | caller | ||
) |
Definition at line 428 of file QuEST_validation.c.
References areUniqueQubits(), E_TARGETS_NOT_UNIQUE, QuESTAssert(), validateNumTargets(), and validateTarget().
Referenced by applyMatrix4(), applyMatrixN(), applyQFT(), calcExpecPauliProd(), calcProbOfAllOutcomes(), mixMultiQubitKrausMap(), mixTwoQubitKrausMap(), multiQubitNot(), multiQubitUnitary(), multiRotatePauli(), multiRotateZ(), twoQubitUnitary(), and validateMultiControlsMultiTargets().
◆ validateMultiVarPhaseFuncOverrides()
void validateMultiVarPhaseFuncOverrides | ( | int * | numQubitsPerReg, |
const int | numRegs, | ||
enum bitEncoding | encoding, | ||
long long int * | overrideInds, | ||
int | numOverrides, | ||
const char * | caller | ||
) |
Definition at line 886 of file QuEST_validation.c.
References E_INVALID_NUM_PHASE_FUNC_OVERRIDES, E_INVALID_PHASE_FUNC_OVERRIDE_TWOS_COMPLEMENT_INDEX, E_INVALID_PHASE_FUNC_OVERRIDE_UNSIGNED_INDEX, QuESTAssert(), TWOS_COMPLEMENT, and UNSIGNED.
Referenced by applyMultiVarPhaseFuncOverrides(), applyNamedPhaseFuncOverrides(), and applyParamNamedPhaseFuncOverrides().
◆ validateMultiVarPhaseFuncTerms()
void validateMultiVarPhaseFuncTerms | ( | int * | numQubitsPerReg, |
int | numRegs, | ||
enum bitEncoding | encoding, | ||
qreal * | exponents, | ||
int * | numTermsPerReg, | ||
const char * | caller | ||
) |
Definition at line 836 of file QuEST_validation.c.
References E_FRACTIONAL_EXPONENT_MULTI_VAR, E_INVALID_NUM_PHASE_FUNC_TERMS, E_INVALID_NUM_SUBREGISTERS, E_NEGATIVE_EXPONENT_MULTI_VAR, MAX_NUM_REGS_APPLY_ARBITRARY_PHASE, QuESTAssert(), and TWOS_COMPLEMENT.
Referenced by applyMultiVarPhaseFunc(), and applyMultiVarPhaseFuncOverrides().
◆ validateNormProbs()
Definition at line 555 of file QuEST_validation.c.
References E_UNNORM_PROBS, qreal, QuESTAssert(), and validateProb().
◆ validateNumAmps()
void validateNumAmps | ( | Qureg | qureg, |
long long int | startInd, | ||
long long int | numAmps, | ||
const char * | caller | ||
) |
Definition at line 387 of file QuEST_validation.c.
References E_INVALID_NUM_AMPS, E_INVALID_OFFSET_NUM_AMPS_QUREG, Qureg::numAmpsTotal, QuESTAssert(), and validateAmpIndex().
Referenced by setAmps().
◆ validateNumControls()
void validateNumControls | ( | Qureg | qureg, |
int | numControlQubits, | ||
const char * | caller | ||
) |
Definition at line 424 of file QuEST_validation.c.
References E_INVALID_NUM_CONTROLS, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by validateMultiControls().
◆ validateNumElems()
void validateNumElems | ( | DiagonalOp | op, |
long long int | startInd, | ||
long long int | numElems, | ||
const char * | caller | ||
) |
Definition at line 393 of file QuEST_validation.c.
References E_INVALID_ELEM_INDEX, E_INVALID_NUM_ELEMS, E_INVALID_OFFSET_NUM_ELEMS_DIAG, DiagonalOp::numQubits, and QuESTAssert().
Referenced by setDiagonalOpElems().
◆ validateNumPauliSumTerms()
void validateNumPauliSumTerms | ( | int | numTerms, |
const char * | caller | ||
) |
Definition at line 606 of file QuEST_validation.c.
References E_INVALID_NUM_SUM_TERMS, and QuESTAssert().
Referenced by applyPauliSum(), and calcExpecPauliSum().
◆ validateNumQubitsInDiagOp()
void validateNumQubitsInDiagOp | ( | int | numQubits, |
int | numRanks, | ||
const char * | caller | ||
) |
Definition at line 365 of file QuEST_validation.c.
References calcLog2(), E_DISTRIB_DIAG_OP_TOO_SMALL, E_INVALID_NUM_CREATE_QUBITS, E_NUM_AMPS_EXCEED_TYPE, and QuESTAssert().
Referenced by createDiagonalOp().
◆ validateNumQubitsInMatrix()
void validateNumQubitsInMatrix | ( | int | numQubits, |
const char * | caller | ||
) |
Definition at line 361 of file QuEST_validation.c.
References E_INVALID_NUM_QUBITS, and QuESTAssert().
Referenced by createComplexMatrixN().
◆ validateNumQubitsInQureg()
void validateNumQubitsInQureg | ( | int | numQubits, |
int | numRanks, | ||
const char * | caller | ||
) |
Definition at line 349 of file QuEST_validation.c.
References calcLog2(), E_DISTRIB_QUREG_TOO_SMALL, E_INVALID_NUM_CREATE_QUBITS, E_NUM_AMPS_EXCEED_TYPE, and QuESTAssert().
Referenced by createDensityQureg(), and createQureg().
◆ validateNumRanks()
void validateNumRanks | ( | int | numRanks, |
const char * | caller | ||
) |
Definition at line 335 of file QuEST_validation.c.
References E_INVALID_NUM_RANKS, and QuESTAssert().
Referenced by createQuESTEnv().
◆ validateNumTargets()
void validateNumTargets | ( | Qureg | qureg, |
int | numTargetQubits, | ||
const char * | caller | ||
) |
Definition at line 420 of file QuEST_validation.c.
References E_INVALID_NUM_TARGETS, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by validateMultiTargets().
◆ validateOneQubitDampingProb()
void validateOneQubitDampingProb | ( | qreal | prob, |
const char * | caller | ||
) |
Definition at line 578 of file QuEST_validation.c.
References E_INVALID_ONE_QUBIT_DEPOL_PROB, QuESTAssert(), and validateProb().
Referenced by mixDamping().
◆ validateOneQubitDephaseProb()
void validateOneQubitDephaseProb | ( | qreal | prob, |
const char * | caller | ||
) |
Definition at line 563 of file QuEST_validation.c.
References E_INVALID_ONE_QUBIT_DEPHASE_PROB, QuESTAssert(), and validateProb().
Referenced by mixDephasing().
◆ validateOneQubitDepolProb()
void validateOneQubitDepolProb | ( | qreal | prob, |
const char * | caller | ||
) |
Definition at line 573 of file QuEST_validation.c.
References E_INVALID_ONE_QUBIT_DEPOL_PROB, QuESTAssert(), and validateProb().
Referenced by mixDepolarising().
◆ validateOneQubitKrausMap()
void validateOneQubitKrausMap | ( | Qureg | qureg, |
ComplexMatrix2 * | ops, | ||
int | numOps, | ||
const char * | caller | ||
) |
Definition at line 610 of file QuEST_validation.c.
References E_INVALID_KRAUS_OPS, E_INVALID_NUM_ONE_QUBIT_KRAUS_OPS, isCompletelyPositiveMap2(), QuESTAssert(), and validateMultiQubitMatrixFitsInNode().
Referenced by mixKrausMap().
◆ validateOneQubitPauliProbs()
Definition at line 588 of file QuEST_validation.c.
References E_INVALID_ONE_QUBIT_PAULI_PROBS, qreal, QuESTAssert(), and validateProb().
Referenced by mixPauli().
◆ validateOneQubitUnitaryMatrix()
void validateOneQubitUnitaryMatrix | ( | ComplexMatrix2 | u, |
const char * | caller | ||
) |
Definition at line 477 of file QuEST_validation.c.
References E_NON_UNITARY_MATRIX, isMatrix2Unitary(), and QuESTAssert().
Referenced by controlledUnitary(), multiControlledUnitary(), multiStateControlledUnitary(), and unitary().
◆ validateOutcome()
void validateOutcome | ( | int | outcome, |
const char * | caller | ||
) |
Definition at line 523 of file QuEST_validation.c.
References E_INVALID_QUBIT_OUTCOME, and QuESTAssert().
Referenced by applyProjector(), calcProbOfOutcome(), collapseToOutcome(), and initStateOfSingleQubit().
◆ validatePauliCodes()
void validatePauliCodes | ( | enum pauliOpType * | pauliCodes, |
int | numPauliCodes, | ||
const char * | caller | ||
) |
Definition at line 599 of file QuEST_validation.c.
References E_INVALID_PAULI_CODE, isValidPauliCode(), and QuESTAssert().
Referenced by applyPauliSum(), calcExpecPauliProd(), calcExpecPauliSum(), initPauliHamil(), multiControlledMultiRotatePauli(), multiRotatePauli(), and validatePauliHamil().
◆ validatePauliHamil()
void validatePauliHamil | ( | PauliHamil | hamil, |
const char * | caller | ||
) |
Definition at line 655 of file QuEST_validation.c.
References PauliHamil::numQubits, PauliHamil::numSumTerms, PauliHamil::pauliCodes, validateHamilParams(), and validatePauliCodes().
Referenced by applyPauliHamil(), applyTrotterCircuit(), calcExpecPauliHamil(), and reportPauliHamil().
◆ validatePhaseFuncName()
void validatePhaseFuncName | ( | enum phaseFunc | funcCode, |
int | numRegs, | ||
int | numParams, | ||
const char * | caller | ||
) |
Definition at line 913 of file QuEST_validation.c.
References DISTANCE, E_INVALID_NUM_NAMED_PHASE_FUNC_PARAMS, E_INVALID_NUM_REGS_DISTANCE_PHASE_FUNC, E_INVALID_PHASE_FUNC_NAME, INVERSE_DISTANCE, INVERSE_NORM, INVERSE_PRODUCT, NORM, PRODUCT, QuESTAssert(), SCALED_DISTANCE, SCALED_INVERSE_DISTANCE, SCALED_INVERSE_NORM, SCALED_INVERSE_PRODUCT, SCALED_INVERSE_SHIFTED_DISTANCE, SCALED_INVERSE_SHIFTED_NORM, SCALED_NORM, and SCALED_PRODUCT.
Referenced by applyNamedPhaseFunc(), applyNamedPhaseFuncOverrides(), applyParamNamedPhaseFunc(), and applyParamNamedPhaseFuncOverrides().
◆ validatePhaseFuncOverrides()
void validatePhaseFuncOverrides | ( | const int | numQubits, |
enum bitEncoding | encoding, | ||
long long int * | overrideInds, | ||
int | numOverrides, | ||
const char * | caller | ||
) |
Definition at line 862 of file QuEST_validation.c.
References E_INVALID_NUM_PHASE_FUNC_OVERRIDES, E_INVALID_PHASE_FUNC_OVERRIDE_TWOS_COMPLEMENT_INDEX, E_INVALID_PHASE_FUNC_OVERRIDE_UNSIGNED_INDEX, QuESTAssert(), TWOS_COMPLEMENT, and UNSIGNED.
Referenced by applyPhaseFuncOverrides().
◆ validatePhaseFuncTerms()
void validatePhaseFuncTerms | ( | int | numQubits, |
enum bitEncoding | encoding, | ||
qreal * | coeffs, | ||
qreal * | exponents, | ||
int | numTerms, | ||
long long int * | overrideInds, | ||
int | numOverrides, | ||
const char * | caller | ||
) |
Definition at line 773 of file QuEST_validation.c.
References E_FRACTIONAL_EXPONENT_WITHOUT_NEG_OVERRIDE, E_INVALID_NUM_PHASE_FUNC_TERMS, E_NEGATIVE_EXPONENT_WITHOUT_ZERO_OVERRIDE, QuESTAssert(), and TWOS_COMPLEMENT.
Referenced by applyPhaseFunc(), and applyPhaseFuncOverrides().
◆ validateProb()
void validateProb | ( | qreal | prob, |
const char * | caller | ||
) |
Definition at line 551 of file QuEST_validation.c.
References E_INVALID_PROB, and QuESTAssert().
Referenced by mixDensityMatrix(), validateNormProbs(), validateOneQubitDampingProb(), validateOneQubitDephaseProb(), validateOneQubitDepolProb(), validateOneQubitPauliProbs(), validateTwoQubitDephaseProb(), and validateTwoQubitDepolProb().
◆ validateQubitSubregs()
void validateQubitSubregs | ( | Qureg | qureg, |
int * | qubits, | ||
int * | numQubitsPerReg, | ||
const int | numRegs, | ||
const char * | caller | ||
) |
Definition at line 757 of file QuEST_validation.c.
References areUniqueQubits(), E_INVALID_NUM_QUBITS, E_INVALID_NUM_SUBREGISTERS, E_INVALID_QUBIT_INDEX, E_QUBITS_NOT_UNIQUE, MAX_NUM_REGS_APPLY_ARBITRARY_PHASE, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by applyMultiVarPhaseFunc(), applyMultiVarPhaseFuncOverrides(), applyNamedPhaseFunc(), applyNamedPhaseFuncOverrides(), applyParamNamedPhaseFunc(), and applyParamNamedPhaseFuncOverrides().
◆ validateSecondQuregStateVec()
void validateSecondQuregStateVec | ( | Qureg | qureg2, |
const char * | caller | ||
) |
Definition at line 539 of file QuEST_validation.c.
References E_SECOND_ARG_MUST_BE_STATEVEC, Qureg::isDensityMatrix, and QuESTAssert().
Referenced by calcFidelity(), and initPureState().
◆ validateStateIndex()
void validateStateIndex | ( | Qureg | qureg, |
long long int | stateInd, | ||
const char * | caller | ||
) |
Definition at line 377 of file QuEST_validation.c.
References E_INVALID_STATE_INDEX, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by initClassicalState().
◆ validateStateVecQureg()
void validateStateVecQureg | ( | Qureg | qureg, |
const char * | caller | ||
) |
Definition at line 515 of file QuEST_validation.c.
References E_DEFINED_ONLY_FOR_STATEVECS, Qureg::isDensityMatrix, and QuESTAssert().
Referenced by calcInnerProduct(), getAmp(), getImagAmp(), getNumAmps(), getProbAmp(), getRealAmp(), initStateOfSingleQubit(), and setAmps().
◆ validateTarget()
void validateTarget | ( | Qureg | qureg, |
int | targetQubit, | ||
const char * | caller | ||
) |
Definition at line 400 of file QuEST_validation.c.
References E_INVALID_TARGET_QUBIT, Qureg::numQubitsRepresented, and QuESTAssert().
Referenced by applyMatrix2(), applyProjector(), calcProbOfOutcome(), collapseToOutcome(), compactUnitary(), hadamard(), initStateOfSingleQubit(), measure(), measureWithStats(), mixDamping(), mixDephasing(), mixDepolarising(), mixKrausMap(), mixPauli(), pauliX(), pauliY(), pauliZ(), phaseShift(), rotateAroundAxis(), rotateX(), rotateY(), rotateZ(), sGate(), tGate(), unitary(), validateControlTarget(), validateMultiControlsTarget(), validateMultiTargets(), and validateUniqueTargets().
◆ validateTrotterParams()
void validateTrotterParams | ( | int | order, |
int | reps, | ||
const char * | caller | ||
) |
Definition at line 703 of file QuEST_validation.c.
References E_INVALID_TROTTER_ORDER, E_INVALID_TROTTER_REPS, and QuESTAssert().
Referenced by applyTrotterCircuit().
◆ validateTwoQubitDephaseProb()
void validateTwoQubitDephaseProb | ( | qreal | prob, |
const char * | caller | ||
) |
Definition at line 568 of file QuEST_validation.c.
References E_INVALID_TWO_QUBIT_DEPHASE_PROB, QuESTAssert(), and validateProb().
Referenced by mixTwoQubitDephasing().
◆ validateTwoQubitDepolProb()
void validateTwoQubitDepolProb | ( | qreal | prob, |
const char * | caller | ||
) |
Definition at line 583 of file QuEST_validation.c.
References E_INVALID_TWO_QUBIT_DEPOL_PROB, QuESTAssert(), and validateProb().
Referenced by mixTwoQubitDepolarising().
◆ validateTwoQubitKrausMap()
void validateTwoQubitKrausMap | ( | Qureg | qureg, |
ComplexMatrix4 * | ops, | ||
int | numOps, | ||
const char * | caller | ||
) |
Definition at line 622 of file QuEST_validation.c.
References E_INVALID_KRAUS_OPS, E_INVALID_NUM_TWO_QUBIT_KRAUS_OPS, isCompletelyPositiveMap4(), QuESTAssert(), and validateMultiQubitMatrixFitsInNode().
Referenced by mixTwoQubitKrausMap().
◆ validateTwoQubitUnitaryMatrix()
void validateTwoQubitUnitaryMatrix | ( | Qureg | qureg, |
ComplexMatrix4 | u, | ||
const char * | caller | ||
) |
Definition at line 481 of file QuEST_validation.c.
References E_NON_UNITARY_MATRIX, isMatrix4Unitary(), QuESTAssert(), and validateMultiQubitMatrixFitsInNode().
Referenced by controlledTwoQubitUnitary(), multiControlledTwoQubitUnitary(), and twoQubitUnitary().
◆ validateUniqueTargets()
void validateUniqueTargets | ( | Qureg | qureg, |
int | qubit1, | ||
int | qubit2, | ||
const char * | caller | ||
) |
Definition at line 414 of file QuEST_validation.c.
References E_TARGETS_NOT_UNIQUE, QuESTAssert(), and validateTarget().
Referenced by mixTwoQubitDephasing(), mixTwoQubitDepolarising(), sqrtSwapGate(), and swapGate().
◆ validateUnitaryComplexPair()
Definition at line 507 of file QuEST_validation.c.
References E_NON_UNITARY_COMPLEX_PAIR, isComplexPairUnitary(), and QuESTAssert().
Referenced by compactUnitary(), and controlledCompactUnitary().
◆ validateVector()
void validateVector | ( | Vector | vec, |
const char * | caller | ||
) |
Definition at line 511 of file QuEST_validation.c.
References E_ZERO_VECTOR, getVectorMagnitude(), and QuESTAssert().
Referenced by controlledRotateAroundAxis(), and rotateAroundAxis().
Variable Documentation
◆ errMsgBuffer
char errMsgBuffer[1024] |
Definition at line 30 of file QuEST_validation.c.
Referenced by validateFileOpened(), validateHamilFileCoeffParsed(), validateHamilFileParams(), validateHamilFilePauliCode(), and validateHamilFilePauliParsed().
◆ errorMessages
|
static |
Definition at line 116 of file QuEST_validation.c.
Referenced by QuESTAssert(), validateFileOpened(), validateHamilFileCoeffParsed(), validateHamilFileParams(), validateHamilFilePauliCode(), and validateHamilFilePauliParsed().