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 263 of file lists.cpp.
263 {
264 DEMAND( numQubits >= numCtrls + numTargs );
265
266
267 int numPerms = getNumPermutations(numQubits, numCtrls + numTargs);
268 int maxPerms = getMaxNumTestedQubitPermutations();
269 if (maxPerms == 0)
270 maxPerms = std::numeric_limits<int>::max();
271
272
273
274
275 if (numPerms < maxPerms)
276 return GENERATE_COPY( disjointsublists(range(0,numQubits), numCtrls, numTargs) );
277
278
279 GENERATE_COPY( range(0,maxPerms) );
280 return getRandomFixedNumCtrlsTargs(numQubits, numCtrls, numTargs);
281}
◆ GENERATE_TARGS()
| vector< int > GENERATE_TARGS |
( |
int | numQubits, |
|
|
int | numTargs ) |
Definition at line 284 of file lists.cpp.
284 {
285 DEMAND( numQubits >= numTargs );
286
287 auto [ctrls, targs] = GENERATE_CTRLS_AND_TARGS(numQubits, 0, numTargs);
288 return targs;
289}
◆ getComplement()
| vector< int > getComplement |
( |
vector< int > | listA, |
|
|
vector< int > | listB ) |
Definition at line 93 of file lists.cpp.
93 {
94
95 std::sort(listA.begin(), listA.end());
96 std::sort(listB.begin(), listB.end());
97
98 vector<int> out;
99 std::set_difference(
100 listA.begin(), listA.end(),
101 listB.begin(), listB.end(),
102 std::back_inserter(out));
103
104 return out;
105}
◆ getRange() [1/2]
| vector< int > getRange |
( |
int | endExcl | ) |
|
Definition at line 82 of file lists.cpp.
82 {
83 return getRange(0, endExcl);
84}
◆ getRange() [2/2]
| vector< int > getRange |
( |
int | start, |
|
|
int | endExcl ) |
Definition at line 70 of file lists.cpp.
70 {
71 DEMAND( endExcl >= start );
72
73 vector<int> out(endExcl - start);
74
75 for (size_t i=0; i<out.size(); i++)
76 out[i] = start + i;
77
78 return out;
79}
◆ getSublist() [1/2]
| vector< int > getSublist |
( |
vector< int > | list, |
|
|
int | start, |
|
|
int | len ) |
Definition at line 52 of file lists.cpp.
52 {
53
54 return vector<int>(list.begin() + start, list.begin() + start + len);
55}
◆ getSublist() [2/2]
| vector< qcomp > getSublist |
( |
vector< qcomp > | list, |
|
|
int | start, |
|
|
int | len ) |
Definition at line 58 of file lists.cpp.
58 {
59
60 return vector<qcomp>(list.begin() + start, list.begin() + start + len);
61}