Skip to content

Commit

Permalink
add a test for CG
Browse files Browse the repository at this point in the history
  • Loading branch information
mariogeiger committed Oct 2, 2023
1 parent f65018f commit 38b46bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions e3nn_jax/_src/so3.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def change_basis_real_to_complex(l: int) -> np.ndarray:
for m in range(1, l + 1):
q[l + m, l + abs(m)] = (-1) ** m / np.sqrt(2)
q[l + m, l - abs(m)] = 1j * (-1) ** m / np.sqrt(2)
return (
-1j
) ** l * q # Added factor of 1j**l to make the Clebsch-Gordan coefficients real

# Added factor of 1j**l to make the Clebsch-Gordan coefficients real
return (-1j) ** l * q


def clebsch_gordan(l1: int, l2: int, l3: int) -> np.ndarray:
Expand Down
6 changes: 6 additions & 0 deletions e3nn_jax/_src/so3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def test_clebsch_gordan_symmetry():
clebsch_gordan(1, 2, 3),
jnp.swapaxes(jnp.swapaxes(clebsch_gordan(2, 3, 1), 0, 2), 1, 2),
)
assert jnp.allclose(
clebsch_gordan(3, 2, 4), -jnp.swapaxes(clebsch_gordan(3, 4, 2), 1, 2)
)
assert jnp.allclose(
clebsch_gordan(2, 3, 4), -jnp.swapaxes(clebsch_gordan(4, 3, 2), 0, 2)
)


def unique_triplets(lmax):
Expand Down

0 comments on commit 38b46bb

Please sign in to comment.