The Quantum Exact Simulation Toolkit v4.2.0
Loading...
Searching...
No Matches
config.hpp
1/** @file
2 * Testing utilities for loading environment variables
3 * which configure the unit tests, independent of QuEST's
4 * internal environment variable facilities
5 *
6 * @author Tyson Jones
7 */
8
9
10/** @file
11 * @author Tyson Jones
12 *
13 * @defgroup testutilsconfig Config
14 * @ingroup testutils
15 * @brief
16 * Testing utilities for loading environment variables
17 * which configure the unit tests, independent of QuEST's
18 * internal environment variable facilities
19 * @{
20 */
21
22#ifndef CONFIG_HPP
23#define CONFIG_HPP
24
25
26/*
27 * SPECIFYING ENV-VARS
28 */
29
30// spoofing as macros to doc; beware that the values below
31// merely duplicate but do not change the default values
32// which are hardcoded in config.cpp
33#if 0
34
35 /// @envvardoc
37
38 /** @envvardoc
39 *
40 * Specifies the maximum number of control and target qubit permutations for which to unit test each relevant
41 * API function.
42 *
43 * Many QuEST functions accept a varying number of target qubits (like applyCompMatr()) and/or control qubits
44 * (like applyMultiControlledCompMatr()). The unit tests will run these functions, passing every possible number
45 * of target qubits (alongside every possible number of control qubits, if possible), from one (zero) up to the
46 * number contained within the tested `Qureg` (minus the number of target qubits).
47 *
48 * For each of these tested number-of-targets and number-of-controls combinations, there are factorially-many
49 * possible choices of the arbitrarily-ordered qubit indices, i.e. sub-permutations of all Qureg qubits.
50 * By default, the unit tests deterministically check every permutation in-turn. This can become prohibitively
51 * slow when the tested `Qureg` are large. For example, there are `604,800` unique, non-overlapping choices of
52 * `4` targets and `3` controls in a Qureg containing `10` qubits.
53 *
54 * When this environment variable is set to a non-zero value, the unit tests will forego testing every permutation
55 * and instead perform only the number specified, randomising the involved qubits. This can significantly speed up the
56 * tests though risks missing esoteric edge-cases. The runtime of the tests are approximately linearly proportional
57 * to the specified number of permutations. When the specified non-zero value exceeds the number of unique
58 * permutations, the tests will revert to deterministically evaluating each once.
59 *
60 * @envvarvalues
61 *
62 * - set to `0` (default) to systematically test all permutations.
63 * - set to a positive integer (e.g. `50`) to test (at most) that many random permutations and accelerate the tests.
64 *
65 * @author Tyson Jones
66 */
68
69 /// @envvardoc
71
72 /// @envvardoc
73 const int TEST_ALL_DEPLOYMENTS = 1;
74
75 /// @envvardoc
77
78#endif
79
80
81/*
82 * ACCESSING ENV-VARS
83 */
84
85int getNumQubitsInUnitTestedQuregs();
86int getMaxNumTestedQubitPermutations();
87int getMaxNumTestedSuperoperatorTargets();
88int getNumTestedMixedDeploymentRepetitions();
89bool getWhetherToTestAllDeployments();
90
91
92#endif // CONFIG_PP
93
94/** @} (end defgroup) */
const int TEST_MAX_NUM_SUPEROP_TARGETS
Definition config.hpp:70
const int TEST_NUM_QUBITS_IN_QUREG
Definition config.hpp:36
const int TEST_ALL_DEPLOYMENTS
Definition config.hpp:73
const int TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS
Definition config.hpp:76
const int TEST_MAX_NUM_QUBIT_PERMUTATIONS
Definition config.hpp:67