VirtualRegister¶
- class samplomatic.virtual_registers.VirtualRegister(virtual_gates: ndarray)[source]¶
Bases:
objectA data register containing a 2D array of virtual gates.
Each virtual gate itself has a shape equal to
GATE_SHAPE, so the number of dimensions of the array owned by a virtual register is actually 2 plus one for each member of gate shape. The first two axes of the array are respectively reserved to represent the number of subsystems and the number of samples. For example, a virtual register representing 2-qubit unitaries might have an array of shape(5, 6, 4, 4)to store a 5x6 array of 4x4 complex unitary matrices.- Parameters:
virtual_gates – The virtual gates in this register.
- Raises:
VirtualGateError – If
virtual_gates’ shape is not understood.
Attributes Summary
Valid arguments for
convert_to().The data type of gate array elements.
The array shape of any single virtual gate.
The number of qubits each virtual gate acts on.
The group name in 1-1 correspondence with this virtual gate type.
The number of samples in this register.
The number of subsystems in this register.
The shape of this register, excluding the trailing shape due to gate shape.
The total number of virtual gates in this register.
The virtual gates of the virtual gates in this register.
Methods Summary
convert_to(register_type)Convert this register type to some other type, if possible.
copy()Generate a copy of this virtual register.
empty(num_subsystems, num_samples)Instantiate a new register.
identity(num_subsystems, num_samples)Instantiate a new register of identity virtual gates.
select(register_type)Select a
VirtualRegistersubclass based on aVirtualTypeenum.Attributes Documentation
- CONVERTABLE_TYPES: frozenset[VirtualType] = frozenset({})¶
Valid arguments for
convert_to().
- TYPE: VirtualType = NotImplemented¶
The group name in 1-1 correspondence with this virtual gate type.
- num_samples¶
The number of samples in this register.
- num_subsystems¶
The number of subsystems in this register.
- shape¶
The shape of this register, excluding the trailing shape due to gate shape.
- size¶
The total number of virtual gates in this register.
- virtual_gates¶
The virtual gates of the virtual gates in this register.
Methods Documentation
- convert_to(register_type: VirtualType) VirtualRegister[source]¶
Convert this register type to some other type, if possible.
- Parameters:
register_type – The type of register to convert to.
- Returns:
A new register of the specified output type, or this instance if its type is
register_type.- Raises:
VirtualGateError – If this type cannot be converted to the specified type.
- copy() VirtualRegister[source]¶
Generate a copy of this virtual register.
- classmethod empty(num_subsystems: int, num_samples: int) T[source]¶
Instantiate a new register.
The array element values are not initialized to any value, so it is expected that the user of this constructor overwrites them all.
- abstractmethod classmethod identity(num_subsystems: int, num_samples: int) T[source]¶
Instantiate a new register of identity virtual gates.
- static select(register_type: VirtualType) type[VirtualRegister][source]¶
Select a
VirtualRegistersubclass based on aVirtualTypeenum.- ..note::
Not all
VirtualRegisters need to define aTYPE, though they will need to if they want to participate in many types ofNodeactions. Conversely, not everyVirtualTypemust correspond to aVirtualRegister, most notably intermediate abstractions likeVirtualTypecan correspond to at most oneVirtualRegistertype.
- Parameters:
register_type – The identifier of the type to select.
- Returns:
The unique subclass associated with the
register_type, if any.