Testing utilities which generate lists of integers.
More...
|
template<class T > |
using | CatchGen = Catch::Generators::GeneratorWrapper<T> |
|
using | listpair = std::tuple<vector<int>,vector<int>> |
|
using | listtrio = std::tuple<vector<int>,vector<int>,vector<int>> |
|
|
CatchGen< listpair > | disjointsublists (CatchGen< int > &&gen, int sublen1, int sublen2) |
|
listpair | GENERATE_CTRLS_AND_TARGS (int numQubits, int numCtrls, int numTargs) |
|
vector< int > | GENERATE_TARGS (int numQubits, int numTargs) |
|
vector< int > | getComplement (vector< int > listA, vector< int > listB) |
|
vector< int > | getRange (int endExcl) |
|
vector< int > | getRange (int start, int endExcl) |
|
vector< int > | getSublist (vector< int > list, int start, int len) |
|
vector< qcomp > | getSublist (vector< qcomp > list, int start, int len) |
|
CatchGen< vector< int > > | sublists (CatchGen< int > &&gen, int sublen) |
|
Testing utilities which generate lists of integers.
◆ CatchGen
template<class T >
using CatchGen = Catch::Generators::GeneratorWrapper<T> |
◆ listpair
using listpair = std::tuple<vector<int>,vector<int>> |
◆ listtrio
using listtrio = std::tuple<vector<int>,vector<int>,vector<int>> |
◆ GENERATE_CTRLS_AND_TARGS()
listpair GENERATE_CTRLS_AND_TARGS |
( |
int | numQubits, |
|
|
int | numCtrls, |
|
|
int | numTargs ) |
Definition at line 262 of file lists.cpp.
262 {
263 DEMAND( numQubits >= numCtrls + numTargs );
264
265
266 int numPerms = getNumPermutations(numQubits, numCtrls + numTargs);
268 if (maxPerms == 0)
269 maxPerms = std::numeric_limits<int>::max();
270
271
272
273
274 if (numPerms < maxPerms)
275 return GENERATE_COPY( disjointsublists(range(0,numQubits), numCtrls, numTargs) );
276
277
278 GENERATE_COPY( range(0,maxPerms) );
279 return getRandomFixedNumCtrlsTargs(numQubits, numCtrls, numTargs);
280}
const int TEST_MAX_NUM_QUBIT_PERMUTATIONS
◆ GENERATE_TARGS()
vector< int > GENERATE_TARGS |
( |
int | numQubits, |
|
|
int | numTargs ) |
Definition at line 283 of file lists.cpp.
283 {
284 DEMAND( numQubits >= numTargs );
285
286 auto [ctrls, targs] = GENERATE_CTRLS_AND_TARGS(numQubits, 0, numTargs);
287 return targs;
288}
◆ getComplement()
vector< int > getComplement |
( |
vector< int > | listA, |
|
|
vector< int > | listB ) |
Definition at line 92 of file lists.cpp.
92 {
93
94 std::sort(listA.begin(), listA.end());
95 std::sort(listB.begin(), listB.end());
96
97 vector<int> out;
98 std::set_difference(
99 listA.begin(), listA.end(),
100 listB.begin(), listB.end(),
101 std::back_inserter(out));
102
103 return out;
104}
◆ getRange() [1/2]
vector< int > getRange |
( |
int | endExcl | ) |
|
Definition at line 81 of file lists.cpp.
81 {
82 return getRange(0, endExcl);
83}
◆ getRange() [2/2]
vector< int > getRange |
( |
int | start, |
|
|
int | endExcl ) |
Definition at line 69 of file lists.cpp.
69 {
70 DEMAND( endExcl >= start );
71
72 vector<int> out(endExcl - start);
73
74 for (size_t i=0; i<out.size(); i++)
75 out[i] = start + i;
76
77 return out;
78}
◆ getSublist() [1/2]
vector< int > getSublist |
( |
vector< int > | list, |
|
|
int | start, |
|
|
int | len ) |
Definition at line 51 of file lists.cpp.
51 {
52
53 return vector<int>(list.begin() + start, list.begin() + start + len);
54}
◆ getSublist() [2/2]
vector< qcomp > getSublist |
( |
vector< qcomp > | list, |
|
|
int | start, |
|
|
int | len ) |
Definition at line 57 of file lists.cpp.
57 {
58
59 return vector<qcomp>(list.begin() + start, list.begin() + start + len);
60}