Q2NS dev
ns-3 module
Loading...
Searching...
No Matches
Core Types and Gates

Shared enums, ids, locations, matrices, and gate helpers used across Q2NS. More...

Classes

class  q2ns::QGate
 Lightweight gate descriptor used by QState backends. More...
 
struct  q2ns::Location
 Current tracked location of a qubit. More...
 

Typedefs

using q2ns::Complex = std::complex< double >
 Complex scalar type used by matrix-based backends.
 
using q2ns::Matrix = Eigen::MatrixXcd
 Dynamic complex matrix type used for custom gates and matrix-based states.
 
using q2ns::Index = std::size_t
 Generic qubit index type within a backend state.
 
using q2ns::StateId = std::uint64_t
 Stable identifier for a registered backend state.
 
using q2ns::QubitId = std::uint64_t
 Stable identifier for a registered qubit handle.
 
using q2ns::QMapInstance = std::function< void(QNode &, std::shared_ptr< Qubit > &)>
 Per-transmission quantum map callable applied to a received qubit.
 
using q2ns::RecvCallback = ns3::Callback< void, std::shared_ptr< Qubit > >
 Callback invoked when a qubit is successfully received at a node.
 

Enumerations

enum class  q2ns::QGateKind {
  q2ns::QGateKind::Custom , q2ns::QGateKind::I , q2ns::QGateKind::X , q2ns::QGateKind::Y ,
  q2ns::QGateKind::Z , q2ns::QGateKind::H , q2ns::QGateKind::S , q2ns::QGateKind::SDG ,
  q2ns::QGateKind::CNOT , q2ns::QGateKind::CZ , q2ns::QGateKind::SWAP
}
 Enumerates built-in gate kinds. More...
 
enum class  q2ns::Basis { q2ns::Basis::Z , q2ns::Basis::X , q2ns::Basis::Y }
 Measurement basis for single-qubit projective measurement. More...
 
enum class  q2ns::QStateBackend { q2ns::QStateBackend::Ket , q2ns::QStateBackend::DM , q2ns::QStateBackend::Stab }
 Backend family used when creating new quantum states. More...
 
enum class  q2ns::LocationType { q2ns::LocationType::Node , q2ns::LocationType::Channel , q2ns::LocationType::Lost , q2ns::LocationType::Unset }
 Kind of simulated qubit location. More...
 

Functions

QStateBackend q2ns::BackendFromString (std::string_view s)
 Convert a backend name string to a QStateBackend enum value.
 
std::vector< QStateBackendq2ns::AllQStateBackends ()
 Return all supported backend enum values.
 
Location q2ns::MakeUnsetLocation ()
 Construct an Unset location value.
 

Detailed Description

Shared enums, ids, locations, matrices, and gate helpers used across Q2NS.

Typedef Documentation

◆ Complex

using q2ns::Complex = typedef std::complex<double>

Complex scalar type used by matrix-based backends.

Definition at line 37 of file q2ns-types.h.

◆ Index

using q2ns::Index = typedef std::size_t

Generic qubit index type within a backend state.

Definition at line 49 of file q2ns-types.h.

◆ Matrix

using q2ns::Matrix = typedef Eigen::MatrixXcd

Dynamic complex matrix type used for custom gates and matrix-based states.

Definition at line 43 of file q2ns-types.h.

◆ QMapInstance

using q2ns::QMapInstance = typedef std::function<void(QNode&, std::shared_ptr<Qubit>&)>

Per-transmission quantum map callable applied to a received qubit.

QMapInstance objects are typically produced by QMap::Sample() during channel transmission and later executed at the receiving node after the qubit becomes local there.

Definition at line 71 of file q2ns-types.h.

◆ QubitId

using q2ns::QubitId = typedef std::uint64_t

Stable identifier for a registered qubit handle.

Definition at line 61 of file q2ns-types.h.

◆ RecvCallback

using q2ns::RecvCallback = typedef ns3::Callback<void, std::shared_ptr<Qubit> >

Callback invoked when a qubit is successfully received at a node.

The callback is executed after the qubit has been adopted by the receiving node and any QMapInstance associated with the transmission has been applied.

Parameters
qubitReceived qubit handle.

Definition at line 82 of file q2ns-types.h.

◆ StateId

using q2ns::StateId = typedef std::uint64_t

Stable identifier for a registered backend state.

Definition at line 55 of file q2ns-types.h.

Enumeration Type Documentation

◆ Basis

enum class q2ns::Basis
strong

Measurement basis for single-qubit projective measurement.

Enumerator

Definition at line 88 of file q2ns-types.h.

◆ LocationType

enum class q2ns::LocationType
strong

Kind of simulated qubit location.

Enumerator
Node 

Qubit is local to a node identified by node id.

Channel 

Qubit is in transit on a channel identified by channel id.

Lost 

Qubit was lost and is no longer accessible.

Unset 

Qubit location has not yet been assigned.

Definition at line 124 of file q2ns-types.h.

◆ QGateKind

enum class q2ns::QGateKind
strong

Enumerates built-in gate kinds.

Custom represents a caller-supplied unitary matrix. All other values refer to predefined gates with built-in matrix definitions.

Enumerator
Custom 

Caller-supplied matrix.

SDG 
CNOT 
CZ 
SWAP 

Definition at line 37 of file q2ns-qgate.h.

◆ QStateBackend

enum class q2ns::QStateBackend
strong

Backend family used when creating new quantum states.

Enumerator
Ket 

State-vector backend.

DM 

Density-matrix backend.

Stab 

Stabilizer backend.

Definition at line 94 of file q2ns-types.h.

Function Documentation

◆ AllQStateBackends()

std::vector< QStateBackend > q2ns::AllQStateBackends ( )
inline

Return all supported backend enum values.

Returns
Vector containing all supported backend types.

Definition at line 116 of file q2ns-types.h.

References q2ns::DM, q2ns::Ket, and q2ns::Stab.

◆ BackendFromString()

QStateBackend q2ns::BackendFromString ( std::string_view  s)

Convert a backend name string to a QStateBackend enum value.

Parse a backend name string.

Unrecognized names fall back to QStateBackend::Ket.

Parameters
sBackend name string.
Returns
Corresponding backend enum value.

Definition at line 29 of file q2ns-qstate-registry.cc.

References q2ns::DM, q2ns::Ket, and q2ns::Stab.

Referenced by q2ns::NetController::SetQStateBackend().

Here is the caller graph for this function:

◆ MakeUnsetLocation()

Location q2ns::MakeUnsetLocation ( )
inline

Construct an Unset location value.

Returns
Location with type LocationType::Unset.

Definition at line 156 of file q2ns-types.h.

References q2ns::Location::type, and q2ns::Unset.

Referenced by q2ns::QStateRegistry::GetLocation(), q2ns::QStateRegistry::GetLocation(), and q2ns::QStateRegistry::Register().

Here is the caller graph for this function: