![]() |
Q2NS dev
ns-3 module
|
Functions | |
| qpp::cmat | ToDensityMatrix (const QState &s) |
| Convert a supported QState backend to a density matrix. | |
| double | ClampToInterval (double x, double lo, double hi, double tol=1e-10) |
| Clamp a scalar metric to a closed interval within numerical tolerance. | |
| Eigen::MatrixXcd | HermitianSqrtPSD (const Eigen::MatrixXcd &A, double negEigTol=1e-12) |
| Compute the Hermitian square root of a positive semidefinite matrix. | |
| double | UhlmannFidelity (const Eigen::MatrixXcd &rho, const Eigen::MatrixXcd &sigma, double negEigTol=1e-12) |
| Compute Uhlmann fidelity between two density matrices. | |
| double | HermitianTraceNorm (const Eigen::MatrixXcd &A) |
| Compute the trace norm of a Hermitian matrix. | |
| double q2ns::analysis::anonymous_namespace{q2ns-analysis.cc}::ClampToInterval | ( | double | x, |
| double | lo, | ||
| double | hi, | ||
| double | tol = 1e-10 |
||
| ) |
Clamp a scalar metric to a closed interval within numerical tolerance.
Values slightly outside the target interval due to floating-point roundoff are clamped back to the nearest endpoint. Values outside the tolerance window are returned unchanged.
| x | Input value. |
| lo | Lower bound. |
| hi | Upper bound. |
| tol | Numerical tolerance for endpoint clamping. |
Definition at line 82 of file q2ns-analysis.cc.
References ClampToInterval().
Referenced by ClampToInterval().
| Eigen::MatrixXcd q2ns::analysis::anonymous_namespace{q2ns-analysis.cc}::HermitianSqrtPSD | ( | const Eigen::MatrixXcd & | A, |
| double | negEigTol = 1e-12 |
||
| ) |
Compute the Hermitian square root of a positive semidefinite matrix.
Small negative eigenvalues caused by numerical roundoff are clamped to zero.
| A | Input matrix. |
| negEigTol | Tolerance for small negative eigenvalues. |
Definition at line 103 of file q2ns-analysis.cc.
References q2ns::H, and HermitianSqrtPSD().
Referenced by HermitianSqrtPSD(), and UhlmannFidelity().
| double q2ns::analysis::anonymous_namespace{q2ns-analysis.cc}::HermitianTraceNorm | ( | const Eigen::MatrixXcd & | A | ) |
Compute the trace norm of a Hermitian matrix.
For a Hermitian matrix H, the trace norm is the sum of the absolute values of its eigenvalues.
The input is symmetrized first to suppress tiny anti-Hermitian numerical noise before diagonalization.
| A | Input matrix. |
| std::runtime_error | if the matrix is not square or if eigenvalue decomposition fails. |
Definition at line 188 of file q2ns-analysis.cc.
References q2ns::H, and HermitianTraceNorm().
Referenced by HermitianTraceNorm().
| qpp::cmat q2ns::analysis::anonymous_namespace{q2ns-analysis.cc}::ToDensityMatrix | ( | const QState & | s | ) |
Convert a supported QState backend to a density matrix.
This helper provides a common density-matrix representation for analysis routines that are naturally expressed in terms of rho, such as purity, entropy, and trace distance.
For ket and stabilizer backends, this may require constructing a dense matrix representation and can therefore be substantially more expensive than backend-native calculations.
| s | Input state. |
| std::runtime_error | if the backend is unsupported or if conversion of a stabilizer state requires unavailable backend-specific functionality. |
Definition at line 47 of file q2ns-analysis.cc.
References ToDensityMatrix().
Referenced by ToDensityMatrix().
| double q2ns::analysis::anonymous_namespace{q2ns-analysis.cc}::UhlmannFidelity | ( | const Eigen::MatrixXcd & | rho, |
| const Eigen::MatrixXcd & | sigma, | ||
| double | negEigTol = 1e-12 |
||
| ) |
Compute Uhlmann fidelity between two density matrices.
The returned value is F(rho, sigma) = (Tr sqrt(sqrt(rho) sigma sqrt(rho)))^2.
| rho | First density matrix. |
| sigma | Second density matrix. |
| negEigTol | Tolerance for small negative eigenvalues in intermediate PSD checks. |
Definition at line 145 of file q2ns-analysis.cc.
References HermitianSqrtPSD(), UhlmannFidelity(), and q2ns::X.
Referenced by UhlmannFidelity().