Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Network::SimpleHost< Time > Class Template Reference

The simple host implementation. More...

#include <SimpleHost.h>

Inheritance diagram for Network::SimpleHost< Time >:
Network::IHost< Types::time_type >

Public Member Functions

 SimpleHost (size_t hostId, size_t startQubitId, size_t numQubits, size_t startClassicalBitId, size_t numClassicalBits)
 The constructor.
size_t GetId () const override
 Get the host id.
size_t GetNumQubits () const override
 Get the number of qubits.
size_t GetNumNetworkEntangledQubits () const override
 Get the number of network entangled qubits.
size_t GetNumClassicalBits () const override
 Get the number of classical bits.
bool IsQubitOnHost (size_t qubitId) const override
 Check if a qubit is in the host.
bool AreQubitsOnSameHost (size_t qubitId1, size_t qubitId2) const override
 Check if two qubits are in the same host.
bool IsClassicalBitOnHost (size_t cbitId) const override
 Check if a classical bit is in the host.
bool IsEntangledQubitOnHost (size_t qubitId) const override
 Check if a qubit used for entanglement between hosts is in the host.
bool AreCbitsOnSameHost (size_t cbitId1, size_t cbitId2) const override
 Check if two classical bits are in the same host.
std::vector< size_t > GetQubitsIds () const override
 Get the ids of the qubits in the host.
std::vector< size_t > GetNetworkEntangledQubitsIds () const override
 Get the ids of the qubits used for entanglement between hosts in the host.
std::vector< size_t > GetClassicalBitsIds () const override
 Get the ids of the classical bits in the host.
std::vector< size_t > GetEntangledQubitMeasurementBitIds () const override
 Get the ids of the classical bits used for measurement of the qubits used for entanglement between hosts present in the host.
bool SendPacketToHost (size_t hostId, const std::vector< uint8_t > &packet) override
 Send a packet to a host.
bool RecvPacketFromHost (size_t hostId, const std::vector< uint8_t > &packet) override
 Receive a packet from a host.
size_t GetStartQubitId () const override
 Get the id of the first qubit assigned to the host.
size_t GetStartClassicalBitId () const override
 Get the id of the first classical bit assigned to the host.
void SetEntangledQubitId (size_t id)
 Set the id of the qubit used for entanglement between hosts.
void SetEntangledQubitMeasurementBit (size_t id)
 Set the id of the classical bit used for measurement of the qubit used for entanglement between hosts.
Public Member Functions inherited from Network::IHost< Types::time_type >
virtual ~IHost ()=default
 The destructor.
std::shared_ptr< IHost< Types::time_type > > getptr ()
 Get a shared pointer to this object.

Detailed Description

template<typename Time = Types::time_type>
class Network::SimpleHost< Time >

The simple host implementation.

A simple host, having just a single qubit for entanglement between hosts, the qubits and classical bits are contiguous.

Template Parameters
TimeThe time type for the execution time.
See also
SimpleController
SimpleNetwork

Definition at line 44 of file SimpleHost.h.

Constructor & Destructor Documentation

◆ SimpleHost()

template<typename Time = Types::time_type>
Network::SimpleHost< Time >::SimpleHost ( size_t hostId,
size_t startQubitId,
size_t numQubits,
size_t startClassicalBitId,
size_t numClassicalBits )
inline

The constructor.

The host will have one qubit more than the specified number, for entanglement with other hosts. It will also have one classical bit more than the specified number, for the measurement of the entangled qubit.

Parameters
hostIdThe id of the host.
startQubitIdThe id of the first qubit assigned to the host.
numQubitsThe number of qubits assigned to the host.
startClassicalBitIdThe id of the first classical bit assigned to the host.
numClassicalBitsThe number of classical bits assigned to the host.

Definition at line 60 of file SimpleHost.h.

Member Function Documentation

◆ AreCbitsOnSameHost()

template<typename Time = Types::time_type>
bool Network::SimpleHost< Time >::AreCbitsOnSameHost ( size_t cbitId1,
size_t cbitId2 ) const
inlineoverridevirtual

Check if two classical bits are in the same host.

Checks if two classical bits with the specified ids are in the same host.

Returns
True if the classical bits are on the same host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 163 of file SimpleHost.h.

◆ AreQubitsOnSameHost()

