# Spherical Tensor

There exists 4 types of function on the sphere depending on how the parity affects it. The representation of the coefficients are affected by this choice:

import torch
from e3nn.io import SphericalTensor

print(SphericalTensor(lmax=2, p_val=1, p_arg=1))
print(SphericalTensor(lmax=2, p_val=1, p_arg=-1))
print(SphericalTensor(lmax=2, p_val=-1, p_arg=1))
print(SphericalTensor(lmax=2, p_val=-1, p_arg=-1))

1x0e+1x1e+1x2e
1x0e+1x1o+1x2e
1x0o+1x1o+1x2o
1x0o+1x1e+1x2o

import plotly.graph_objects as go

def plot(traces):
traces = [go.Surface(**d) for d in traces]
fig = go.Figure(data=traces)
fig.show()


In the following graph we show the four possible behavior under parity for a function on the sphere.

1. This first ball shows $$f(x)$$ unaffected by the parity

2. Then p_val=1 but p_arg=-1 so we see the signal flipped over the sphere but the colors are unchanged

3. For p_val=-1 and p_arg=1 only the value of the signal flips its sign

4. For p_val=-1 and p_arg=-1 both in the same time, the signal flips over the sphere and the value flip its sign

lmax = 1
x = torch.tensor([0.8] + [0.0, 0.0, 1.0])

parity = -torch.eye(3)

x = torch.stack([
SphericalTensor(lmax, p_val, p_arg).D_from_matrix(parity) @ x
for p_val in [+1, -1]
for p_arg in [+1, -1]
])
centers = torch.tensor([
[-3.0, 0.0, 0.0],
[-1.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[3.0, 0.0, 0.0],
])

st = SphericalTensor(lmax, 1, 1)  # p_val and p_arg set arbitrarily here