Pauli Class #66
dsvandet
started this conversation in
Project Notes
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
These notes are related to the Pauli class representing a Pauli Operators from the quantum_info modulo of qiskit-terra
These notes are in regards to satisfying the following requirement:
Location of Code
Currently these changes are staged at dsvandet/qiskit-terra/tree/paulilist_representations.
Modifications and additions to
PauliclassMoved
_from_label,_split_pauli_label,_phase_from_complexfunctions to the PauliRep class with some functions being updated to be more general etc. See PauliRep Class notes. PauliRep is now a base class of BasePauliRemoved _VALID_LABEL_PATTERN as no longer need here. A more general method can be found in PauliRep class. See PauliRep Class notes.
Added input variable to
__init__method:input_qubit_orderwith default value of"right-to-left". This flag controls the order in which input string representations are indexed for qubits. The internal order is not changed. The option"right-to-left"reads a Pauli strings right to left. For example: the Pauli string"XZY"would haveYon qubit 0,Zon qubit 1 andXand qubit 2. Where as the value "left-to-right" option reads Pauli strings left to right. For example: the Pauli string"XZY"would haveXon qubit 0,Zon qubit 1 andYon qubit 2. The flag only has an effect on product string representations and not index representations.Added a new ability to use
QubitMapsto access elements of a Pauli via labels defined in those Maps. For example ifP=Pauli("iXYZ")then normallyP[0]will return the Pauli attached to qubit 0 - soZin this example. If aQubitMapis registered with the Pauli (instance or class) and is assigned/activated then a different indexing can be used based on that Map. For example: Consider theQubitMapthat has(0,0)->0, (0,1)->1, (1,0)->2and(1,1)->3. Then for the PauliP=Pauli("XYZI")we would haveP[(0,1)]=Zetc. See TranslationMap section below for more detailsTranslationMaps
For details on TranslationMap classes see Translation Classes
The
PauliandPauliLIstclass labels the quibts/Paulis as 0,1,2,... up tonum_qubits-1/num_paulis-1. The the__getitem__method is set so that subelements are accessed via this index. For example ifP=Pauli("XZY")thenP[0]=Yand ifL=PauliList("ZYXI", "XXYZ")thenP[0] = Pauli("ZYXI").It is often useful to be able to label and access these quits using different labels. This is done with the aid of
QubitMapinstance. A QubitMap is a specificTranslationMapthat maps labels into non-negative integers. To use aQubitMapwith aPauliorPauliListinstance a map needs to be registered and then activated/assigned to the__getitem__and/or__call__methods.A
QubitMapmay be registered with either the instance or the class. If a map is registered with an instance then only that instance can use that map. If the map is registered with the class (say Pauli class for example) then any instance of that class (herePauliinstances) may use that map. A map can be registered with none, either or both class and instance. Registration is done using either of the following the registration methods:At the moment the individual registration methods are semi-private but this is easily changed. The override switch allows one to overwrite a map with the same identifier. If no identifier is provided then one will be automatically generated. To use a registered map the map needs to be activated or assigned. This is done with the following methods:
If no maps are to be used then the
use_no_map()method can be used. You can check to see if a map is registered, with a given identifier, using one of the following methods:Examples:
See the TranslationMap Classes discussion for more examples and details TranslationMaps
The registered maps are stored in a dictionaries. These dictionaries can be accessed via the
class_map_dict()andinstance_map_dict()methods.The use of
QubitMaps is done by changing the__getitem__and__call__methods. The__getitem__method returns the__instance_getitem__method which is either set to return the__getitem_map__method or the__getitem_nomap__method. The__instance_getitem__method uses the QubitMap to translate the map labels or indices to the internal labels/indices. These translated labels are pass to the__getitem_nomap__method. If noQubitMapis being used then the__instance_getitem__method simply returns the__getitem_nomap__method.The
__call__method will use to function method within theQubitMapif one is present. The__getitem__method on the other hand will use what ever method is configured within theQubitMap.TODO: Currently the registration methods etc are coded into the
Pauliclass. We also need this for thePauliListClass and a map may need to be useable in bothPauliandPauliListclasses. Therefore we should move this capability to the BasePauli Class or some other class that can be used my other classes.Beta Was this translation helpful? Give feedback.
All reactions