template<typename Time = Types::time_type>
bool Network::SimpleHost< Time >::AreQubitsOnSameHost ( size_t qubitId1,
size_t qubitId2 ) const
inlineoverridevirtual

Check if two qubits are in the same host.

Checks if two qubits with the specified ids are in the same host, excluding the one(s) used only for entanglement with other hosts.

Returns
True if the qubits are on the same host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 126 of file SimpleHost.h.

◆ GetClassicalBitsIds()

template<typename Time = Types::time_type>
std::vector< size_t > Network::SimpleHost< Time >::GetClassicalBitsIds ( ) const
inlineoverridevirtual

Get the ids of the classical bits in the host.

Obtain the ids of the classical bits in the host.

Returns
The ids of the classical bits in the host.

Implements Network::IHost< Types::time_type >.

Definition at line 204 of file SimpleHost.h.

◆ GetEntangledQubitMeasurementBitIds()

template<typename Time = Types::time_type>
std::vector< size_t > Network::SimpleHost< Time >::GetEntangledQubitMeasurementBitIds ( ) const
inlineoverridevirtual

Get the ids of the classical bits used for measurement of the qubits used for entanglement between hosts present in the host.

Obtain the ids of the classical bits used for measurement of the qubits used for entanglement between hosts present in the host.

Returns
The ids of the classical bits used for measurement of the qubits used for entanglement between hosts present in the host.

Implements Network::IHost< Types::time_type >.

Definition at line 221 of file SimpleHost.h.

◆ GetId()

template<typename Time = Types::time_type>
size_t Network::SimpleHost< Time >::GetId ( ) const
inlineoverridevirtual

Get the host id.

Obtain a host id used to identify the host in the network.

Returns
The host id.

Implements Network::IHost< Types::time_type >.

Definition at line 72 of file SimpleHost.h.

◆ GetNetworkEntangledQubitsIds()

template<typename Time = Types::time_type>
std::vector< size_t > Network::SimpleHost< Time >::GetNetworkEntangledQubitsIds ( ) const
inlineoverridevirtual

Get the ids of the qubits used for entanglement between hosts in the host.

Obtain the ids of the qubits used for entanglement between hosts in the host.

Returns
The ids of the qubits used for entanglement between hosts in the host.

Implements Network::IHost< Types::time_type >.

Definition at line 191 of file SimpleHost.h.

◆ GetNumClassicalBits()

template<typename Time = Types::time_type>
size_t Network::SimpleHost< Time >::GetNumClassicalBits ( ) const
inlineoverridevirtual

Get the number of classical bits.

Obtain the number of classical bits in the host. This does not include the bits used for measurement of the network entangled qubits.

Returns
The number of classical bits.

Implements Network::IHost< Types::time_type >.

Definition at line 106 of file SimpleHost.h.

◆ GetNumNetworkEntangledQubits()

template<typename Time = Types::time_type>
size_t Network::SimpleHost< Time >::GetNumNetworkEntangledQubits ( ) const
inlineoverridevirtual

Get the number of network entangled qubits.

Obtain the number of qubits in the host used for entanglement with other hosts. The simple hosts have only one such qubit.

Returns
The number of network entangled qubits, in this case, one.

Implements Network::IHost< Types::time_type >.

Definition at line 91 of file SimpleHost.h.

◆ GetNumQubits()

template<typename Time = Types::time_type>
size_t Network::SimpleHost< Time >::GetNumQubits ( ) const
inlineoverridevirtual

Get the number of qubits.

Obtain the number of qubits in the host, excluding the one(s) used only for entanglement with other hosts.

Returns
The number of qubits.

Implements Network::IHost< Types::time_type >.

Definition at line 81 of file SimpleHost.h.

◆ GetQubitsIds()

template<typename Time = Types::time_type>
std::vector< size_t > Network::SimpleHost< Time >::GetQubitsIds ( ) const
inlineoverridevirtual

Get the ids of the qubits in the host.

Obtain the ids of the qubits in the host, excluding the one(s) used only for entanglement with other hosts.

Returns
The ids of the qubits in the host.

Implements Network::IHost< Types::time_type >.

Definition at line 174 of file SimpleHost.h.

◆ GetStartClassicalBitId()

template<typename Time = Types::time_type>
size_t Network::SimpleHost< Time >::GetStartClassicalBitId ( ) const
inlineoverridevirtual

Get the id of the first classical bit assigned to the host.

