Cartesian Tensor

class e3nn.io.CartesianTensor(formula)[source]

Bases: Irreps

representation of a cartesian tensor into irreps

Parameters:

formula (str)

Examples

>>> import torch
>>> CartesianTensor("ij=-ji")
1x1e
>>> x = CartesianTensor("ijk=-jik=-ikj")
>>> x.from_cartesian(torch.ones(3, 3, 3))
tensor([0.])
>>> x.from_vectors(torch.ones(3), torch.ones(3), torch.ones(3))
tensor([0.])
>>> x = CartesianTensor("ij=ji")
>>> t = torch.arange(9).to(torch.float).view(3,3)
>>> y = x.from_cartesian(t)
>>> z = x.to_cartesian(y)
>>> torch.allclose(z, (t + t.T)/2, atol=1e-5)
True

Methods:

from_cartesian(data[, rtp])

convert cartesian tensor into irreps

from_vectors(*xs[, rtp])

convert \(x_1 \otimes x_2 \otimes x_3 \otimes \dots\)

reduced_tensor_products([data])

reduced tensor products

to_cartesian(data[, rtp])

convert irreps tensor to cartesian tensor

from_cartesian(data, rtp=None)[source]

convert cartesian tensor into irreps

Parameters:

data (torch.Tensor) – cartesian tensor of shape (..., 3, 3, 3, ...)

Returns:

irreps tensor of shape (..., self.dim)

Return type:

torch.Tensor

from_vectors(*xs, rtp=None)[source]

convert \(x_1 \otimes x_2 \otimes x_3 \otimes \dots\)

Parameters:

xs (list of torch.Tensor) – list of vectors of shape (..., 3)

Returns:

irreps tensor of shape (..., self.dim)

Return type:

torch.Tensor

reduced_tensor_products(data: Tensor | None = None) ReducedTensorProducts[source]

reduced tensor products

Returns:

reduced tensor products

Return type:

e3nn.ReducedTensorProducts

to_cartesian(data, rtp=None)[source]

convert irreps tensor to cartesian tensor

This is the symmetry-aware inverse operation of from_cartesian().

Parameters:

data (torch.Tensor) – irreps tensor of shape (..., D), where D is the dimension of the irreps, i.e. D=self.dim.

Returns:

cartesian tensor of shape (..., 3, 3, 3, ...)

Return type:

torch.Tensor