sys-sage
|
Represents a physical or logical qubit in a quantum backend. More...
#include <Qubit.hpp>
Public Member Functions | |
Qubit (int _id=0, std::string _name="Qubit") | |
Qubit constructor (no automatic insertion in the Component Tree). | |
Qubit (Component *parent, int _id=0, std::string _name="Qubit") | |
Qubit constructor with insertion into the Component Tree as the parent's child (as long as parent is an existing Component). | |
void | SetProperties (double t1, double t2, double readout_fidelty, double q1_fidelity=0, double readout_length=0) |
Sets the properties of the qubit. | |
double | GetT1 () const |
Gets the T1 relaxation time of the qubit. | |
double | GetT2 () const |
Gets the T2 dephasing time of the qubit. | |
double | GetReadoutFidelity () const |
Gets the readout fidelity of the qubit. | |
double | Get1QFidelity () const |
Gets the 1Q fidelity of the qubit. | |
double | GetReadoutLength () const |
Gets the readout length of the qubit. | |
double | GetFrequency () const |
Gets the frequency of the qubit. | |
void | RefreshProperties () |
Refreshes the properties of the qubit. | |
![]() | |
Component (int _id=0, std::string _name="unknown") | |
Generic Component constructor (no automatic insertion in the Component Tree). Usually one of the derived subclasses for different Component Types will be created, not this one. | |
Component (Component *parent, int _id=0, std::string _name="unknown") | |
Generic Component constructor with insertion into the Component Tree as the parent's child. Usually one of the derived subclasses for different Component Types will be created. | |
void | InsertChild (Component *child) |
Inserts a child component to this component (in the Component Tree). The child pointer will be inserted at the end of the children vector. | |
int | InsertBetweenParentAndChild (Component *parent, Component *child, bool alreadyParentsChild) |
Inserts this component between a parent and one of its children. The parent component remains the parent, this Component becomes a new child of the parent, and the specified child becomes this component's child. | |
int | InsertBetweenParentAndChildren (Component *parent, std::vector< Component * > children, bool alreadyParentsChild) |
Inserts this component between a parent and a (subset of) its children. The parent component remains parent, this Component becomes a new child, and the children become parent's grandchildren. | |
int | RemoveChild (Component *child) |
Removes the passed component from the list of children, without completely deleting (and deallocating) the child itself. | |
void | SetParent (Component *parent) |
Set a parent to the component. This is usually used when inserting a component in the tree (by calling InsertChild on the parent, and calling SetParent on the child). | |
void | PrintSubtree () const |
Prints the whole subtree of this component (including the component itself) to stdout. The tree is printed in DFS order, so that the hierarchy can be easily seen. Each child is indented by " ". For each component in the subtree, the following is printed: "<string component type> (name <name>) id <id> - children: <num children> | |
void | PrintAllDataPathsInSubtree () |
Prints all DataPaths that go from or to components in the subtree. | |
void | PrintAllRelationsInSubtree (RelationType::type RelationType=RelationType::Any) |
Prints all Relations in the subtree. | |
const std::string & | GetName () const |
Returns name of the component. | |
void | SetName (std::string _name) |
Sets name of the component. | |
int | GetId () const |
Returns id of the component. | |
sys_sage::ComponentType::type | GetComponentType () const |
Returns component type of the component. The component type denotes which class the instance is (often stored as Component*, even though they are a member of one of the child classes). | |
std::string | GetComponentTypeStr () const |
Returns component type as a human-readable string, as defined in ComponentType::names. | |
const std::vector< Component * > & | GetChildren () const |
Returns a const reference to std::vector containing all children of the component (empty vector if no children). | |
Component * | GetParent () const |
Returns Component pointer to parent (or NULL if this component is the root) | |
Component * | GetChild (int _id) const |
Retrieve a Component* to a child with child.id=_id. Identical to GetChildById Should there be more children with the same id, the first match will be retrieved (i.e. the one with lower index in the children array.) | |
Component * | GetChildById (int _id) const |
Retrieve a Component* to a child with child.id=_id. Should there be more children with the same id, the first match will be retrieved (i.e. the one with lower index in the children array.) | |
Component * | GetChildByType (ComponentType::type _componentType) const |
Retrieve a Component* to a child matching the given component type. Should there be more children with the same type, the first match will be retrieved (i.e. the one with lower index in the children array.) | |
std::vector< Component * > | GetAllChildrenByType (ComponentType::type _componentType) const |
Searches for all children matching the given component type. | |
void | GetAllChildrenByType (std::vector< Component * > *_outArray, ComponentType::type _componentType) const |
Searches for all the children matching the given component type. | |
Component * | GetSubcomponentById (int _id, ComponentType::type _componentType) |
Searches the subtree to find a component with a matching id and componentType, i.e. looks for a certain component with a matching ID. The search is a DFS. The search starts with the calling component. | |
void | GetAllSubcomponentsByType (std::vector< Component * > *outArray, ComponentType::type _componentType) |
Searches for all the subcomponents (children, their children and so on) matching the given component type. | |
std::vector< Component * > | GetAllSubcomponentsByType (ComponentType::type _componentType) |
Searches for all the subcomponents (children, their children and so on) matching the given component type. | |
int | CountAllSubcomponents () const |
Counts number of subcomponents (children, grandchildren, etc.). | |
int | CountAllSubcomponentsByType (ComponentType::type _componentType) const |
Counts number of subcomponents (children, their children and so on) matching the requested component type. | |
int | CountAllChildrenByType (ComponentType::type _componentType) const |
Counts number of children matching the requested component type. | |
Component * | GetAncestorByType (ComponentType::type _componentType) |
Moves up the tree until a parent of the given type is found. | |
int | GetSubtreeDepth () const |
Retrieves maximal distance to a leaf (i.e. the depth of the subtree). 0=leaf, 1=children are leaves, 2=at most children's children are leaves ..... | |
Component * | GetNthAncestor (int n) |
Retrieves Nth ancestor, which resides N levels above. E.g. if n=1, the parent is retrieved; if n=2, the grandparent is retrieved and so on. | |
void | GetNthDescendents (std::vector< Component * > *outArray, int depth) |
Retrieves a std::vector of Component pointers, which reside 'depth' levels deeper. The tree is traversed in order as the children are stored in std::vector children. E.g. if depth=1, only children of the current are retrieved; if depth=2, only children of the children are retrieved.. | |
std::vector< Component * > | GetNthDescendents (int depth) |
Retrieves a std::vector of Component pointers, which reside 'depth' levels deeper. The tree is traversed in order as the children are stored in the std::vector. E.g. if depth=1, only children of the current are retrieved; if depth=2, only children of the children are retrieved.. | |
void | GetSubcomponentsByType (std::vector< Component * > *outArray, int componentType) |
Retrieves a std::vector of Component pointers, which reside in the subtree and have a matching type. The tree is traversed DFS in order as the children are stored in each std::vector children. | |
std::vector< Component * > | GetSubcomponentsByType (ComponentType::type _componentType) |
Retrieves a std::vector of Component pointers, which reside in the subtree and have a matching type. The tree is traversed DFS in order as the children are stored in the std::vector. | |
void | GetComponentsInSubtree (std::vector< Component * > *outArray) |
Retrieves a std::vector of Component pointers, which form the subtree (current node and all the subcomponents) of this. | |
std::vector< Component * > | GetComponentsInSubtree () |
Retrieves a std::vector of Component pointers, which form the subtree (current node and all the subcomponents) of this. | |
const std::vector< Relation * > & | GetRelations (RelationType::type relationType) const |
Returns a (const) reference to the internal vector of relations for a given type. | |
std::vector< Relation * > | GetAllRelationsBy (RelationType::type relationType=RelationType::Any, int thisComponentPosition=-1) const |
Returns a newly-constructed vector of all relations of a given type and position. | |
DataPath * | GetDataPathByType (DataPathType::type dp_type, DataPathDirection::type direction=DataPathDirection::Any) const |
Retrieves a DataPath* from the list of this component's data paths with matching DataPathType and DataPathDirection. The first match is returned. | |
void | GetAllDataPaths (std::vector< DataPath * > *outDpArr, DataPathType::type dp_type=DataPathType::Any, DataPathDirection::type direction=DataPathDirection::Any) const |
Retrieves all DataPath* from the list of this component's data paths with matching type and orientation. Results are returned in std::vector<DataPath*>* outDpArr, where first the matching data paths in dp_outgoing are pushed back, then the ones in dp_incoming. | |
std::vector< DataPath * > | GetAllDataPaths (DataPathType::type dp_type=DataPathType::Any, DataPathDirection::type direction=DataPathDirection::Any) const |
Retrieves all DataPath* from the list of this component's data paths with matching type and orientation/direction. Results are returned in a std::vector<DataPath*>*. | |
int | CheckComponentTreeConsistency () const |
Checks the consistency of the component tree starting from this component. | |
int | GetTopologySize (unsigned *out_component_size, unsigned *out_dataPathSize) const |
Calculates approximate memory footprint of the subtree of this element (including the relevant Relations). | |
int | GetDepth (bool refresh) |
Retrieves the depth (level) of a component in the topology. | |
void | DeleteRelation (Relation *r) |
Deletes a Relation from this component as well as the Relation itself. | |
void | DeleteDataPath (DataPath *dp) |
Deletes and deallocates the DataPath pointer from the list of outgoing/incoming DataPaths. | |
void | DeleteAllRelations (RelationType::type relationType=RelationType::Any) |
Deletes all relations of this component (optionally filtered by type). | |
void | DeleteAllDataPaths () |
Deletes all DataPaths of this component. | |
void | DeleteSubtree () const |
void | Delete (bool withSubtree=true) |
Deletes a component, its children (if withSubtree = true), and all associated Relations. If only the component itself is deleted, its children are inserted into its parent's children list. | |
Additional Inherited Members | |
![]() | |
std::map< std::string, void * > | attrib |
![]() | |
Component (int _id, std::string _name, ComponentType::type _componentType) | |
Protected constructor for derived classes (no automatic insertion in the Component Tree). | |
Component (Component *parent, int _id, std::string _name, ComponentType::type _componentType) | |
Protected constructor for derived classes with insertion into the Component Tree. | |
![]() | |
int | id |
int | depth |
std::string | name |
int | count {-1} |
const ComponentType::type | componentType |
std::vector< Component * > | children |
Component * | parent { nullptr } |
std::array< std::vector< Relation * > *, RelationType::_num_relation_types > * | relations = nullptr |
Represents a physical or logical qubit in a quantum backend.
Inherits from Component and provides quantum-specific properties such as T1, T2, readout fidelity, and calibration time. Qubit objects are used to describe the quantum resources available in a QuantumBackend and can be extended with additional properties as needed for specific hardware or simulation backends.
sys_sage::Qubit::Qubit | ( | int | _id = 0, |
std::string | _name = "Qubit" ) |
sys_sage::Qubit::Qubit | ( | Component * | parent, |
int | _id = 0, | ||
std::string | _name = "Qubit" ) |
Qubit constructor with insertion into the Component Tree as the parent's child (as long as parent is an existing Component).
parent | Pointer to the parent component |
_id | Numeric ID of the qubit (default 0) |
_name | Name of the qubit (default "Qubit") |
Sets componentType to sys_sage::ComponentType::Qubit.
double sys_sage::Qubit::Get1QFidelity | ( | ) | const |
Gets the 1Q fidelity of the qubit.
double sys_sage::Qubit::GetFrequency | ( | ) | const |
Gets the frequency of the qubit.
double sys_sage::Qubit::GetReadoutFidelity | ( | ) | const |
Gets the readout fidelity of the qubit.
double sys_sage::Qubit::GetReadoutLength | ( | ) | const |
Gets the readout length of the qubit.
double sys_sage::Qubit::GetT1 | ( | ) | const |
Gets the T1 relaxation time of the qubit.
double sys_sage::Qubit::GetT2 | ( | ) | const |
Gets the T2 dephasing time of the qubit.
void sys_sage::Qubit::SetProperties | ( | double | t1, |
double | t2, | ||
double | readout_fidelty, | ||
double | q1_fidelity = 0, | ||
double | readout_length = 0 ) |
Sets the properties of the qubit.
t1 | The T1 relaxation time. |
t2 | The T2 dephasing time. |
readout_fidelity | The readout fidelity. |
q1_fidelity | 1-qubit gate fidelity (optional, default 0). |
readout_length | The readout length (optional, default 0). |
These properties are important for quantum error modeling and backend calibration.