---
title: Z2Register (latest version)
description: API reference for samplomatic.virtual_registers.Z2Register in the latest version of samplomatic
source: https://quantum.cloud.ibm.com/docs/en/api/samplomatic/auto/virtual-registers-z-2-register
---

# Z2Register

*class* `samplomatic.virtual_registers.Z2Register(virtual_gates)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/virtual_registers/z2_register.py#L23-L78)

Bases: [`GroupRegister`](/docs/api/samplomatic/auto/virtual-registers-group-register "samplomatic.virtual_registers.group_register.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`](#samplomatic.virtual_registers.Z2Register.CONVERTABLE_TYPES "samplomatic.virtual_registers.Z2Register.CONVERTABLE_TYPES") | Valid arguments for [`convert_to()`](#samplomatic.virtual_registers.Z2Register.convert_to "samplomatic.virtual_registers.Z2Register.convert_to"). |
| [`GATE_SHAPE`](#samplomatic.virtual_registers.Z2Register.GATE_SHAPE "samplomatic.virtual_registers.Z2Register.GATE_SHAPE")                      | The array shape of any single virtual gate.                                                                                                       |
| [`SUBSYSTEM_SIZE`](#samplomatic.virtual_registers.Z2Register.SUBSYSTEM_SIZE "samplomatic.virtual_registers.Z2Register.SUBSYSTEM_SIZE")          | The number of qubits each virtual gate acts on.                                                                                                   |
| [`TYPE`](#samplomatic.virtual_registers.Z2Register.TYPE "samplomatic.virtual_registers.Z2Register.TYPE")                                        | The group name in 1-1 correspondence with this virtual gate type.                                                                                 |

**Methods Summary**

|                                                                                                                                                                         |                                                                               |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [`convert_to`](#samplomatic.virtual_registers.Z2Register.convert_to "samplomatic.virtual_registers.Z2Register.convert_to")(register\_type)                              | Convert this register type to some other type, if possible.                   |
| [`identity`](#samplomatic.virtual_registers.Z2Register.identity "samplomatic.virtual_registers.Z2Register.identity")(num\_subsystems, num\_samples)                     | Instantiate a new register of identity virtual gates.                         |
| [`inplace_multiply`](#samplomatic.virtual_registers.Z2Register.inplace_multiply "samplomatic.virtual_registers.Z2Register.inplace_multiply")(other\[, subsystem\_idxs]) | Inplace-multiply each virtual gate with the corresponding element of `other`. |
| [`invert`](#samplomatic.virtual_registers.Z2Register.invert "samplomatic.virtual_registers.Z2Register.invert")()                                                        | Return a new virtual register that inverts each virtual gate.                 |
| [`multiply`](#samplomatic.virtual_registers.Z2Register.multiply "samplomatic.virtual_registers.Z2Register.multiply")(other\[, subsystem\_idxs])                         | Multiply each virtual gate with the corresponding element of `other`.         |

**Attributes Documentation**

### CONVERTABLE\_TYPES

Type: [`frozenset`](https://docs.python.org/3/builtins/stdtypes.html#frozenset)\[[`VirtualType`](/docs/api/samplomatic/auto/virtual-registers-virtual-type "samplomatic.virtual_registers.virtual_type.VirtualType")]

Default value: `frozenset({VirtualType.PAULI, VirtualType.Z2})`

Valid arguments for [`convert_to()`](#samplomatic.virtual_registers.Z2Register.convert_to "samplomatic.virtual_registers.Z2Register.convert_to").

### GATE\_SHAPE

Type: [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)\[[`int`](https://docs.python.org/3/builtins/functions.html#int), ...]

Default value: `()`

The array shape of any single virtual gate.

### SUBSYSTEM\_SIZE

Type: [`int`](https://docs.python.org/3/builtins/functions.html#int)

Default value: `1`

The number of qubits each virtual gate acts on.

### TYPE

Type: [`VirtualType`](/docs/api/samplomatic/auto/virtual-registers-virtual-type "samplomatic.virtual_registers.virtual_type.VirtualType")

Default value: `'z2'`

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

**Methods Documentation**

### convert\_to

`convert_to(register_type)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/virtual_registers/z2_register.py#L46-L51)

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**](/docs/api/samplomatic/auto/exceptions-virtual-gate-error "samplomatic.exceptions.VirtualGateError") – If this type cannot be converted to the specified type.

### identity

*classmethod* `identity(num_subsystems, num_samples)`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/virtual_registers/z2_register.py#L42-L44)

Instantiate a new register of identity virtual gates.

### inplace\_multiply

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

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/virtual_registers/z2_register.py#L62-L71)

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**](/docs/api/samplomatic/auto/exceptions-virtual-gate-error "samplomatic.exceptions.VirtualGateError") – When the shapes do not match.

### invert

`invert()`

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/virtual_registers/z2_register.py#L73-L74)

Return a new virtual register that inverts each virtual gate.

### multiply

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

[GitHub](https://github.com/Qiskit/samplomatic/tree/main/samplomatic/virtual_registers/z2_register.py#L53-L60)

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**](/docs/api/samplomatic/auto/exceptions-virtual-gate-error "samplomatic.exceptions.VirtualGateError") – When the shapes do not match.
