Subsystems

class trueq.Subsystems(subsystems=None)

Represents a collection of quantum subsystems. Each subsystem is represented as a sorted tuple of qudit labels, and a particular subsystem can appear only once in the collection.

import trueq as tq

tq.Subsystems([0, [1, 2], 3])
Subsystems(((0,), (3,), (1, 2)))
Parameters

subsystems (Iterable) – A list of lists of subsystem labels. For convenience, isolated labels are treated as a list of length 1, for example, labels = [0, [1, 2], 3] is equivalent to labels = [[0], [1, 2], [3]].

property subsystems

All the subsystems, sorted first by subsystem size and then lexicographically by the subsystem labels.

import trueq as tq

subsys = tq.Subsystems([0, 2, [1, 2], 1, [0, 1, 2]])
subsys.subsystems
((0,), (1,), (2,), (1, 2), (0, 1, 2))
Type

tuple

property labels

The sorted union of all system labels in this Subsystems.

import trueq as tq

subsys = tq.Subsystems([0, [0, 1], [0, 1, 2]])
subsys.labels
(0, 1, 2)
Type

tuple

property n_sys

The number of distinct system labels in this Subsystems.

import trueq as tq

subsys = tq.Subsystems([0, [0, 1], [0, 1, 2]])
subsys.n_sys
3
Type

int

static from_cycle(cycle, twirl=None)

Returns a new Subsystems containing all the subsystems acted on by the Gates of a given Cycle.

import trueq as tq

cycle = tq.Cycle({0: tq.Gate.h, (2, 3): tq.Gate.cnot})
twirl = tq.Twirl("P", range(4))

tq.Subsystems.from_cycle(cycle, twirl=twirl)
Subsystems(((0,), (1,), (2, 3)))
Parameters
  • cycle (Cycle) – The cycle to specify the subsystems for.

  • twirl (Twirl) – The Twirl used with this cycle. Setting this will include the non-overlapping labels of the twirl as subsystems in addition to the labels of this cycle.

Return type

Subsystems

Raises
  • ValueError – If the twirl is missing subsystems present in the cycle.

  • ValueError – If the subsystems in the twirl partially overlap with those in the cycle.

combinations(k)

Returns a new Subsystems where all combinations of up to k of these subsystems are included.

import trueq as tq

subsys = tq.Subsystems([0, 2, [1, 3]])
subsys.combinations(2)
Subsystems(((0,), (2,), (0, 2), (1, 3), (0, 1, 3), (1, 2, 3)))
Parameters

k (int) – The maximum number of combinations to include.

Return type

Subsystems

intersection(labels)

Returns a new Subsystems of labels that are the intersections of this Subsystems with a given labels.

import trueq as tq

subsys = tq.Subsystems([0, [0, 1], [1, 2]])
subsys.intersection([0, 2])
Subsystems(((0,), (2,)))
Parameters

labels (Iterable) – A label to intersect this Subsystems with.

Return type

Subsystems