lloca.framesnet.frames.Frames

class lloca.framesnet.frames.Frames(matrices=None, is_global=False, det=None, inv=None, parity=None, is_identity=False, shape=None, device=None, dtype=None)[source]

Bases: object

Bookkeeping class for local frames.

Collection of Lorentz transformations, represented as (…, 4, 4) matrices. Properties like det, inv and parity are cached for performance. parity is the sign that parity-odd representations pick up under the transformation; it defaults to sign(det) but is tracked separately, because derived frames can carry a non-Lorentz factor whose determinant must not leak into the parity (see LowerIndicesFrames). Attributes should not be changed after initialization to avoid inconsistencies. The object can be modified with e.g. .reshape(), .expand() and .repeat(), .to().

There are 2 ways to initialize an Frames object, with different arguments: - From matrices: Set matrices and optionally is_global, det, inv - As identity: Set is_identity=True, shape, device, dtype

Parameters:
  • matrices (torch.tensor) – Transformation matrices of shape (…, 4, 4)

  • is_global (bool) – Whether frames are the same for all particles in the point cloud

  • inv (torch.Tensor) – Optional cached inverse of shape (…, 4, 4). If not given, takes a bit of extra time to compute.

  • det (torch.Tensor) – Optional cached determinant of shape (…). If not given, takes a bit of extra time to compute.

  • parity (torch.Tensor) – Optional sign of shape (…) that parity-odd representations pick up, see the parity attribute. If not given, defaults to sign(det).

  • is_identity (bool) – Sets matrices to diagonal. Takes precedence over matrices: if both are given, matrices is only used to infer shape, device and dtype.

  • shape (List[int]) – Specifies matrices.shape[:-2] if is_identity. Otherwise inferred from matrices.

  • device (str) – Specifies device if is_identity. Otherwise inferred from matrices.

  • dtype (torch.dtype) – Specifies dtype if is_identity. Otherwise inferred from matrices.

property device
property dtype
expand(*shape)[source]

Expand the matrices to generate a new object of different shape.

Parameters:

shape (int) – New shape for the matrices. The last two dimensions must be (4, 4).

Return type:

Frames

property metric
repeat(*shape)[source]

Repeat the matrices to generate a new object of different shape.

Parameters:

shape (int) – New shape for the matrices. The last two dimensions must be (4, 4).

Return type:

Frames

reshape(*shape)[source]

Reshape the matrices to generate a new object of different shape.

Parameters:

shape (int) – New shape for the matrices. The last two dimensions must be (4, 4).

Return type:

Frames

property shape
property source

The Frames object these frames were derived from, or self if there is none.

Two frames that share a source hold a selection of the same matrices, which lets ChangeOfFrames recognize a trivial change of frames without comparing tensors.

to(dtype=None, device=None)[source]

Move the matrices to a new device and/or dtype.