![]() |
Q2NS dev
ns-3 module
|
Main user-facing entry points for building and using Q2NS. More...
Classes | |
| class | q2ns::NetController |
| Main user-facing facade for creating and configuring a quantum network. More... | |
| class | q2ns::QNode |
| Main user-facing per-node API for quantum operations and transmission. More... | |
| class | q2ns::Qubit |
| Lightweight handle for one qubit inside a registry-managed state. More... | |
Functions | |
| double | q2ns::analysis::Fidelity (const QState &a, const QState &b) |
| Compute fidelity between two QState objects of the same backend type. | |
| double | q2ns::analysis::Purity (const QState &s) |
| Compute the purity of a quantum state. | |
| bool | q2ns::analysis::IsPure (const QState &s, double tol=1e-12) |
| Check whether a quantum state is pure within a numerical tolerance. | |
| double | q2ns::analysis::VonNeumannEntropy (const QState &s) |
| Compute the von Neumann entropy of a quantum state in bits. | |
| double | q2ns::analysis::TraceDistance (const QState &a, const QState &b) |
| Compute the trace distance between two QState objects of the same backend type. | |
Main user-facing entry points for building and using Q2NS.
Compute fidelity between two QState objects of the same backend type.
Currently supported backend pairings are:
Mixed backend comparisons are not yet supported and throw.
| a | First state. |
| b | Second state. |
| std::invalid_argument | if the states are empty. |
| std::runtime_error | if the states have different sizes, use unsupported backends, or require unavailable backend-specific functionality. |
Definition at line 207 of file q2ns-analysis.cc.
References q2ns::QState::NumQubits().
Referenced by main(), q2ns::SwapApp::TryApply(), anonymous_namespace{q2ns-5-noisy-teleportation-example.cc}::TryCorrections(), and anonymous_namespace{q2ns-5-noisy-teleportation-advanced-example.cc}::TryCorrections().
| bool q2ns::analysis::IsPure | ( | const QState & | s, |
| double | tol = 1e-12 |
||
| ) |
Check whether a quantum state is pure within a numerical tolerance.
This function evaluates purity and compares it against 1.0. It is intended as a convenience helper for diagnostics, tests, and analysis code.
| s | Input state. |
| tol | Absolute tolerance for comparing purity against 1.0. |
| std::invalid_argument | if the state is empty or if tol is negative. |
| std::runtime_error | if the backend is unsupported or requires unavailable backend-specific functionality. |
Definition at line 280 of file q2ns-analysis.cc.
References q2ns::analysis::Purity().
| double q2ns::analysis::Purity | ( | const QState & | s | ) |
Compute the purity of a quantum state.
Purity is defined as Tr(rho^2), where rho is the density matrix of the state. It is equal to 1 for pure states and less than 1 for mixed states.
For backend-specific reasons, this function currently operates only on a single QState and therefore does not involve cross-backend comparison.
| s | Input state. |
| std::invalid_argument | if the state is empty. |
| std::runtime_error | if the backend is unsupported or requires unavailable backend-specific functionality. |
Definition at line 264 of file q2ns-analysis.cc.
References q2ns::QState::NumQubits().
Referenced by q2ns::analysis::IsPure().
Compute the trace distance between two QState objects of the same backend type.
The trace distance is defined as D(rho, sigma) = 0.5 * ||rho - sigma||_1, where ||.||_1 is the trace norm.
Currently supported backend pairings are:
Mixed backend comparisons are not supported and throw.
| a | First state. |
| b | Second state. |
| std::invalid_argument | if the states are empty. |
| std::runtime_error | if the states have different sizes, use unsupported backends, or require unavailable backend-specific functionality. |
Definition at line 337 of file q2ns-analysis.cc.
References q2ns::QState::NumQubits().
| double q2ns::analysis::VonNeumannEntropy | ( | const QState & | s | ) |
Compute the von Neumann entropy of a quantum state in bits.
The von Neumann entropy is defined as S(rho) = -Tr(rho log2 rho).
Eigenvalues whose magnitude is below numerical tolerance are treated as zero and do not contribute to the sum.
| s | Input state. |
| std::invalid_argument | if the state is empty. |
| std::runtime_error | if the backend is unsupported, if the backend requires unavailable functionality, or if the density matrix is not positive semidefinite within numerical tolerance. |
Definition at line 290 of file q2ns-analysis.cc.
References q2ns::H, and q2ns::QState::NumQubits().