| 292 | |
| 293 | template <NumQubitsFlag Ctrls, NumQubitsFlag Targs, ArgsFlag Args> |
| 294 | int GENERATE_NUM_TARGS(int numQuregQubits) { |
| 295 | |
| 296 | assertNumQubitsFlagsAreValid(zero, Targs); |
| 297 | DEMAND( Targs != one || numQuregQubits >= 1 ); |
| 298 | DEMAND( Targs != two || numQuregQubits >= 2 ); |
| 299 | DEMAND( numQuregQubits > 0 ); |
| 300 | |
| 301 | // single choice if #targs is compile-time set |
| 302 | if constexpr (Targs == one) |
| 303 | return 1; |
| 304 | if constexpr (Targs == two) |
| 305 | return 2; |
| 306 | |
| 307 | if constexpr (Targs == any) { |
| 308 | |
| 309 | // we can target all qubits... |
| 310 | int maxNumTargs = numQuregQubits; |
| 311 | |
| 312 | // unless we're applying CompMatr in distributed |
| 313 | // mode. Technically we can support all targets |
| 314 | // if the Qureg is a density matrix or not |
| 315 | // distributed, but we safely choose the min here |
| 316 | if (Args == compmatr) |
| 317 | maxNumTargs = numQuregQubits - getLog2(getQuESTEnv().numNodes); |
| 318 | |
| 319 | // we must also ensure there is space left for a forced ctrl |
| 320 | if (Ctrls == one && maxNumTargs == numQuregQubits) |
| 321 | maxNumTargs -= 1; |
| 322 | |
| 323 | return GENERATE_COPY( range(1, maxNumTargs+1) ); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | template <NumQubitsFlag Ctrls> |
| 328 | int GENERATE_NUM_CTRLS(int numFreeQubits) { |
nothing calls this directly
no test coverage detected