test_unitaries.cpp File Reference
#include "catch.hpp"
#include "QuEST.h"
#include "utilities.hpp"

Go to the source code of this file.

Macros

#define CLEANUP_TEST(quregVec, quregMatr)
 Destroys the data structures made by PREPARE_TEST. More...
 
#define PREPARE_TEST(quregVec, quregMatr, refVec, refMatr)
 Prepares the needed data structures for unit testing unitaries. More...
 

Functions

 TEST_CASE ("compactUnitary", "[unitaries]")
 
 TEST_CASE ("controlledCompactUnitary", "[unitaries]")
 
 TEST_CASE ("controlledMultiQubitUnitary", "[unitaries]")
 
 TEST_CASE ("controlledNot", "[unitaries]")
 
 TEST_CASE ("controlledPauliY", "[unitaries]")
 
 TEST_CASE ("controlledPhaseFlip", "[unitaries]")
 
 TEST_CASE ("controlledPhaseShift", "[unitaries]")
 
 TEST_CASE ("controlledRotateAroundAxis", "[unitaries]")
 
 TEST_CASE ("controlledRotateX", "[unitaries]")
 
 TEST_CASE ("controlledRotateY", "[unitaries]")
 
 TEST_CASE ("controlledRotateZ", "[unitaries]")
 
 TEST_CASE ("controlledTwoQubitUnitary", "[unitaries]")
 
 TEST_CASE ("controlledUnitary", "[unitaries]")
 
 TEST_CASE ("hadamard", "[unitaries]")
 
 TEST_CASE ("multiControlledMultiQubitNot", "[unitaries]")
 
 TEST_CASE ("multiControlledMultiQubitUnitary", "[unitaries]")
 
 TEST_CASE ("multiControlledMultiRotatePauli", "[unitaries]")
 
 TEST_CASE ("multiControlledMultiRotateZ", "[unitaries]")
 
 TEST_CASE ("multiControlledPhaseFlip", "[unitaries]")
 
 TEST_CASE ("multiControlledPhaseShift", "[unitaries]")
 
 TEST_CASE ("multiControlledTwoQubitUnitary", "[unitaries]")
 
 TEST_CASE ("multiControlledUnitary", "[unitaries]")
 
 TEST_CASE ("multiQubitNot", "[unitaries]")
 
 TEST_CASE ("multiQubitUnitary", "[unitaries]")
 
 TEST_CASE ("multiRotatePauli", "[unitaries]")
 
 TEST_CASE ("multiRotateZ", "[unitaries]")
 
 TEST_CASE ("multiStateControlledUnitary", "[unitaries]")
 
 TEST_CASE ("pauliX", "[unitaries]")
 
 TEST_CASE ("pauliY", "[unitaries]")
 
 TEST_CASE ("pauliZ", "[unitaries]")
 
 TEST_CASE ("phaseShift", "[unitaries]")
 
 TEST_CASE ("rotateAroundAxis", "[unitaries]")
 
 TEST_CASE ("rotateX", "[unitaries]")
 
 TEST_CASE ("rotateY", "[unitaries]")
 
 TEST_CASE ("rotateZ", "[unitaries]")
 
 TEST_CASE ("sGate", "[unitaries]")
 
 TEST_CASE ("sqrtSwapGate", "[unitaries]")
 
 TEST_CASE ("swapGate", "[unitaries]")
 
 TEST_CASE ("tGate", "[unitaries]")
 
 TEST_CASE ("twoQubitUnitary", "[unitaries]")
 
 TEST_CASE ("unitary", "[unitaries]")
 

Detailed Description

Unit testing for QuEST's 'unitaries' API. The tests are in alphabetical order of the API doc.

These tests work by constructing, from the unitary specification (e.g. control and target qubits), a full-Hilbert space complex matrix. This is then multiplied onto statevectors, or multiplied and it's conjugate-transpose right-multiplied onto density matrices.

QuEST's user validation handling is unit tested by redefining exitWithError (a weak C symbol) to throw a C++ exception, caught by the Catch2 library.

Author
Tyson Jones

Definition in file test_unitaries.cpp.

Macro Definition Documentation

◆ CLEANUP_TEST

#define CLEANUP_TEST (   quregVec,
  quregMatr 
)
Value:
destroyQureg(quregVec, QUEST_ENV); \
destroyQureg(quregMatr, QUEST_ENV);

Destroys the data structures made by PREPARE_TEST.

Definition at line 33 of file test_unitaries.cpp.

◆ PREPARE_TEST

#define PREPARE_TEST (   quregVec,
  quregMatr,
  refVec,
  refMatr 
)
Value:
Qureg quregMatr = createDensityQureg(NUM_QUBITS, QUEST_ENV); \
initDebugState(quregVec); \
initDebugState(quregMatr); \
QVector refVec = toQVector(quregVec); \
QMatrix refMatr = toQMatrix(quregMatr);

Prepares the needed data structures for unit testing unitaries.

This creates a statevector and density matrix of the size NUM_QUBITS, and corresponding QVector and QMatrix instances for analytic comparison.

Definition at line 24 of file test_unitaries.cpp.

QuESTEnv QUEST_ENV
The global QuESTEnv instance, to be created and destroyed once in this main(), so that the MPI enviro...
Definition: main.cpp:20
#define NUM_QUBITS
The default number of qubits in the registers created for unit testing (both statevectors and density...
Definition: utilities.hpp:36
QMatrix toQMatrix(ComplexMatrix2 src)
Returns a copy of the given 2-by-2 matrix.
Definition: utilities.cpp:1044
QVector toQVector(Qureg qureg)
Returns an equal-size copy of the given state-vector qureg.
Definition: utilities.cpp:1113
void destroyQureg(Qureg qureg, QuESTEnv env)
Deallocate a Qureg, freeing its memory.
Definition: QuEST.c:77
Represents a system of qubits.
Definition: QuEST.h:322
Qureg createQureg(int numQubits, QuESTEnv env)
Creates a state-vector Qureg object representing a set of qubits which will remain in a pure state.
Definition: QuEST.c:36
Qureg createDensityQureg(int numQubits, QuESTEnv env)
Creates a density matrix Qureg object representing a set of qubits which can enter noisy and mixed st...
Definition: QuEST.c:50