VirtualRegister
class samplomatic.virtual_registers.VirtualRegister(virtual_gates: ndarray)
Bases: object
A 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
Column 1 | Column 2 |
|---|---|
CONVERTABLE_TYPES | Valid arguments for convert_to(). |
DTYPE | The data type of gate array elements. |
GATE_SHAPE | The array shape of any single virtual gate. |
SUBSYSTEM_SIZE | The number of qubits each virtual gate acts on. |
TYPE | 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 Summary
Column 1 | Column 2 |
|---|---|
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 VirtualRegister subclass based on a VirtualType enum. |
Attributes Documentation
CONVERTABLE_TYPES
DTYPE
GATE_SHAPE
SUBSYSTEM_SIZE
TYPE
Type: VirtualType
Default value: 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
convert_to(register_type: VirtualType) → VirtualRegister
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
empty
classmethod empty(num_subsystems: int, num_samples: int) → T
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.
identity
abstractmethod classmethod identity(num_subsystems: int, num_samples: int) → T
Instantiate a new register of identity virtual gates.
select
static select(register_type: VirtualType) → type[VirtualRegister]
Select a VirtualRegister subclass based on a VirtualType enum.
Not all VirtualRegisters need to define a TYPE, though they will need to if they want to participate in many types of Node actions. Conversely, not every VirtualType must correspond to a VirtualRegister, most notably intermediate abstractions like VirtualType can correspond to at most one VirtualRegister type.
Parameters
register_type – The identifier of the type to select.
Returns
The unique subclass associated with the register_type, if any.