![]() |
Q2NS dev
ns-3 module
|
Main user-facing per-node API for quantum operations and transmission. More...
#include <q2ns-qnode.h>
Public Member Functions | |
| QNode (QStateRegistry ®istry) | |
| Construct a node bound to a shared state registry. | |
| ~QNode () override | |
| Destructor. | |
| std::shared_ptr< Qubit > | GetQubit (const std::string &label) const |
| Lookup a local qubit by application label. | |
| std::shared_ptr< Qubit > | GetQubit (QubitId id) const |
| Lookup a local qubit by unique identifier. | |
| std::vector< std::shared_ptr< Qubit > > | GetLocalQubits () const |
| Return the qubits currently located at this node. | |
| void | AddDevice (ns3::Ptr< ns3::NetDevice > device) |
| Register a device with this node. | |
| void | AddRoute (uint32_t dstNodeId, uint32_t oif) |
| Add or replace a simple host route for quantum transmission. | |
| bool | Send (std::shared_ptr< Qubit > q, uint32_t dstNodeId) |
| Send a qubit toward a destination node. | |
| void | SetRecvCallback (RecvCallback cb) |
| Set the application-level receive callback. | |
| std::shared_ptr< Qubit > | CreateQubit (const std::string &label="") |
| Create a new local qubit initialized in the |0> state. | |
| std::shared_ptr< Qubit > | CreateQubit (const std::shared_ptr< QState > &state, const std::string &label="") |
| Create a new local qubit from an existing single-qubit backend state. | |
| std::pair< std::shared_ptr< Qubit >, std::shared_ptr< Qubit > > | CreateBellPair () |
| Create a local Bell pair in the |Phi+> state. | |
| std::shared_ptr< QState > | GetState (const std::shared_ptr< Qubit > &q) |
| Get the current backend state of a qubit. | |
| bool | Apply (const QGate &gate, const std::vector< std::shared_ptr< Qubit > > &qs) |
| Apply a gate to one or more local qubits. | |
| bool | Apply (const q2ns::Matrix &gate, const std::vector< std::shared_ptr< Qubit > > &qs) |
| Apply a custom matrix gate to one or more local qubits. | |
| int | Measure (const std::shared_ptr< Qubit > &q, q2ns::Basis basis=q2ns::Basis::Z) |
| Measure a local qubit in the given basis. | |
| std::pair< int, int > | MeasureBell (const std::shared_ptr< Qubit > &a, const std::shared_ptr< Qubit > &b) |
| Perform a Bell-state measurement on two local qubits. | |
Static Public Member Functions | |
| static ns3::TypeId | GetTypeId (void) |
| Get the ns-3 TypeId. | |
Private Member Functions | |
| void | AdoptQubit (const std::shared_ptr< Qubit > &q) |
| Mark a qubit as local to this node. | |
Private Attributes | |
| QStateRegistry & | registry_ |
| Shared state registry. | |
| std::unique_ptr< QProcessor > | processor_ |
| Internal local quantum processor. | |
| std::unique_ptr< QNetworker > | networker_ |
| Internal networking component. | |
Friends | |
| class | NetController |
| class | QNetworker |
Main user-facing per-node API for quantum operations and transmission.
QNode is the primary interface through which users create qubits, apply local operations, perform measurements, and send qubits to other nodes.
Internally, QNode delegates local quantum state manipulation to QProcessor and network-facing transmission and reception to QNetworker. These internal components operate against a shared QStateRegistry.
Responsibilities:
Definition at line 63 of file q2ns-qnode.h.
|
explicit |
Construct a node bound to a shared state registry.
| registry | Registry used for state and location tracking. |
Definition at line 34 of file q2ns-qnode.cc.
|
overridedefault |
Destructor.
| void q2ns::QNode::AddDevice | ( | ns3::Ptr< ns3::NetDevice > | device | ) |
Register a device with this node.
The device is added to the underlying ns-3 Node. If the device is a QNetDevice, it is also bound to this node's internal QNetworker so that quantum arrivals are forwarded upward correctly.
| device | Device to add. |
Definition at line 50 of file q2ns-qnode.cc.
References networker_.
| void q2ns::QNode::AddRoute | ( | uint32_t | dstNodeId, |
| uint32_t | oif | ||
| ) |
Add or replace a simple host route for quantum transmission.
The route maps a destination node id to an outgoing interface index in the internal QNetworker.
| dstNodeId | Destination node identifier. |
| oif | Outgoing interface index. |
Definition at line 44 of file q2ns-qnode.cc.
References networker_.
|
private |
Mark a qubit as local to this node.
This is an internal helper used by the receive path. Locality is tracked centrally by QStateRegistry through QProcessor.
| q | Qubit handle. |
Definition at line 145 of file q2ns-qnode.cc.
References processor_.
Referenced by q2ns::QNetworker::ReceiveFromDevice().
| bool q2ns::QNode::Apply | ( | const q2ns::Matrix & | gate, |
| const std::vector< std::shared_ptr< Qubit > > & | qs | ||
| ) |
Apply a custom matrix gate to one or more local qubits.
| gate | Gate matrix to wrap as a custom gate. |
| qs | Target qubits. |
Definition at line 114 of file q2ns-qnode.cc.
References Apply(), and q2ns::gates::Custom().
Apply a gate to one or more local qubits.
| gate | Gate to apply. |
| qs | Target qubits. |
Definition at line 108 of file q2ns-qnode.cc.
References processor_.
Referenced by Apply(), main(), and q2ns::DephasingQMap::Sample().
Create a local Bell pair in the |Phi+> state.
Definition at line 96 of file q2ns-qnode.cc.
References processor_.
| std::shared_ptr< Qubit > q2ns::QNode::CreateQubit | ( | const std::shared_ptr< QState > & | state, |
| const std::string & | label = "" |
||
| ) |
Create a new local qubit from an existing single-qubit backend state.
| state | Backend state to use for the created qubit. |
| label | Optional application-level qubit label. |
Definition at line 71 of file q2ns-qnode.cc.
References processor_.
| std::shared_ptr< Qubit > q2ns::QNode::CreateQubit | ( | const std::string & | label = "" | ) |
Create a new local qubit initialized in the |0> state.
| label | Optional application-level qubit label. |
Definition at line 65 of file q2ns-qnode.cc.
References processor_.
| std::vector< std::shared_ptr< Qubit > > q2ns::QNode::GetLocalQubits | ( | ) | const |
Return the qubits currently located at this node.
The returned vector is a snapshot taken at call time. No stable internal container is exposed, and element order is not guaranteed.
Definition at line 90 of file q2ns-qnode.cc.
References processor_.
| std::shared_ptr< Qubit > q2ns::QNode::GetQubit | ( | const std::string & | label | ) | const |
Lookup a local qubit by application label.
Labels are optional and need not be unique. Prefer GetQubit(QubitId) when a stable unique identifier is available.
| label | Application-level qubit label. |
Definition at line 78 of file q2ns-qnode.cc.
References processor_.
Lookup a local qubit by unique identifier.
| id | Qubit identifier. |
Definition at line 84 of file q2ns-qnode.cc.
References processor_.
Get the current backend state of a qubit.
| q | Target qubit. |
Definition at line 102 of file q2ns-qnode.cc.
References processor_.
|
static |
| int q2ns::QNode::Measure | ( | const std::shared_ptr< Qubit > & | q, |
| q2ns::Basis | basis = q2ns::Basis::Z |
||
| ) |
Measure a local qubit in the given basis.
| q | Target qubit. |
| basis | Measurement basis. Defaults to q2ns::Basis::Z. |
Definition at line 120 of file q2ns-qnode.cc.
References processor_.
| std::pair< int, int > q2ns::QNode::MeasureBell | ( | const std::shared_ptr< Qubit > & | a, |
| const std::shared_ptr< Qubit > & | b | ||
| ) |
Perform a Bell-state measurement on two local qubits.
| a | First qubit. |
| b | Second qubit. |
Definition at line 126 of file q2ns-qnode.cc.
References processor_.
| bool q2ns::QNode::Send | ( | std::shared_ptr< Qubit > | q, |
| uint32_t | dstNodeId | ||
| ) |
Send a qubit toward a destination node.
The qubit must be local to this node and a valid route must exist to the destination node.
| q | Qubit to send. |
| dstNodeId | Destination node identifier. |
Definition at line 133 of file q2ns-qnode.cc.
References networker_.
| void q2ns::QNode::SetRecvCallback | ( | RecvCallback | cb | ) |
Set the application-level receive callback.
The callback is invoked for qubits successfully delivered to this node after destination-side adoption and channel-map processing.
| cb | Callback invoked with the arriving qubit. |
Definition at line 139 of file q2ns-qnode.cc.
References networker_.
|
friend |
Definition at line 259 of file q2ns-qnode.h.
|
friend |
Definition at line 260 of file q2ns-qnode.h.
|
private |
Internal networking component.
Definition at line 257 of file q2ns-qnode.h.
Referenced by AddDevice(), AddRoute(), Send(), and SetRecvCallback().
|
private |
Internal local quantum processor.
Definition at line 256 of file q2ns-qnode.h.
Referenced by AdoptQubit(), Apply(), CreateBellPair(), CreateQubit(), CreateQubit(), GetLocalQubits(), GetQubit(), GetQubit(), GetState(), Measure(), and MeasureBell().
|
private |
Shared state registry.
Definition at line 255 of file q2ns-qnode.h.