adpeps.utils.nested

Contains utility class that represents a collection of tensors of different types, with operations that can be applied to all contained tensors at once

class Nested(tensors)[source]

This is a helper class for the efficient contraction of variants of tensors, used in the energy evaluation of excited states

A Nested tensor contains the following variants (some may be empty):

  • tensors[0]: regular tensor (no B or Bd)

  • tensors[1]: (terms with) a single B tensor

  • tensors[2]: (terms with) a single Bd tensor

  • tensors[3]: (terms with) both a B and a Bd tensor

When two Nested tensors x,y are contracted, all combinations are taken into account and the result is again a Nested tensor, filled with the following variants:

  • tensors[0]: x[0] * y[0]

  • tensors[1]: x[1] * y[0] + x[0] * y[1]

  • tensors[2]: x[2] * y[0] + x[0] * y[2]

  • tensors[3]: x[3] * y[0] + x[2] * y[1] + x[1] * y[2] + x[0] * y[3]

By using Nested tensors in a (large) contraction, the many different terms are resummed on the fly, leading to a potentially reduced computational cost

Note

Most implented functions act as wrappers for the corresponding numpy functions on the individual tensors

mult(other, *args)[source]
Parameters
  • other (Union[np.ndarray, Nested, EmptyT]) – other tensor-like object to contract with

  • *args – arguments to be passed to the contraction method (np.tensordot)

Returns

result of the contraction

Return type

res

Return type

Nested

normalize()[source]

Normalize the contained tensors by the largest value of the first element of self.tensors

transpose(*args)[source]

Applies transpose to each contained tensor

Return type

Nested