Q2NS dev
ns-3 module
Loading...
Searching...
No Matches
Public API

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.
 

Detailed Description

Main user-facing entry points for building and using Q2NS.

Function Documentation

◆ Fidelity()

double q2ns::analysis::Fidelity ( const QState a,
const QState b 
)

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.

Parameters
aFirst state.
bSecond state.
Returns
Fidelity in the range [0.0, 1.0].
Exceptions
std::invalid_argumentif the states are empty.
std::runtime_errorif the states have different sizes, use unsupported backends, or require unavailable backend-specific functionality.
See also
QState

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsPure()

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.

Parameters
sInput state.
tolAbsolute tolerance for comparing purity against 1.0.
Returns
True if the state is pure within tolerance, false otherwise.
Exceptions
std::invalid_argumentif the state is empty or if tol is negative.
std::runtime_errorif the backend is unsupported or requires unavailable backend-specific functionality.
See also
Purity
QState

Definition at line 280 of file q2ns-analysis.cc.

References q2ns::analysis::Purity().

Here is the call graph for this function:

◆ 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.

Parameters
sInput state.
Returns
Purity in the range [0.0, 1.0], up to numerical tolerance.
Exceptions
std::invalid_argumentif the state is empty.
std::runtime_errorif the backend is unsupported or requires unavailable backend-specific functionality.
See also
IsPure
VonNeumannEntropy
QState

Definition at line 264 of file q2ns-analysis.cc.

References q2ns::QState::NumQubits().

Referenced by q2ns::analysis::IsPure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TraceDistance()

double q2ns::analysis::TraceDistance ( const QState a,
const QState b 
)

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.

Parameters
aFirst state.
bSecond state.
Returns
Trace distance in the range [0.0, 1.0], up to numerical tolerance.
Exceptions
std::invalid_argumentif the states are empty.
std::runtime_errorif the states have different sizes, use unsupported backends, or require unavailable backend-specific functionality.
See also
Fidelity
VonNeumannEntropy
QState

Definition at line 337 of file q2ns-analysis.cc.

References q2ns::QState::NumQubits().

Here is the call graph for this function:

◆ VonNeumannEntropy()

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.

Parameters
sInput state.
Returns
von Neumann entropy in bits.
Exceptions
std::invalid_argumentif the state is empty.
std::runtime_errorif the backend is unsupported, if the backend requires unavailable functionality, or if the density matrix is not positive semidefinite within numerical tolerance.
See also
Purity
TraceDistance
QState

Definition at line 290 of file q2ns-analysis.cc.

References q2ns::H, and q2ns::QState::NumQubits().

Here is the call graph for this function: