Z2Register

class samplomatic.virtual_registers.Z2Register(virtual_gates)[source]

Bases: GroupRegister

Virtual register of elements of Z2, the cyclic group of order 2.

Z2 is a group that contains two elements, which can be represented by \(0\) and \(1\). We define the group product as the bit-wise XOR operation, such that the cyclic properties \(0 * 0 = 1 * 1 = 0\) and \(0 * 1 = 0 * 1 = 1\) are satisfied.

Attributes Summary

CONVERTABLE_TYPES

Valid arguments for convert_to().

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.

Methods Summary

identity(num_subsystems, num_samples)

Instantiate a new register of identity virtual gates.

inplace_multiply(other[, subsystem_idxs])

Inplace-multiply each virtual gate with the corresponding element of other.

invert()

Return a new virtual register that inverts each virtual gate.

multiply(other[, subsystem_idxs])

Multiply each virtual gate with the corresponding element of other.

Attributes Documentation

CONVERTABLE_TYPES: frozenset[VirtualType] = frozenset({VirtualType.Z2})

Valid arguments for convert_to().

GATE_SHAPE: tuple[int, ...] = ()

The array shape of any single virtual gate.

SUBSYSTEM_SIZE: int = 1

The number of qubits each virtual gate acts on.

TYPE: VirtualType = 'z2'

The group name in 1-1 correspondence with this virtual gate type.

Methods Documentation

classmethod identity(num_subsystems, num_samples)[source]

Instantiate a new register of identity virtual gates.

inplace_multiply(other, subsystem_idxs: list[int] | slice = slice(None, None, None))[source]

Inplace-multiply each virtual gate with the corresponding element of other.

Parameters:
  • other – Another virtual register of the same type.

  • subsystem_idxs – The indices of the subsystems to multiply, in self.

Raises:

VirtualGateError – When the shapes do not match.

invert()[source]

Return a new virtual register that inverts each virtual gate.

multiply(other, subsystem_idxs: list[int] | slice = slice(None, None, None))[source]

Multiply each virtual gate with the corresponding element of other.

Parameters:
  • other – Another virtual register of the same type.

  • subsystem_idxs – The indices of the subsystems to multiply, in self.

Returns:

A new virtual register of the same type.

Raises:

VirtualGateError – When the shapes do not match.