| 392 | } |
| 393 | |
| 394 | void applyMultiStateControlledDiagMatrPower(Qureg qureg, int* controls, int* states, int numControls, int* targets, int numTargets, DiagMatr matrix, qcomp exponent) { |
| 395 | validate_quregFields(qureg, __func__); |
| 396 | validate_controlsAndTargets(qureg, controls, numControls, targets, numTargets, __func__); |
| 397 | validate_controlStates(states, numControls, __func__); // can be nullptr, ignoring numControls |
| 398 | validate_matrixDimMatchesTargets(matrix, numTargets, __func__); |
| 399 | validate_matrixIsUnitary(matrix, __func__); |
| 400 | validate_matrixExpIsNonDiverging(matrix, exponent, __func__); |
| 401 | validate_unitaryExponentIsReal(exponent, __func__); |
| 402 | |
| 403 | // unlike calcExpecDiagMatrPower which accepts a 'qreal' exponent, |
| 404 | // this function accepts a 'qcomp'. This is because it always |
| 405 | // evaluates the relatively numerically unstable pow(qcomp,qcomp) |
| 406 | // overload, rather than pow(qreal,qreal), since there is no reason |
| 407 | // to think matrix is real (unitarity permits it to be complex). |
| 408 | // As such, despite unitarity requiring exponent is also real, we |
| 409 | // accept a qcomp types so that complex exponents can be passed |
| 410 | // when numerical validation is disabled without a separate func. |
| 411 | |
| 412 | bool conj = false; |
| 413 | auto ctrlVec = util_getVector(controls, numControls); |
| 414 | auto stateVec = util_getVector(states, numControls); // empty if states==nullptr |
| 415 | auto targVec = util_getVector(targets, numTargets); |
| 416 | localiser_statevec_anyCtrlAnyTargDiagMatr(qureg, ctrlVec, stateVec, targVec, matrix, exponent, conj); |
| 417 | |
| 418 | if (!qureg.isDensityMatrix) |
| 419 | return; |
| 420 | |
| 421 | conj = true; |
| 422 | ctrlVec = util_getBraQubits(ctrlVec, qureg); |
| 423 | targVec = util_getBraQubits(targVec, qureg); |
| 424 | localiser_statevec_anyCtrlAnyTargDiagMatr(qureg, ctrlVec, stateVec, targVec, matrix, exponent, conj); |
| 425 | } |
| 426 | |
| 427 | } // end de-mangler |
| 428 |
no test coverage detected