Obtain the id of the first classical bit assigned to the host, the other ones are assigned contiquously.

Returns
The id of the first classical bit assigned to the host.

Implements Network::IHost< Types::time_type >.

Definition at line 279 of file SimpleHost.h.

◆ GetStartQubitId()

template<typename Time = Types::time_type>
size_t Network::SimpleHost< Time >::GetStartQubitId ( ) const
inlineoverridevirtual

Get the id of the first qubit assigned to the host.

Obtain the id of the first qubit assigned to the host, the other ones are assigned contiquously.

Returns
The id of the first qubit assigned to the host.

Implements Network::IHost< Types::time_type >.

Definition at line 269 of file SimpleHost.h.

◆ IsClassicalBitOnHost()

template<typename Time = Types::time_type>
bool Network::SimpleHost< Time >::IsClassicalBitOnHost ( size_t cbitId) const
inlineoverridevirtual

Check if a classical bit is in the host.

Checks if a classical bit with the specified id is in the host.

Returns
True if the classical bit is on this host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 136 of file SimpleHost.h.

◆ IsEntangledQubitOnHost()

template<typename Time = Types::time_type>
bool Network::SimpleHost< Time >::IsEntangledQubitOnHost ( size_t qubitId) const
inlineoverridevirtual

Check if a qubit used for entanglement between hosts is in the host.

Checks if a qubit used for entanglement between hosts with the specified id is in the host.

Returns
True if the network entangled qubit is on this host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 150 of file SimpleHost.h.

◆ IsQubitOnHost()

template<typename Time = Types::time_type>
bool Network::SimpleHost< Time >::IsQubitOnHost ( size_t qubitId) const
inlineoverridevirtual

Check if a qubit is in the host.

Checks if a qubit with the specified id is in the host, excluding the one(s) used only for entanglement with other hosts.

Returns
True if the qubit is on this host, false otherwise.

Implements Network::IHost< Types::time_type >.

Definition at line 115 of file SimpleHost.h.

◆ RecvPacketFromHost()

template<typename Time = Types::time_type>
bool Network::SimpleHost< Time >::RecvPacketFromHost ( size_t hostId,
const std::vector< uint8_t > & packet )
inlineoverridevirtual

Receive a packet from a host.

Not used in this simple host implementation, classical packets receiving is not simulated, the classical bits are implicitely shared using the classical state for the quantum computing simulation for the network.

Parameters
hostIdThe id of the host to receive the packet from.
packetThe packet to receive.
Returns
False.

Implements Network::IHost< Types::time_type >.

Definition at line 256 of file SimpleHost.h.

◆ SendPacketToHost()

template<typename Time = Types::time_type>
bool Network::SimpleHost< Time >::SendPacketToHost ( size_t hostId,
const std::vector< uint8_t > & packet )
inlineoverridevirtual

Send a packet to a host.

Send a packet to a host. Not used in this simple host implementation, classical packets sending is not simulated, the classical bits are implicitely shared using the classical state for the quantum computing simulation for the network.

Parameters
hostIdThe id of the host to send the packet to.
packetThe packet to send.
Returns
False.

Implements Network::IHost< Types::time_type >.

Definition at line 240 of file SimpleHost.h.

◆ SetEntangledQubitId()

template<typename Time = Types::time_type>
void Network::SimpleHost< Time >::SetEntangledQubitId ( size_t id)
inline

Set the id of the qubit used for entanglement between hosts.

Sets the id of the qubit used for entanglement between hosts. Typically the convention is to allocate them in the simulators after all the qubits for all the hosts were allocated, so they are assigned in order, one for each host, with id number after the last qubit assigned to all hosts.

Definition at line 290 of file SimpleHost.h.

◆ SetEntangledQubitMeasurementBit()

template<typename Time = Types::time_type>
void Network::SimpleHost< Time >::SetEntangledQubitMeasurementBit ( size_t id)
inline

Set the id of the classical bit used for measurement of the qubit used for entanglement between hosts.

Sets the id of the classical bit used for measurement of the qubit used for entanglement between hosts. Typically the convention is to allocate them in the classical state of the quantum simulators after all the classical bits for all the hosts were allocated, so they are assigned in order, one for each host, with id number after the last classical bit assigned to all hosts.

Definition at line 303 of file SimpleHost.h.


The documentation for this class was generated from the following file: