MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / validate_quregsCanBeProducted

Function validate_quregsCanBeProducted

quest/src/core/validation.cpp:4133–4162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4131}
4132
4133void 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
4164void validate_throwErrorBecauseCalcFidOfDensMatrNotYetImplemented(const char* caller) {
4165

Callers 3

calcInnerProductFunction · 0.85
calcFidelityFunction · 0.85
calcDistanceFunction · 0.85

Calls 1

assertThatFunction · 0.85

Tested by

no test coverage detected