![]() |
The Quantum Exact Simulation Toolkit v4.2.0
|
Functions for comparing multiple quantum states. More...
Functions | |
| qreal | calcDistance (Qureg qureg, Qureg other) |
| qreal | calcFidelity (Qureg qureg, Qureg other) |
| qcomp | calcInnerProduct (Qureg qureg, Qureg other) |
Functions for comparing multiple quantum states.
Calculates one of three distance measures between qureg and other, depending upon whether one or both are density matrices. These are the Hilbert-Schmidt distance, Bures distance and purified distance.
qureg and other are statevectors (respectively \(\ket{\psi}\) and \(\ket{\phi}\)), this function returns the Bures distance defined as \[ d_B\left(\ket{\psi},\ket{\phi}\right) = \sqrt{2 - 2 \left| \braket{\phi}{\psi} \right|} \]
where \(\left| \braket{\phi}{\psi} \right|\) is the square-root of the fidelity between \(\ket{\psi}\) and \(\ket{\phi}\) as would be computed by calcFidelity().qureg and other are density matrices (respectively \(\mathbf{\rho}\) and \(\mathbf{\sigma}\)), this function returns the Hilbert-Schmidt distance defined as \[ d_{HS}\left(\mathbf{\rho}, \mathbf{\sigma}\right) = \sqrt{ \tr{ \left| \mathbf{\rho} - \mathbf{\sigma} \right|^2 } } = \sqrt{ \sum\limits_{ij} \left| \rho_{ij} - \sigma_{ij} \right|^2 }. \]
qureg or other is a statevector \(\svpsi\), and the other is a density matrix \(\dmrho\), this function returns the purified distance defined as \[ d_p\left(\svpsi,\dmrho\right) = \sqrt{ 1 - \brapsi \dmrho \svpsi } \]
where \(\brapsi \dmrho \svpsi\) is the fidelity as returned by calcFidelity().\[ \left| \braket{\phi}{\psi} \right| \le 1 + \valeps \]
while the purified distance validation will check that\[ \left| \, \im{ \brapsi \dmrho \svpsi } \, \right| \le \valeps, \\ \re{ \brapsi \dmrho \svpsi } \le 1 + \valeps, \]
where \(\valeps\) is the validation epsilon, adjustable via setValidationEpsilon().qureg and other are both statevectors, or both density matrices, then both or neither must be GPU-accelerated. That is, their CPU vs GPU deployments must agree. They are permitted to differ in distribution however. Such considerations are only relevant when creating the registers using createCustomQureg(), since the automatic deployments of createQureg() and createDensityQureg() will always agree.qureg and other dimensionally differ (i.e. one is a statevector while the other is a density matrix), the statevector must not be distributed unless the density matrix is distributed. The CPU vs GPU deployments however are permitted to disagree. These requirements are again consistent with the automatic deployments of the createQureg() and createDensityQureg() functions.qureg and other are statevectors, this function wraps calcInnerProduct(). qureg is a density matrix and other is a statevector, this function wraps calcInnerProduct() as a complex-valued proxy for calcFidelity(). | [in] | qureg | a state |
| [in] | other | another state containing an equal number of qubits |
qureg and other, according to the above measures. | error |
|
Definition at line 331 of file calculations.cpp.
Referenced by TEST_CASE().
Calculates the fidelity between qureg and other, where at least one is a statevector.
qureg and other are statevectors (respectively \(\ket{\psi}\) and \(\ket{\phi}\)), this function returns \[ \left| \braket{\phi}{\psi} \right|^2. \]
qureg is a density matrix \(\dmrho\) and other is a statevector \(\svpsi\), this function returns \[ \bra{\psi} \dmrho \ket{\psi}, \]
and similarly whenqureg is a statevector and other is a density matrix.qureg and other being density matrices, for which the fidelity calculation is more substantial.qureg and other are both statevectors, or both density matrices, then both or neither must be GPU-accelerated. That is, their CPU vs GPU deployments must agree. They are permitted to differ in distribution however. Such considerations are only relevant when creating the registers using createCustomQureg(), since the automatic deployments of createQureg() and createDensityQureg() will always agree.qureg and other dimensionally differ (i.e. one is a statevector while the other is a density matrix), the statevector must not be distributed unless the density matrix is distributed. The CPU vs GPU deployments however are permitted to disagree. These requirements are again consistent with the automatic deployments of the createQureg() and createDensityQureg() functions.qureg and other are statevectors, this function is equivalent to calling calcInnerProduct() and squaring the absolute value of the result. qureg or other is a statevector in the computational basis state \(\ket{i}\) (e.g. as can be produced via initClassicalState()), this function is slower but equivalent to finding directly the probability of the basis state. | [in] | qureg | a state |
| [in] | other | another state containing an equal number of qubits. |
qureg and other. | error |
|
Definition at line 303 of file calculations.cpp.
Referenced by TEST_CASE(), and TEST_CASE().
Calculates the inner product of state qureg with other.
qureg and other are statevectors (respectively \(\ket{\psi}\) and \(\ket{\phi}\)), this function returns \[ \braket{\psi}{\phi} = \sum\limits_i \psi_i^* \phi_i \]
where \(\psi_i\) and \(\phi_i\) are the \(i\)-th amplitudes of \(\ket{\psi}\) (qureg) and \(\ket{\phi}\) (other) respectively, and \(\alpha^*\) notates the complex conjugate of scalar \(\alpha\).qureg and other are density matrices (respectively \(\mathbf{\rho}\) and \(\mathbf{\sigma}\)), this function returns \[ \tr{ \rho^\dagger \sigma } = \sum\limits_{ij} {\rho_{ij}}^* \, \sigma_{ij}. \]
qureg is a density matrix \(\dmrho\) and other is a statevector \(\ket{\phi}\), this function returns \[ \bra{\phi} \dmrho^\dagger \ket{\phi}. \]
qureg is a statevector \(\svpsi\) and other is a density matrix \(\mathbf{\sigma}\), this function returns \[ \brapsi \mathbf{\sigma} \svpsi. \]
qureg and other are both statevectors, or both density matrices, then both or neither must be GPU-accelerated. That is, their CPU vs GPU deployments must agree. They are permitted to differ in distribution however. Such considerations are only relevant when creating the registers using createCustomQureg(), since the automatic deployments of createQureg() and createDensityQureg() will always agree.qureg and other dimensionally differ (i.e. one is a statevector while the other is a density matrix), the statevector must not be distributed unless the density matrix is distributed. The CPU vs GPU deployments however are permitted to disagree. These requirements are again consistent with the automatic deployments of the createQureg() and createDensityQureg() functions.| [in] | qureg | a state |
| [in] | other | another state with an equal number of qubits |
qureg with other. | error |
|
Definition at line 49 of file calculations.cpp.
Referenced by TEST_CASE(), and TEST_CASE().