TrainShape

class trainsum.trainshape.TrainShape(dims, cores, ranks=1)

Class for representing the structure of a quantics tensor train. The shape consists of one or multiple dimensions, which are each represented as a sequence of digits. The digits are grouped into cores that are connected linearly.

Parameters:
property dims: Sequence[Dimension]

Dimensions of the shape. Cannot be set.

property digits: Sequence[Sequence[Digit]]

Digits that are grouped to cores. Cannot be set.

property ranks: Sequence[int]

Ranks between the cores. The length of ranks is one less than the number of cores. Setting the ranks to None will set the ranks to the maximum possible values, for representing a tensor exactly. The ranks can also be set to an integer, which will set all ranks to the minimum of the given integer and the maximum possible value. Otherwise, the ranks can be set individually by providing a sequence of integers.

left_rank(idx)

Get the left rank of the core at index idx.

Parameters:

idx (int)

Return type:

int

right_rank(idx)

Get the right rank of the core at index idx.

Parameters:

idx (int)

Return type:

int

middle(idx)

Get the bases of the digits in the core at index idx.

Parameters:

idx (int)

Return type:

Sequence[int]

reverse()

return a new TrainShape with reversed order of cores and digits.

Return type:

TrainShape

permute_dims(order)

Permute the dimensions of the shape according to the given order.

Parameters:

order (Sequence[int])

Return type:

None