| 4131 | } |
| 4132 | |
| 4133 | void validate_quregsCanBeProducted(Qureg quregA, Qureg quregB, const char* caller) { |
| 4134 | |
| 4135 | // number of qubits must always match |
| 4136 | assertThat( |
| 4137 | quregA.numQubits == quregB.numQubits, |
| 4138 | report::PRODUCTED_QUREGS_HAVE_DIFFERENT_NUM_QUBITS, |
| 4139 | {{"${NUM_A}", quregA.numQubits}, {"${NUM_B}", quregB.numQubits}}, caller); |
| 4140 | |
| 4141 | // if both are statevecs or both are densmatr... |
| 4142 | if (quregA.isDensityMatrix == quregB.isDensityMatrix) { |
| 4143 | |
| 4144 | // then they must have the same GPU accel (because falling back to CPU is slow) |
| 4145 | assertThat( |
| 4146 | quregA.isGpuAccelerated == quregB.isGpuAccelerated, |
| 4147 | report::PRODUCTED_SAME_TYPE_QUREGS_HAVE_DIFFERING_GPU_ACCELS, caller); |
| 4148 | |
| 4149 | // but their distributions may differ, so finish |
| 4150 | return; |
| 4151 | } |
| 4152 | |
| 4153 | // when one is a statevector and the other is a density matrix... |
| 4154 | Qureg dm = (quregA.isDensityMatrix)? quregA : quregB; |
| 4155 | Qureg sv = (quregA.isDensityMatrix)? quregB : quregA; |
| 4156 | |
| 4157 | // then statevec can only be distributed if density matrix is |
| 4158 | if (sv.isDistributed) |
| 4159 | assertThat(dm.isDistributed, report::PRODUCTED_STATEVEC_DISTRIB_BUT_DENSMATR_LOCAL, caller); |
| 4160 | |
| 4161 | // their GPU accelerations may differ however |
| 4162 | } |
| 4163 | |
| 4164 | void validate_throwErrorBecauseCalcFidOfDensMatrNotYetImplemented(const char* caller) { |
| 4165 |
no test coverage detected